[Ajuda] Pegar id do Player
#5

Vocк pegar pegar o Id pelo Nome.

PHP код:

stock GetPlayerID
(pNick[]) {
    for(new 
p!= MAX_PLAYERSp++)
    {
        if(!
strcmp(PlayerName(p), pNickfalse) && IsPlayerConnected(p)) return p;
    }
    return -
1;

Mas isso й banal, se vocк quer saber o ID do Player, faзa assim: um exemplo em um comando:

PHP код:

new IdPlayer[MAX_PLAYERS] = INVALID_PLAYER_ID;
CMD:player(playeridparams[]) {
    new 
id;
    if(
sscanf(params"u"id)) return SCM(playeridCOLOR_ERRO"| ERRO | Digite: /player [id do jogador]");
    if(!
IsPlayerConnected(id)) return SCM(playeridCOLOR_ERRO"| ERRO | Esse(a) jogador(a) nгo estб conectado(a).");
    
IdPlayer[playerid] = id// O id do Jogador que vocк digitou /player [id] estarб armazenado nessa variбvel.
    
return 1;
}
public 
OnPlayerDisconnect(playeridreason) {
    
// Exemplo de Uso:
    
if(IdPlayer[playerid] != INVALID_PLAYER_ID)
    {
        new 
string[100];
        
        
format(stringsizeof(string), "O Jogador %s[%d] Que digitou: /Player [%d], ou seja, seu ID, se desconectou."PlayerName(playerid), playeridIdPlayer[playerid]);
        
SCM(IdPlayer[playerid], -1string); // Mensagem Aq
        
        
IdPlayer[playerid] = INVALID_PLAYER_ID// Resetar as variaveis ao desconectar й importante.
    
}
    return 
true;
}
stock PlayerName(playerid) {
    new 
nNick[MAX_PLAYER_NAME];
    
    
GetPlayerName(playeridnNicksizeof(nNick));
    return 
nNick;

Reply


Messages In This Thread
Pegar id do Player - by BrunoSayden177 - 26.01.2019, 21:46
Re: Pegar id do Player - by PedroH - 26.01.2019, 21:57
Re: Pegar id do Player - by BrunoSayden177 - 26.01.2019, 22:30
Re: Pegar id do Player - by Lovejoy - 26.01.2019, 22:32
Re: Pegar id do Player - by GuiKommander - 26.01.2019, 22:33
Re: Pegar id do Player - by PedroH - 26.01.2019, 22:36
Re: Pegar id do Player - by BrunoSayden177 - 26.01.2019, 23:03
Re: Pegar id do Player - by GuiKommander - 26.01.2019, 23:26

Forum Jump:


Users browsing this thread: 1 Guest(s)