28.10.2016, 09:14
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)).
I think it's good now.
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(playerid, params[])
{
if(!IsAllowed(playerid, 3)) return NoAuth(playerid);
new playerb;
if(sscanf(params, "u", playerb)) return SendClientMessage(playerid, COLOR_WHITE, "USAGE: /checkalts [playerid]");
if(playerb == INVALID_PLAYER_ID) return SendClientMessage(playerid, COLOR_WHITE, "Invalid ID.");
if(IsImmune(playerid, playerb)) return NotImmune(playerid);
new query[128], Cache:result, tempname[24], tempdate[12];
mysql_format(mysql, query, sizeof(query), "SELECT `Username`, `Score`, `Registration` FROM `Users` WHERE `IP` = '%s' ORDER BY `UserID`", RPIP(playerb));
result = mysql_query(mysql, query);
new rows = cache_num_rows();
format(query, sizeof(query), "Active & Registered accounts on %s.", RPIP(playerb));
SendClientMessage(playerid, COLOR_REPORT, query);
if(rows)
{
for(new i; i < rows; i++)
{
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(query, sizeof(query), "Username: %s || Registration Date: %s || Score: %d", tempname, tempdate, cache_get_field_content_int(i, "Score"));
}
SendClientMessage(playerid, COLOR_RED, query);
}
cache_delete(result);
return 1;
}
