Usage: gms_login_execute ( callback )


Executes the login. Calls the callback-script when the login attempt finishes. The callback script is called with argument0 being either e_ok or one of the e_* errorcodes.

If you are developing a game using GameMaker Server, you are to never store or transmit user passwords (or hashes, or encoded variations). Not remotely, nor locally. Any violation of this will get your game banned.



//In scr_login:

    case e_ok:
        show_message("Login OK!");
    case e_already_logged_in:
        show_message("You're already logged in!");

Replies (28)

Last message on 24 Apr 2018

Dublann on 12 Mar 2017, 19:28:13
When Im dont type the password correctly, the error message appears, but the game crash and it shows:
of  Step Event0
for object GMS:
SERVER ERROR: Action PlayerINIString cannot be executed when not logged in
Please note: This is a server-sided error message. To disable all GameMaker Server-errors, call gms_debug_hide_errors().
 at gml_Script_XServer_step (line 401) -                         show_error("SERVER ERROR: " + XServer_readstring(_rr), false);
stack frame is
gml_Script_XServer_step (line 401)
called from - gml_Script_gms_step (line 45) - __ret = XServer_step(__current_room);
called from - gml_Object_GMS_StepNormalEvent_1 (line 5) - gms_step()

The scrip im having is for logging is very similar to the example, but having in the default case, the show_message of the example and room_goto(rm_login).
Dublann on 12 Mar 2017, 19:30:55
The code for loggin in that Im having is:

    case e_ok:
       // show_message("Login OK!");
       show_message("LOGGED IN!, PLEASE WAIT")
    case e_already_logged_in:
        show_message("You're already logged in!");
Size43 (Administrator) on 22 Mar 2017, 18:41:48
Seems like you're writing to a playerini even if the login fails. Try adding show_messages right before saving to the ini, and then login with an incorrect password. Do you see any messages pop up?
SaitoZero on 12 Jan 2016, 21:32:29
I'm encountering a small problem, first look at my code:
switch (argument0){
case e_ok: {if gms_self_isguest()
{gms_logout(); show_message("Please enter account");
objTextInput.txt=""; objPassInput.txt="";
objTextInput.selected=true; objPassInput.selected=false;
global.__player_isguest= false;}

if !gms_ini_player_exists("AvailNavi", "current")
{global.folder= ds_list_create();
show_message("Can't connect"); break;

When I tried to enter a wrong password, nothing happened, no message box was shown, nor any codes put in the "default" case would execute.
SaitoZero on 12 Jan 2016, 21:33:41
All the codes in case e_ok was working fine, by the way.
Size43 (Administrator) on 24 Jan 2016, 20:44:51
That's very strange. Are you using the All, Windows, or GM8 version of the extension?
captain_davy on 23 Aug 2014, 13:13:06
How is does this work exactly?
It would be lovely if it could do something like this (though it does not work):

if(gms_login_execute()) or "if gms_login_execute()=e_ok"?
Size43 (Administrator) on 23 Aug 2014, 15:22:36
I've added an example!
lazerg on 23 Apr 2018, 20:45:31
What to do if everything is ok? room_goto_next() ?
Size43 (Administrator) on 24 Apr 2018, 09:09:28
Yes, that would work if you have a separate room for the login screen.
Dublann on 31 Dec 2016, 22:36:07
Hi Size! And happy new year!!

I hope you can help me, Im desperated :(

Since 3 days ago I am having problems with this function. I explain better.

-In one hand, Im having a login system in which you introduce the data. With it, it is logged correctly

-In another hand, if the button "remember" is pressed, what is introduced by keyboard is stored in a txt file. This data is readed (and I have checked that it is properly stored and loaded) and then this function is called (previously was called gms_login_set_password(pass) and gms_login_set_username(name)). This part of the code was working very well 3 days ago, but now, it doesnt log in anymore, the log in works just with the first way. Has anything being changed?

This is the code I use for the 2nd way:

Create event:
if global.remember=="1"

Alarm0 event:

The script is the same than suggested by you
Dublann on 31 Dec 2016, 22:50:31
If it helps, with gms_info_isconnected(), it return 1, therefore, Im connected right?

It seems like the callback script is not executed. This is the complete script Im using:

case e_ok:
with(GMS){alarm[1]=60}//It goes to the play room, and it doesnt work. I have tried to show_messages inside this script, and it is not opened at all. It doesnt send any message, therefore I supossed that the callback is not executed
case e_already_logged_in:
show_message("You're already logged in!");
Size43 (Administrator) on 3 Jan 2017, 12:57:58
There were some server issues that have now been fixed. Are you still having this issue?
matthe815 on 2 Jan 2017, 22:23:46
When does global.remember get set to 1?
Dublann on 3 Jan 2017, 22:17:10
It is working now

suppercut2 on 2 Jul 2015, 23:02:42
I can login fine with gms_show_login(), but I can't seem to get this function to work at all.

Create script:

var bla=argument0;
show_debug_message("are we even logging in wtf")
if bla=e_ok

No debug messages are shown.
suppercut2 on 2 Jul 2015, 23:15:00
Nevermind, I figured it out on my own. dummyloginscript doesn't call on its own at all if there is no error. It does, however, if there IS an error. So for example, when I set it to automatically check gms_info_isloggedin(), it went straight to my main menu like intended. When I changed OverrideUsername to "thisuserobviouslydoesntexist", I got both debug messages and my game closed, as intended.

And your website is still kicking me off randomly, making it impossible to make this comment.
Size43 (Administrator) on 7 Jul 2015, 14:53:32
dummyloginscript should be called as soon as the extension gets a response from the server, regardless of whether the login fails or succeeds. Are you using instance_destroy or instance_deactivate_* anywhere at all? The extension needs an object (GMS object in GM:Studio, a hidden object in GM8) to exist to be able to run scripts etc.

What browser/OS are you using?
suppercut2 on 2 Jul 2015, 23:03:58
Might I add I'm getting logged out of your website every two minutes. This whole entire extension and website is irritating me, too bad I don't have the money to afford making my own...
Forgeio on 19 Aug 2015, 20:07:24
stop being such a jerk. He made this server hosting website for users like me, Gamewolf10, Chokoboy, Aaron13ps and all the other users who are making awesome games with this program, if you have a problem with it UNINSTALL it and since your so smart, program your own online game and host your own server. It only costs around $600.00 for a little server ideal for an mmo or whatever you are creating. So please remove yourself from this website, and give all of us CONTENT users who love what size is doing a break.

severs on amazon:
trg601 on 10 Apr 2015, 17:26:17
I tried making a custom login menu, it sort of works, but then really doesn't.
For some reason it will almost always give the "Already logged in error"
Then I use "gms_logout()"
And I made it keep retrying automatically to log back in but sometimes that gives an error.
(It works sometimes though)
And on top of that, you can't actually see other players in the game for some reason, which makes me think it's not actually logging you in.
Size43 (Administrator) on 10 Apr 2015, 17:28:40
Make sure you're not calling gms_login_execute multiple times. It may take a second or so before the callback is called, so having the gms_login_execute in a step or even a (non-press/release) mouse event will trigger the login multiple times.

To see if this is happening, add a show_message right before calling gms_login_execute.
Miksamoo on 10 Mar 2015, 19:09:29
gms_info_isconnected() returns 0 after 8 seconds. I test this few weeks ago but I forgot to tell it.
Size43 (Administrator) on 12 Mar 2015, 14:01:16
Are you still able to send chat messages/see other players move/etc when gms_info_isconnected() starts returning 0?
Miksamoo on 12 Mar 2015, 16:57:44
I mean I test connection after 8 seconds. Player is not connected at all.
Size43 (Administrator) on 15 Mar 2015, 17:32:20
Please double-check that your GameID hasn't changed (GM:Studio sometimes does this) the GMS object exists before you call gms_settings, and that gms_init, gms_step, gms_draw and when using the All version gms_network are called in the proper events.

You can also set a script to be executed when the client is kicked using gms_script_set_kick. The script that you set will be called with argument0 as the reason for kicking. If you put that in a show_message or something like that you can see why the server is kicking you.
Miksamoo on 14 Feb 2015, 14:34:08
I said before that gms_show_login not work on Android. Now I have done own login system, but it not work better. I have this code:


if hi_button_get_pressed(0) {
var username = get_string('Username','')

hi_ scripts is my own, don't care of them. On windows this code works fine, but on Android nothing happens.
login_errorcode_handling includes some debug messages, one on the first line, but message is not shown. I use all version and gms_network is called on networking event.
Size43 (Administrator) on 21 Feb 2015, 19:36:41

I've attempted to get an android emulator running multiple times in the past week or so, but to no avail. I'll have another go using a different emulator tomorrow.

My last guess without being able to test this myself is that you're somehow kicked from the server before/while logging in. What does gms_info_isconnected() return before calling gms_login_execute and after a few seconds?