if(cache_get_field_content(0, "UnbanTime", bSt[3]) < CURRENT_TIMESTAMP()) { format(query, sizeof(query), "DELETE FROM `bans` WHERE `Name` = '%s'", GetName(playerid)), mysql_tquery(MySQLCon, query, "", ""); return 1; }
error 017: undefined symbol "CURRENT_TIMESTAMP"
if(cache_get_field_content(0, "UnbanTime", bSt[3]) < gettime())
"UnbanTime" something like: 2016-02-03 04:29:58
GetTime return: Hour, Minute, Second. |
You should use unix timestamps instead of dealing with plain dates. It will also be a lot easier to compare them in the future.
Here is a good example of what you're probably trying to achieve. https://sampforum.blast.hk/showthread.php?tid=269126 |
//Where you fill in the value of "UnBanTime":
UnBanTime = gettime()+60*60*24*2 //2 days
if(cache_get_field_content_int(0,"UnbanTime",MySQLCon) < gettime())
{
format(query,sizeof query,"DELETE FROM `bans` WHERE `Name`='%s'",GetName(playerid));
mysql_tquery(MySQLCon,query,"","");
return 1;
}
I would change your system to this:
PHP код:
PHP код:
|
mysql_pquery( MySQLCon, query );
stock jUnbanName(name[], bool:expired = false)
{
if(strlen(name) > MAX_PLAYER_NAME) return 0;
mysql_real_escape_string(name, name);
if(expired == false) format(jQuery, MAX_QUERY_LENGTH, "DELETE FROM `"#J_TABLE"` WHERE user_banned = '%s' AND NOW() <= DATE_ADD(ban_timestamp, INTERVAL ban_time MINUTE)", name);
else format(jQuery, MAX_QUERY_LENGTH, "DELETE FROM `"#J_TABLE"` WHERE user_banned = '%s'", name);
mysql_query(jQuery, QUERY_UNBAN_NAME, 0, jban_connection);
return 1;
}
new unban_date;
// When loading the information
unban_date = cache_get_field_content_int(0,"UnbanTime" );
if ( unban_date < gettime() )
{
format(query,sizeof query,"DELETE FROM `bans` WHERE `Name`='%e'",GetName(playerid));
mysql_pquery( MySQLCon,query );
return 1;
}