29.01.2012, 02:49
Using for
Foreach is similar, just replace the for loop.
pawn Код:
stock FindPlayerByName(name[])
{
new Pname[24];
for(new i; i<MAX_PLAYERS; i++)
{
if(!IsPlayerConnected(i)) continue;
GetPlayerName(i, Pname, 24);
if(!strcmp(Pname, name, true)) return i;
}
return -1;
}