Issue with IsPlayerConnected and GetPlayerID
#1

Hello,
so i want to obtain the name of the player, but ONLY if the player is offline.
This doesn't work, and I have no idea why.
Can someone help me?
ty
PHP код:
/* ============================================================================= */
COMMAND:foff(playerid,params[])
{
    if(!
Player[playerid][Faction]) return SendClientError(playerid,"You are not in a faction.");
    new 
query[200];
    
format(query,sizeof(query),"SELECT * FROM accounts WHERE Faction='%i'",Player[playerid][Faction]);
    
mysql_tquery(connection,query,"foff","d",playerid);
    return 
1;
}
/* ============================================================================= */
forward foff(playerid);
public 
foff(playerid)
{
    new 
name[35];
    for(new 
i=0i<cache_get_row_count(); i++)
    {
        
cache_get_field_content(i,"Username",name);
        if(
IsPlayerConnected(GetPlayerID(name))) return 1;
        
SendClientMessage(playerid,-1,sprintf("%i",i));
    }
    return 
1;
}
/* ============================================================================= */
stock GetPlayerID(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;
}
/* ============================================================================= */ 
So, nothing gets send to the chat (sendclientmessage doesn't work.)
Reply


Messages In This Thread
Issue with IsPlayerConnected and GetPlayerID - by justjamie - 09.11.2016, 11:04
Re: Issue with IsPlayerConnected and GetPlayerID - by Lloyde - 09.11.2016, 12:28
Re: Issue with IsPlayerConnected and GetPlayerID - by Konstantinos - 09.11.2016, 12:39

Forum Jump:


Users browsing this thread: 2 Guest(s)