Quote:
Originally Posted by Mencent
I would change your system to this:
PHP код:
//Where you fill in the value of "UnBanTime":
UnBanTime = gettime()+60*60*24*2 //2 days
UnBanTime has to be an integer. And then like this:
PHP код:
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;
}
|
First of all UnbanTime isn't a variable in his code, it's a row name in his table.
You can also use pquery, if you're running the latest version of BlueG's MySQL plugin.
pawn Код:
mysql_pquery( MySQLCon, query );
Also, I already gave you an example of how you should do it, just look at jBan, it has everything that you need.
Here is a link to get it
http://www.jatochnietdan.com/project/sa-mp/jban
pawn Код:
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;
}
It uses a bit older version of MySQL, however you could just easily edit it.
Another method would be when you load the UnBanTime from SQL, assuming you're using unix timestamps,
you could do this.
pawn Код:
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;
}