Is there a smarter way to do this ?
#2

Check if the player is INVALID_PLAYER_ID instead of checking if the player is not connected.
Don't use SendClientMessage inside the loop.
You don't need to use sizeof in the cache_get.., It basically get the sizeof the destination. ( max_len = sizeof(destination)).

PHP код:
CMD:checkalts(playeridparams[])
{
    if(!
IsAllowed(playerid3)) return NoAuth(playerid);
    new 
playerb;
    if(
sscanf(params"u"playerb)) return SendClientMessage(playeridCOLOR_WHITE"USAGE: /checkalts [playerid]");
    if(
playerb == INVALID_PLAYER_ID) return SendClientMessage(playeridCOLOR_WHITE"Invalid ID.");
    if(
IsImmune(playeridplayerb)) return NotImmune(playerid);
    new 
query[128], Cache:resulttempname[24], tempdate[12];
    
mysql_format(mysqlquerysizeof(query), "SELECT `Username`, `Score`, `Registration` FROM `Users` WHERE `IP` = '%s' ORDER BY `UserID`"RPIP(playerb));
    
result mysql_query(mysqlquery);
    new 
rows cache_num_rows();
    
format(querysizeof(query), "Active & Registered accounts on %s."RPIP(playerb));
    
SendClientMessage(playeridCOLOR_REPORTquery);
    if(
rows)
    {
        for(new 
irowsi++)
        {
            
cache_get_field_content(i"Username"tempname); // use the connection handle if you have option DUPLICATE_CONNECTION
            
cache_get_field_content(i"Registration"tempdate);  // use the connection handle if you have option DUPLICATE_CONNECTION
            
format(querysizeof(query), "Username: %s || Registration Date: %s || Score: %d"tempnametempdatecache_get_field_content_int(i"Score"));
        }
        
SendClientMessage(playeridCOLOR_REDquery);
    }
    
cache_delete(result);
    return 
1;

I think it's good now.
Reply


Messages In This Thread
Is there a smarter way to do this ? - by NeXoR - 28.10.2016, 08:54
Re: Is there a smarter way to do this ? - by oMa37 - 28.10.2016, 09:14
Re: Is there a smarter way to do this ? - by NeXoR - 28.10.2016, 09:22
Re: Is there a smarter way to do this ? - by oMa37 - 28.10.2016, 10:17
Re: Is there a smarter way to do this ? - by Threshold - 28.10.2016, 11:13
Re: Is there a smarter way to do this ? - by oMa37 - 28.10.2016, 11:21
Re: Is there a smarter way to do this ? - by AndySedeyn - 28.10.2016, 11:32
Re: Is there a smarter way to do this ? - by Threshold - 28.10.2016, 13:14

Forum Jump:


Users browsing this thread: 2 Guest(s)