Getting the amount of players online.
#1

Hello, I would like to see if I can get the amount of players online, here is my code which I have now.

pawn Код:
format(string, sizeof(string), "~r~%d~w~/~b~%d ~y~Players Online", GetMaxPlayers());
Cheers.
Reply
#2

Please could some one attempt to help, I really need this fixed.
Reply
#3

Easy! Just create a variable..

pawn Код:
new PlayersOnline = 0;
OnPlayerConnect:

pawn Код:
PlayersOnline++;
OnPlayerDisconnect:

pawn Код:
PlayersOnline--;
Wallah!
Reply
#4

hi,

you could also count the players with a variable on the server:

pawn Код:
new Players;

//OnPlayerConnect

Players++;

//OnPlayerDisconnect

Players--;


//and show them where u want...
format(string, sizeof(string), "%d Players Online", Players);
SendClientMessage(playerid,colour,string);

regards, wolf.
//edit: damn, too slow
Reply
#5

pawn Код:
stock OnlinePlayers() return Itter_Count(Player);
Reply
#6

Thanks, I have done it now .
Reply
#7

I think it works:

PHP код:
forward Check();

public 
Check()
{
    new 
players;
    for(new 
0MAX_PLAYERS++)
    {
        if(
IsPlayerConnected(i)) players++;
    }
    return 
players;
}

format(stringsizeof(string), "~r~%d~w~/~b~%d ~y~Players Online"CheckGetMaxPlayers()); 
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)