PDA

View Full Version : Get playerid from variable


Tanush123
10/06/2013, 03:16 AM
How can i get someone's ID from a variable?

Imagine someone owns a business

BusInfo[playerid][Owner]
The owner is Papa and [Owner] is Papa

Can i get the playerid from the BusInfo[playerid][Owner] ?

admantis
10/06/2013, 03:23 AM
Use the following function:

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

cristip
10/06/2013, 03:29 AM
use sscanf :) for that