gms_login_execute

Usage: gms_login_execute ( callback )

Description

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.

Example

gms_login_execute(scr_login)

//In scr_login:

switch(argument0)
{
    case e_ok:
        show_message("Login OK!");
        break;
    case e_already_logged_in:
        show_message("You're already logged in!");
        break;
    default:
        show_message(gms_login_error_tostring(argument0));
        break;
}

Replies (26)

Last message on 22 Mar 2017

Dublann on 12 Mar 2017, 19:28:13
Hey!
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:
gms_login_set_password(global.pass1)
gms_login_set_username(global.usuario)
gms_login_execute(scr_login)


scr_login]
switch(argument0)
{
    case e_ok:
       // show_message("Login OK!");
       //instance_create(room_width/2,room_height/2,obj_tiempo)
       show_message("LOGGED IN!, PLEASE WAIT")
       with(obj_login_GMS){alarm[0]=60}
        break;
    case e_already_logged_in:
        show_message("You're already logged in!");
        room_goto(rm_login)
        break;
    default:
        show_message(gms_login_error_tostring(argument0));
        room_goto(rm_login)
        break;
}
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;}
else{
show_message("Connected");

if !gms_ini_player_exists("AvailNavi", "current")
{room_goto(rmCharSel)}
else
{global.folder= ds_list_create();
scrClientUpdate(0);
scrClientUpdate(1);
scrClientUpdate(2);
room_goto(rmPET)}
};
}
break;
default:
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"?
{
room_goto_next()
}else{
show_message("ERROR")
}
Size43 (Administrator) on 23 Aug 2014, 15:22:36
I've added an example!
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"
{
alarm[0]=10
}
else{room_goto(rm_login)}

Alarm0 event:
gms_login_set_password(global.pass1)
gms_login_set_username(global.usuario)
gms_login_execute(scr_login_recordado)

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:

switch(argument0)
{
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
break;
case e_already_logged_in:
show_message("You're already logged in!");
room_goto(rm_login)
break;
default:
show_message(gms_login_error_tostring(argument0));
room_goto(rm_login)
break;
}
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

Thx!
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:
gms_login_set_username(OverrideUsername)
gms_login_set_password(OverridePassword)
gms_login_execute(dummyloginscript)

dummyloginscript:
var bla=argument0;
show_debug_message("are we even logging in wtf")
if bla=e_ok
{
show_debug_message(gms_login_error_tostring(bla))
room_goto_next()
}
else
{
show_debug_message(gms_login_error_tostring(bla))
game_end()
}

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:http://www.amazon.com/dp/B00NR1GW1A/ref=ams_at_2812501301039_B0096CMENO
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:

hi_button_press(0)

if hi_button_get_pressed(0) {
var username = get_string('Username','')
gms_login_set_username(username)
gms_login_set_password(get_string('Password',''))
gms_login_execute(asset_get_index('login_errorcode_handling'))
}

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
Hey,

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?

Size43