SA-MP Forums Archive
Problem with GetPlayerID - 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)
+---- Forum: Help Archive (https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: Problem with GetPlayerID (/showthread.php?tid=241594)



Problem with GetPlayerID - bijoyekuza - 18.03.2011

hey guys .
So,I need the GetPlayerID function . so I added it in the end of the GM.(stock)
like this
Код:
stock GetPlayerID(const Name[])
{
	for(new i = 0; new max = GetMaxPlayers(); i < max; i++)
	{
	    if(IsPlayerConnected(i))
		{
  		new pName2[MAX_PLAYER_NAME];
		GetPlayerName(i, pName2, sizeof(pName2));
			if(strcmp(Name, pName2, true) ==0)
			{
			    return i;
			}
		}
	}
	return -1;
}
yep, not i got the errors.
PHP код:
(3185) : error 029invalid expressionassumed zero
(3185) : warning 204symbol is assigned a value that is never used"i"
(3185) : error 017undefined symbol "i"
(3185) : error 076syntax error in the expression, or invalid function call
(3185) : fatal error 107too many error messages on one line 
line 3185
for(new i = 0; new max = GetMaxPlayers(); i < max; i++)



Re: Problem with GetPlayerID - ricardo178 - 18.03.2011

Use sscanf


Re: Problem with GetPlayerID - bijoyekuza - 18.03.2011

I dont want to include sscanf in my script . I know its easy but I just dont want to use it .


Respuesta: Problem with GetPlayerID - Sandman-x - 18.03.2011

pawn Код:
stock GetPlayerID(Name[])
{
    for(new i = 0; i < MAX_PLAYERS; i++)
    {
        if(IsPlayerConnected(i))
        {
        new pName2[MAX_PLAYER_NAME];
        GetPlayerName(i, pName2, sizeof(pName2));
            if(!strcmp(Name, pName2))
            {
                return i;
            }
        }
    }
    return -1;
}
Try this.