gms_session_count
Usage: gms_session_count ( )
Description
Returns the number of sessions.
Example
//Script: gms_session_find(type)
//Returns a session_id for the given type, if it exists, otherwise this script will return -1
for(i = 0; i < gms_session_count(); i += 1)
{
//Check whether the session is of the right type
if(gms_session_type(i) == argument0) return gms_session_id(i);
}
return -1;
Replies (9)
Last message on 22 Mar 2017
Hi Size,
Why is it not working? I dont understand why:
if room=room_main_centro
{
id_sesion=scr_session(1)
if id_sesion=-1{gms_session_create(1)} else{gms_session_join(id_sesion)}
show_message(gms_session_current_id())
}
scr_session()
for(i = 0; i < gms_session_count(); i += 1)
{
//Check whether the session is of the right type
if(gms_session_type(i) == argument0) return gms_session_id(i);
}
return -1;
I did the trial with 2 players, and each time I go to this room, a new session is created by each player.
THX
Size43
(Administrator)
on
22 Mar 2017, 18:55:33
You need a small delay before the session ID changes. If you move the show_message to the session changed script it should work.
What would the agrument0 be?
The type of session you are currently looking for.
a game like creating a game inside so friends can join :/
All sessions allow for that...
Type = type of session, (Battle, Arena, Coop).
but what would the arg 1 be for coop
Argument 0 can equal up to 255, and using a script call you can define which type.