Automatic unban after some time - Printable Version
+- SA-MP Forums Archive (
https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (
https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (
https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: Automatic unban after some time (
/showthread.php?tid=648974)
Automatic unban after some time -
JaskaranSingh - 31.01.2018
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:
Код:
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
Код:
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;
}