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

Dublann on 15 Mar 2017, 22:25:12
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.
KadePcGames on 29 Jan 2017, 23:36:06
What would the agrument0 be?
matthe815 on 31 Jan 2017, 16:03:48
The type of session you are currently looking for.
KadePcGames on 5 Feb 2017, 00:12:01
a game like creating a game inside so friends can join :/
matthe815 on 6 Feb 2017, 04:23:23
All sessions allow for that...
Type = type of session, (Battle, Arena, Coop).
KadePcGames on 14 Feb 2017, 16:14:20
its fine i have one
KadePcGames on 14 Feb 2017, 16:15:06
but what would the arg 1 be for coop
matthe815 on 14 Feb 2017, 21:19:46
Argument 0 can equal up to 255, and using a script call you can define which type.