SA-MP Forums Archive
Get Online Player Count Bug? - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: Get Online Player Count Bug? (/showthread.php?tid=450036)



Get Online Player Count Bug? - Blackazur - 11.07.2013

Hello, i have an problem, the problem is that for example: when 10 players online and 1 new guy come online it says then something like [36/50], but why is that so? I think the variables didnt reset or something like that.

Код:
new gPlayersConnected = 0;



// OnPlayerConnect

gPlayersConnected++;
new string[124], name[MAX_PLAYER_NAME+1];
GetPlayerName(playerid, name, sizeof(name));
format(string, sizeof(string), "Player %s connected. There are %d/50 players connected", name, gPlayersConnected);
SendClientMessage(playerid, -1, string);


// OnPlayerDisconnect

gPlayersConnected--;
new string[124];
new name[MAX_PLAYER_NAME+1];
GetPlayerName(playerid, name, sizeof(name));
format(string, sizeof(string), "Player %s left the server. There are %d/50 players connected", name, gPlayersConnected);
SendClientMessage(playerid, -1, string);



AW: Get Online Player Count Bug? - Blackazur - 11.07.2013

Also like this?:

Код:
stock GetConnectedPlayers() return Iter_Count(Character);