gms_script_set_session_change

Usage: gms_script_set_session_change ( script_id )

Description

Sets the script that will be called when the player's session_id changes.

The script script_id should take 1 argument.
1: The new session_id

Replies (6)

Last message on 1 Jun 2018

muniznico on 10 May 2018, 19:37:43
Hi Size,

I have a problem. i have set a simple script to handle a session change.

//in GMS object
gms_script_set_session_change(on_session_change);

//on_session_change(new_id)

var new_id = argument0;
if(new_id != gms_session_current_id()){
session_type = gms_session_type(new_id);
if(session_type == 1){
//show_message(gms_session_current_id());
room_transition = instance_create(0,0,obj_screen_transition);
room_transition.next_room = rm_wait_screen;
}
else if(session_type == 0){
//show_message(gms_session_current_id());
room_transition = instance_create(0,0,obj_screen_transition);
room_transition.next_room = rm_main_menu;
}
}

but when i call :

gms_session_create_ext(1,tag);

the script always pass by the "session_type == 0" case...
But after that, i check the session type (with a show_message), and it returns 1.

I can't handle session creation because of that.
Can you help me please ?
Size43 (Administrator) on 27 May 2018, 16:37:00
What version of GameMaker Server are you using? Windows or all?
muniznico on 29 May 2018, 08:49:17
I'm using the windows version (I can't seem to login with the all version). I found a way to work around my problem, but if you know why is this happening, i would still be glad to know the answer ;)

By the way, i have another question. Sometimes, the function "gms_session_count()" takes a really long time to find the active sessions in my game. I know there are multiple sessions running by my friends (or me in multiple game runs), but when i join my lobby room, the function only find the main session (type 0). I'm executing the function in the step event while i don't find a session that fit the requisite type and tag, but it can take to 6~7 minutes to find the right sessions. Sometimes it works immediately, sometimes not.

Is it a normal behavior ? Maybe because the server is busy ?

Thanks by advance for your reply.
Size43 (Administrator) on 1 Jun 2018, 16:28:27
(Maybe the all version isn't working because the call to gms_network in the async networking event is missing?)

If you're able to reproduce the session behaviour at least semi-regularly please send your project (or something similar that has the same issue) to gamemakerserver@outlook.com so I can take a look.

You could also try to force a session update using gms_request_resource.
Dublann on 15 Mar 2017, 20:06:23
Hi Size,

To use it, should be like this?
somewhere in the code
gms_script_set_session_change(scr_session)


scr_session
argument0=1


Because it is connected to a random session id instead of the session 1.

THX
Size43 (Administrator) on 22 Mar 2017, 18:50:20
Session IDs are random, you can only change the session type (when creating a new session).