08.05.2010, 13:37
is there a way to check if a player is connected withuot the id but with his name, like IsPlayerConnected(name[])?
stock IsNickConnected(Nick[])
{
new Name[24];
for(new d,g=GetMaxPlayers(); d < g; d++)
if(IsPlayerConnected(d) && !IsPlayerNPC(d))
{
GetPlayerName(d,Name,24);
if(!strcmp(Name,Nick,true)) return true;
}
return false;
}
IsPlayerNickConnected(Name[])
{
PlayerNick[MAX_PLAYER_NAME];
for(new i=0; i <= GetMaxPlayers(); i++)
{
if(IsPlayerConnected(i) && !IsPlayerNPC(i))
{
GetPlayerName(i, PlayerNick, MAX_PLAYER_NAME);
if(strfind(PlayerNick,Name,true) != -1) return 1;
}
}
return 0;
}