Get Player id from name
#1

Hello, i have a varible 'nev' for e.g. "Thommas_Cook".
And the code is:
Код:
new id = GetPlayerID(nev);
if (IsPlayerConnected(id)) {
   // 1
}
else
{
   // 2
}
The second cames always, when the player (Thommas Cook) is connected, or not connected. Why?
I debug it with prinf(id) and printf(nev) and it's good, (id = playerid, 0), nev is Thommas_Cook
Reply
#2

Use sscanf its lot more easier and has a specifier already for that
Example
pawn Код:
new id;
if(sscanf(nev, "u", id))
{
     //player is NOT connected
}
else
{
     //now 'id' contains id of the player who's name is in 'nev'
}
PS. You need sscanf plugin and include to use this function
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)