I made a /tempban system that bans a player based on IP or account for a duration of time. How do I run something that automatically changes the ban status to 0 in the database after the ban expires?
This is the function that checks for ban:
This is the callback function
This is the function that checks for ban:
Code:
public checkaccban(playerid)
{
new query[128], pIpAddress[128], pName[128];
GetPlayerName(playerid, pName, sizeof(pName));
mysql_format(g_SQL, query, sizeof(query), "SELECT * FROM `accbans` WHERE `pName` = '%e' AND pBanned = 1", pName, pIpAddress);
mysql_tquery(g_SQL, query, "bancheckcb", "i", playerid);
return 1;
}
This is the callback function
Code:
public bancheckcb(playerid)
{
new rows, dest;
cache_get_row_count(rows);
if(rows > 0)
{
cache_get_value_name_int(0, "bExpiration", dest);
dest = (dest - gettime())/3600;
if(dest > 0)
{
new string[128];
format(string, sizeof(string), "You are banned from this server. Hours left: %d", dest);
SendClientMessage(playerid, COLOR_RED, string);
SetTimerEx("DelayedKick", 1000, false, "i", playerid);
}
}
return 1;
}