[Tutorial] How to display current online players(OnPlayerConnect)
#4

First of all you don't need to do
PHP код:
new onlineplayers=0
If the variable has not any value set, it automatically sets it to 0 so
PHP код:
new onlineplayers
is enough

and

what Dutheil said

and

Your system won't work, if any player leaves it won't remove 1 to the count, so it will just keep adding when a player join, but not remove when a player leaves!

PHP код:
public OnPlayerDisconnect(playeridreason)
{
    
onlineplayers--;
    new 
str[128];
    
format(str,sizeof(str),"SERVER STATUS: %i players are currently online.",onlineplayers);
    
SendClientMessageToAll(0xED5F07FF,str);
    return 
1;

Reply


Messages In This Thread

Forum Jump:


Users browsing this thread: 1 Guest(s)