[HELP] check if player is online when using offline command
#3

Untested but should work
PHP код:
CMD:offcheck(playerid,params[])
{
    new 
offnick[MAX_PLAYER_NAME];
    if(
sscanf(params,"s[128]",offnick)) return SendClientMessage(playerid, -1"Usage: /offcheck [full name]");
    if(
IsPlayerConnected(GetPlayerIdFromName(offnick)) return SendClientMessage(playerid, -1"You cannot use this command on online players.");
    
// Code
    
return 1;
}
stock GetPlayerIdFromName(playername[])
{
  for(new 
0<= MAX_PLAYERSi++)
  {
    if(
IsPlayerConnected(i))
    {
      new 
playername2[MAX_PLAYER_NAME];
      
GetPlayerName(iplayername2sizeof(playername2));
      if(
strcmp(playername2playernametruestrlen(playername)) == 0)
      {
        return 
i;
      }
    }
  }
  return 
INVALID_PLAYER_ID;

Reply


Messages In This Thread
[HELP] check if player is online when using offline command - by Luca12 - 04.04.2015, 08:14
AW: [HELP] check if player is online when using offline command - by Mencent - 04.04.2015, 08:22
Re: [HELP] check if player is online when using offline command - by Sellize - 04.04.2015, 08:59
Re: AW: [HELP] check if player is online when using offline command - by Luca12 - 04.04.2015, 11:41

Forum Jump:


Users browsing this thread: 1 Guest(s)