mysql_format(database, query, sizeof(query), "SELECT * FROM `bans` WHERE `ip` = '%e'", uData[target][pip]);
mysql_tquery(database, query, "BanCheck", "i", playerid);
function:BanCheck(playerid)
{
new
rows, fields, ip[16], preason[20], adm[MAX_PLAYER_NAME], string[128], pname[MAX_PLAYER_NAME], bid, type, timeleft;
cache_get_data(rows, fields, database);
if(rows > 0)
{
for(new i = 0; i < rows; i++)
{
bid = cache_get_field_content_int(0, "id");
cache_get_field_content(0, "name", pname, database, MAX_PLAYER_NAME);
cache_get_field_content(0, "ip", ip, database, 16);
cache_get_field_content(0, "admin", adm, database, MAX_PLAYER_NAME);
cache_get_field_content(0, "reason", preason, database, 20);
type = cache_get_field_content_int(0, "btype");
timeleft = cache_get_field_content_int(0, "utime");
switch(type)
{
case 1: format(string, sizeof(string), "IP ban match found. BanID: %d Name: %s Reason: %s Admin: %s Type: Permanent.", bid, pname, preason, adm);
case 2:
{
new hours = floatround((timeleft - gettime()) / 60 / 60, floatround_round);
new minutes = floatround((timeleft - gettime()) / 60 % 60, floatround_round);
new seconds = (timeleft - gettime()) % 60;
format(string, sizeof(string), "IP ban match found. BanID: %d Name: %s Reason: %s Admin: %s Type: Temporary Time left: %d hour(s) %d minute(s) %d second(s).", bid, pname, preason, adm, hours, minutes, seconds);
}
}
SendClientMessage(playerid, COL_ADMIN, string);
}
return 1;
}
else SendClientMessage(playerid, COL_ADMIN, "No ban info found.");
return 1;
}
IP ban match found. BanID: 1 Name: TEST Reason: test Admin: TEST Type: Temporary Time left: 4 hour(s) 6 minute(s) 51 second(s). IP ban match found. BanID: 1 Name: TEST Reason: test Admin: TEST Type: Temporary Time left: 4 hour(s) 6 minute(s) 51 second(s).
IP ban match found. BanID: 1 Name: TEST Reason: test Admin: TEST Type: Temporary Time left: 4 hour(s) 6 minute(s) 51 second(s). IP ban match found. BanID: 2 Name: TEST_TEST Reason: test2 Admin: TEST Type: Temporary Time left: 4 hour(s) 6 minute(s) 51 second(s).
That's because you always fetch row 0. Replace that with the loop counter (i).
|