How Do Sessions Work

Posted by KadePcGames
How Please Tell Me How I Have No Idea I Have Been Looking For Hours
All I know is how to make one but never join one
:/
can someone help me make a type 1 session
this is what i have
if gms_session_exists(1//Example

{
show_message("Showing Sessions")
script_execute(gms_session_find_type_,gms_session_count())
if gms_session_exists(0)
{
room_restart()
}
if gms_session_exists(1)
{
gms_session_join(1)
}
}
else
{
show_message("error No Sessions Found")
room_restart()
}

Replies (9)

Last message on 9 Feb 2017

Size43 (Administrator) on 5 Feb 2017, 14:19:53
gms_session_exists (and the other gms_session_* functions you're using too) expects a session ID, not a session type. It would look something like this:

var session_id = gms_session_find_type_(1)
if session_id == -1
{
    // create session
} else {
    // join session
}


(assuming gms_session_find_type_ is the script shown on the gms_session_count page)
KadePcGames (Topicstarter) on 5 Feb 2017, 21:14:29
oh :|
KadePcGames (Topicstarter) on 5 Feb 2017, 21:17:17
so its like
var session_id = gms_session_find_type_(1)
if session_id == -1
{
    // create session
} else {
    // join session
}

but then what is this part for
if session_id == -1
{
    // create session
} else {
    // join session
}
KadePcGames (Topicstarter) on 5 Feb 2017, 21:18:57
wait is it like if theres a session open it joins it? and if not it does nothing
KadePcGames (Topicstarter) on 5 Feb 2017, 21:23:30
if you can give me and ex for creating one and joning one :/
Zecca on 6 Feb 2017, 16:06:54
If you made the custom script "gms_session_find_type" found in the tutorial you just have to do this:

var session = gms_session_find_type(1);
if session {
gms_session_join(session);
} else {
gms_session_create(1);
}

it search for type 1 session, if it found one it join it, else it makes one
KadePcGames (Topicstarter) on 7 Feb 2017, 16:20:37
It Worked I Did This
var session = gms_session_find_type(1);
if session {
gms_session_join(session);
room_goto (rm_session);
} else {
gms_session_create(1);
room_goto (rm_session);
}

And It Was Good
KadePcGames (Topicstarter) on 9 Feb 2017, 05:29:30
Wait Will This Work :|
var session = gms_session_find_type(1);
if session {
if gms_session_player_count(session_id) < 4 
{gms_session_join(session);
room_goto (rm_session);
gms_show_message("Found A Campain Game");} else {room_goto(rm_play);
gms_show_message("Its Full Sorry")}
} else {gms_show_message("none found Creating One")
gms_session_create(1)
room_goto (rm_session)
}
KadePcGames (Topicstarter) on 9 Feb 2017, 05:36:00
frogot to add
var session_id = gms_session_id(session_id)