14.10.2011, 17:33
Verifique se vocк tambйm possui a funзгo ReturnUser.
pawn Код:
ReturnUser(text[], playerid = INVALID_PLAYER_ID)
{
new pos = 0;
while (text[pos] < 0x21)
{
if(text[pos] == 0) return INVALID_PLAYER_ID;
pos++;
}
new userid = INVALID_PLAYER_ID;
if(IsNumeric(text[pos]))
{
userid = strval(text[pos]);
if(userid >=0 && userid < PLAYERS)
{
if(!IsPlayerConnected(userid))
{
userid = INVALID_PLAYER_ID;
}
else
{
return userid;
}
}
}
new len = strlen(text[pos]);
new count = 0;
new name[MAX_PLAYER_NAME];
for(new i=0; i < MAX_PLAYERS; i++)
{
if(IsPlayerConnected(i))
{
GetPlayerName(i, name, sizeof (name));
if(strcmp(name, text[pos], true, len) == 0)
{
if(len == strlen(name))
{
return i;
}
else
{
count++;
userid = i;
}
}
}
}
if(count != 1)
{
if(playerid != INVALID_PLAYER_ID)
{
if(count)
{
SendClientMessage(playerid, -1, "Muitos jogadores encontrados, por favor, procure com mais detalhes.");
}
else
{
SendClientMessage(playerid, -1, "Nenhum jogador encontrado.");
}
}
userid = INVALID_PLAYER_ID;
}
return userid;
}