Get playerid from variable
#1

How can i get someone's ID from a variable?

Imagine someone owns a business
pawn Код:
BusInfo[playerid][Owner]
The owner is Papa and [Owner] is Papa

Can i get the playerid from the BusInfo[playerid][Owner] ?
Reply
#2

Use the following function:
pawn Код:
stock GetPlayerIdFromText(text[]) {

    new name[24];
    for(new i = 0; i != MAX_PLAYERS; i++) {
   
        if(!IsPlayerConnected(i)) continue;
       
        GetPlayerName(i, name, 24);
        if(!strcmp(name, text)) {
       
            return i;
        }
    }
    return INVALID_PLAYER_ID;
}
Reply
#3

use sscanf for that
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)