SA-MP Forums Archive
Get playerid from variable - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: Get playerid from variable (/showthread.php?tid=443030)



Get playerid from variable - Tanush123 - 10.06.2013

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] ?


Respuesta: Get playerid from variable - admantis - 10.06.2013

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;
}



Re: Get playerid from variable - cristip - 10.06.2013

use sscanf for that