gms_friend_count

Usage: gms_friend_count ( )

Description

Retruns the number of friends.

Example

//Draw all friends
var n, user_id, name;
for(n = 0; n < gms_friend_count(); n += 1)
{
user_id = gms_friend_get(n);
name = gms_friend_name(user_id)
draw_text(0, n * 20, name);
}

Replies (11)

Last message on 21 Oct 2018

CurrentCanine on 13 Sep 2018, 05:17:09
Hi, I build my own friends list screen and for some reason every time I restart my game the number of friends on your friends list increases every time. I use "game_restart()" to automatically restart the game and log the player out. However if you log back in and view your friends list the same friends show up twice (or more if you log out again and log back in). I'm willing to email you my project if necessary, this is a pretty important problem to fix for me. =)
Size43 (Administrator) on 30 Sep 2018, 12:41:34
Yup, that sounds like a bug.

Is this happening with the Windows or the All version?
CurrentCanine on 30 Sep 2018, 16:57:11
Windows
Size43 (Administrator) on 21 Oct 2018, 16:46:21
Apologies for the wait. Does this release fix the issue?:https://gamemakerserver.com/staticcontent/GameMaker Server 2.1.4.zip
CurrentCanine on 13 Sep 2018, 05:17:44
My friends list code::
var YY = TotalBarSize+1
for(i=0;i<gms_friend_count();i+=1) {
var Player = gms_friend_get(i)
var Colour = c_gray
if(gms_friend_isonline(Player)) {
Colour = c_orange
var ScoreBoard = FindScoreTable("CurrentSession") //A script that returns the id of the highscore table
if(gms_session_exists(gms_highscore_score(ScoreBoard,gms_highscore_find_pos(ScoreBoard,gms_friend_name(Player))))) {
Colour = c_green //Set the background colour as green if the player is in a match (The highscore table "CurrentSession" has -1 for every player offline or in the menus)
}
}
draw_set_colour(Colour) draw_set_alpha(0.6)
draw_rectangle(0,YY,window_get_width(),YY+string_height(gms_friend_name(Player))+2,0)
draw_set_font(fFine) draw_set_colour(c_black) draw_set_alpha(1)
draw_text(5,YY+1,gms_friend_name(Player))
YY += string_height(gms_friend_name(Player))+2
}
TehAwesomestKitteh on 14 Sep 2018, 13:59:41
Is the object this script is calling on persistent?
CurrentCanine on 15 Sep 2018, 23:06:49
No, but I made it persistent wondering if that was the issue and it didn't help...
TehAwesomestKitteh on 19 Sep 2018, 11:15:07
hmm, right after your "game_restart()", try to add the following and see if it works:
ScoreBoard = -1; YY = -1;

Otherwise it *might* be a bug
CurrentCanine on 19 Sep 2018, 15:55:54
Nope didn't help either, I think it's a bug... I've read through this code ~10 times already trying to find out the issue, and I've even recoded it a couple of times. Still no luck...
rggames on 23 Sep 2018, 04:12:01
Maybe the game is saving the number of friends everytime you close the game and loading it, and when the operation on the code increases something by 1 on the line 3, it increases the number that has already loaded and it repeats, so, you should check the saving system if your game haves one. Look for something that talks about the total of friends on the code.
Ryaangu on 28 Sep 2018, 14:58:24
Hmmmm