[Ajuda] Players On
#1

Esta correto assim?

pawn Код:
if(strcmp(cmd, "/playersonline", true) == 0)
    {
    new Str[40];
    if(!IsPlayerNPC(playerid))
    {
    format(Str,sizeof(Str),"Players Online: %d", PlayersOnline);
    SendClientMessage(playerid, -1, Str);
    return 1;
    }
Para fazer a verificaзгo sem contar com os npcs, esta correto?

Corrigi nгo sei se esta certo:


pawn Код:
if(strcmp(cmd, "/playersonline", true) == 0)
    {
    if(!IsPlayerNPC(playerid))
    {
    new Str[40];
    format(Str,sizeof(Str),"Players Online: %d", PlayersOnline);
    SendClientMessage(playerid, -1, Str);
    }
    return 1;
    }
Porem agora sim compilou.
Reply
#2

Estб correto se for um NPC que digitar o comando -q'

Para contar os players online sem contar os NPCs, vб atй a OnPlayerConnect mude onde provavelmente estб PlayersOnline ++; para if(!IsPlayerNPC(playerid)) PlayersOnline ++;.

Adapte tambйm ao OnPlayerDisconnect.
Reply
#3

Entгo ficarб assim?

pawn Код:
if(strcmp(cmd, "/playersonline", true) == 0)
    {
    new Str[40];
    format(Str,sizeof(Str),"Players Online: %d", PlayersOnline);
    SendClientMessage(playerid, -1, Str);
    }
    return 1;
    }
?
ou deixo como estava e acrescento as linhas qe vocк disse em Connect & Disconnect?
Reply
#4

pawn Код:
//topo
new
    TotalOn = 0
;

//Onplayerconnect
if(!IsPlayerNPC(playerid))
{
    TotalOn++;
}

//Onplayerdisconnect
if(!IsPlayerNPC(playerid))
{
    TotalOn--;
}
if(strcmp(cmd, "/playersonline", true) == 0)
{
    new
        Str[ 40 ]
    ;
    format(Str,sizeof(Str),"Players Online: %i", TotalOn);
    SendClientMessage(playerid, -1, Str);
    return 1;
}
Reply
#5

Oi Skygay, esse seu code ele vai aparecer a mensagem quando o player entra no servidor e ao digitar o comando?
Reply
#6

pq gay? ^^

pawn Код:
//Onplayerconnect
if(!IsPlayerNPC(playerid))
{
    static SK_[ 40 ];
   
    TotalOn++;
   
    format(SK_, sizeof( SK_ ),"Players Online: %i", TotalOn);
    SendClientMessage(playerid, -1, SK_);
}
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)