25.03.2012, 05:37
pawn Код:
stock IsNumeric(const string[])
{
for (new i = 0, j = strlen(string); i < j; i++)
if(string[i] > '9' || string[i] < '0') return 0;
return 1;
}
stock ReturnUser(PlayerName[])
{
if(IsNumeric(PlayerName))
return strval(PlayerName);
else
{
new found=0, id;
for(new i, p = GetMaxPlayers(); i < p; i++)
{
if(IsPlayerConnected(i))
{
new foundname[MAX_PLAYER_NAME];
GetPlayerName(i, foundname, MAX_PLAYER_NAME);
new namelen = strlen(foundname);
new bool:searched=false;
for(new pos=0; pos <= namelen; pos++)
{
if(searched != true)
{
if(strfind(foundname,PlayerName,true) == pos)
{
found++;
id = i;
}
}
}
}
}
if(found == 1)
return id;
else
return INVALID_PLAYER_ID;
}
}