Get a player ID
#1

Hi everybody !

I need your help for a little thing.

I have in my script this:

pawn Код:
PlayerInfo[playerid][pNum]
pNum is a value that changes when the player connect, when he disconnect, the value is 0.

I need to get the player's id who have the number 84 for example with /getid 84 the command tells me:

Person 84, ID: 6

But i don't know how to do that ...
Reply
#2

pawn Код:
if(!strcmp(cmdtext,"/getid",true,6))
{
    if(strlen(cmdtext) == 6 || cmdtext[6] == ' ')
    {
        if(!strlen(cmdtext[7])) return SendClientMessage(playerid, 0xFF0000FF, "USAGE: /getid [pNum]");
        new id = strval(cmdtext[7]), user = -1;
        for(new i=0; i<MAX_PLAYERS; i++)
        {
            if(PlayerInfo[i][pNum] == id)
            {
                user = i;
                break;
            }
        }
        if(user == -1) return SendClientMessage(playerid, 0xFF0000FF, "ERROR: No player with such pNum found.");
        new string[128], name[24]; GetPlayerName(playerid, name, 24);
        format(string, sizeof(string), "Player %s (ID: %d) has the pNum %d.",name, user, id);
        return SendClientMessage(playerid, 0x00FF00FF, string);
    }
}
Not sure if this is what you are looking for.
Reply
#3

Yes it's that but the problem is allready solved, someone else helped me Instead, thx
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)