Usage: gms_other_count ( )


Returns the number of players online subtracted by 1 (one, that's you)


//Show the names of all players
var n, player_id, name;
for(n = 0; n < gms_other_count(); n += 1)
    player_id = gms_other_find(n);
    name = gms_other_get_string(player_id, "name")

Replies (21)

Last message on 14 Jan 2017

Dublann on 26 Dec 2016, 21:21:49
Hi everyone!

I dont know why I am not able to use properly the vs functions, therefore I have checked with the function gms_other_count ( ) what says. I have open the game with 2 android devices, the player INIs for each player are correctly loaded, stored, saved...I mean, they are correctly logged in, but when I ask for the show_message(gms_other_count ( )) is always says 0. In fact, the chat is not working!! Both players are not seeing what the other player is sending.

What am I not taking into account?

PS: others days the chat was working well. Any issue with the server?

Size43 (Administrator) on 3 Jan 2017, 12:55:48
Hey, apologies for my very late response. I've had some issues with my hand that prevented me from using a computer (RSI).

There were some server issues that have now been fixed. Please let me know if you're still having issues.
Dublann on 4 Jan 2017, 19:54:30
Hi Size!

Chat is still not working, but some days ago it was working very well.

The code Im using is:

Step Event:

Left button event:"CHAT","")))

Room end event:

What is typed is shown in the chat box, but not sent to the others (they are already logged in).
Size43 (Administrator) on 6 Jan 2017, 10:03:29
Could you check what gms_info_isconnected() and gms_info_isloggedin() return right before sending the chat message?
Dublann on 6 Jan 2017, 12:52:31
I have checked gms_other_count(), gms_info_isconnected() and gms_info_isloggedin() just after logged in in both devices with different accounts, and the resutls were 0; 1; 1 respectively.

I did the same just before and just after sending the chat message, and the results were also 0; 1; 1.
Dublann on 10 Jan 2017, 18:55:23
Size, is it related with the problems on sync functions?
Size43 (Administrator) on 10 Jan 2017, 19:02:32
It should not be related.

Could you post the code you're using for logging in?

(Also, just make sure you're not accidentally destroying the GMS object. gms_network needs to be called each step so that the extension can receive data from the server)
Dublann on 10 Jan 2017, 19:15:14
GMS object:

Create event:
gms_settings(true, 1.0, obj_player, obj_other_player);

if global.recordar=="1"//This variable is true when the button remember is pressed
else{room_goto(rm_login)}//In this room with get_string you get the user data and execute the script that switch(argument0)...

Alarm0 event:
gms_login_execute(scr_login_recordado)//The scrip is the switch(argument0)...

These global var are stored in a local txt file. They are got using get_string function

Step event:

Networking event:

Draw event:

Game end event:
Size43 (Administrator) on 11 Jan 2017, 16:37:54
That code looks fine. I'm thinking both clients somehow end up in different sessions. Can you check to see if the session IDs are the same? (gms_session_current_id)
Dublann on 11 Jan 2017, 20:02:26
It says that both players are in the session 0.

Maybe the problem is in the object chat. It is what Im having:

Step event:


Left released event:"CHAT","")))

Room end event:
Size43 (Administrator) on 11 Jan 2017, 21:58:26
Well if the session id is 0, there's definitely something wrong with the login process. The session id should be greater or equal to 1. Make sure you're not accidentially calling gms_login_execute twice (maybe there are two GMS instances in the room?). Also, check if you're getting kicked from the server by setting a script in gms_script_set_kick.
Dublann on 12 Jan 2017, 19:23:05
Size I dont find the problem. This is what i did:

- look for where is gms_login_execute , and it is added only in GMS object. In case I missed something, I added a show_message for each time this function is executed, and it was executed only once during the game.
-There is only 1 object gms in the rooms (it is persistent and placed only in the first room)
- With gms_script_set_kick, I added it into a persisten object in the step event. The scrip just said argument0="KICKEADO". It never appears

Any other idea?
Dublann on 14 Jan 2017, 14:12:09
Another thing that I have done in order to check if the session_id is being modified during the game, is to create a session to join in the first room, and check if this id is changing when I press a key. I have confirmed that the session_id once created is never changed and I keep contected to it.

It seems that when gms_login_execute is called, it does not create a session. It remains me in the session "0" (I have also checked it with the debugger mode). So, it seems to be the reason why I am not able to send/receive chat messages.
Size43 (Administrator) on 14 Jan 2017, 14:20:03
Yeah, that's definitely an issue. The session id will change when logging in, otherwise you're not logged in. Try changing the kick script to


Otherwise you won't know if it was run. Also, could you post the contents of scr_login_recordado?
Dublann on 14 Jan 2017, 14:36:57
I have changed the kick script and nothing happens:

in step event of GMS: gms_script_set_kick(scr_kick)
In script "scr_kick": show_message(argument0)

The scr_login_recordado is having:

case e_ok:
//show_message("Login OK!");
with(GMS){alarm[1]=5}//This alarm is having room_goto(room_main_centro)
case e_already_logged_in:
show_message("You're already logged in!");

I think Im logged in the server, because the player INI are well readed. In fact, on every room they need to be loaded and always they are loaded correctly.
Size43 (Administrator) on 14 Jan 2017, 14:38:40
That's very strange. Would you mind mailing me your project (or a similar one that has the same issue) at
Dublann on 14 Jan 2017, 16:05:57
Already sent.

Thank you very much!!
Bluecore on 19 Aug 2016, 07:37:30
I am trying to use this code to display on the title screen how many people are online playing my game however I seem to only get 0 no matter how many instances of the game I do.

Draw Event:
var PLayerCount
PlayerCount = gms_other_count()

draw_text_ext_transformed_colour(x+2,y,string(PlayerCount) + " filled with DETERMINATION!",10,200,2,2,0,c_white,c_white,c_white,c_white,1);
Bluecore on 19 Aug 2016, 07:41:14
Made a small mistake with the var name, fixed it but the same problem still happens.
var PlayerCount
PlayerCount = gms_other_count()

draw_text_ext_transformed_colour(x+2,y,string(PlayerCount) + " filled with DETERMINATION!",10,200,2,2,0,c_white,c_white,c_white,c_white,1);
Size43 (Administrator) on 20 Aug 2016, 22:50:22

gms_other_count() currently only works when you're logged in. An easy solution to this would be to have a player (which is logged in) periodically write gms_other_count to the GameINI. The GameINI can then be read from the title screen by clients that aren't logged in.

To choose a player, you could use gms_self_ismaster(), which will return true for exactly one player in the game.

Ps. Thank you so much for the donation!
Bluecore on 28 Aug 2016, 00:28:48
Thank you very much for the solution and it was my pleasure! Thanks to you, great things can be accomplished using Game Maker.