11.06.2012, 11:40
Quote:
Thanks for all of you giving some advice. I've changed a bit of AndreT's code a little bit and added a field on. Would this work?
Also that query does work with the selecting the date as it tells me if the Date they will be unbanned has passed or not returning 1 for passed or 0 for not passed. http://pastie.org/private/tzztcvzdyjg27smiyjuvw |
pawn Код:
mysql_function_query(MySQLConnection, MySQL, true, "CheckBanned", "is", playerid, plrIP);
pawn Код:
public OnBanQueryFinish(playerid, ip[])
pawn Код:
mysql_function_query(MySQLConnection, MySQL, true, "OnBanQueryFinish", "is", playerid, plrIP);
pawn Код:
forward OnBanQueryFinish(playerid, ip[]);
public OnBanQueryFinish(playerid, ip[])
{
new rows, fields;
cache_get_data(rows, fields);
if(rows)
{
new data[12], data2[1];
cache_get_row(0, 0, data); // Your only selecting date, so how come you actually
cache_get_row(1, 0, data2); // get two rows of data? Sorry maybe I am just wrong but shouldnt
new expire = strval(data); // you only have one result? You expect a date to return
new expirer = strval(data2);
printf("Extracted unban time %d from string '%s'", expire, data);
if(expirer == 1)
{
printf("Player is NOT Banned - Query Complete"); // Why is the player not banned if you get a 2nd result?
mysql_format(MySQLConnection, MySQL, "DELETE FROM bans WHERE Name = '%s' LIMIT 1", ip);
mysql_function_query(MySQLConnection, MySQL, false, "ReturnNull", "i", INVALID_PLAYER_ID); // You don't need to use "ReturnNull", you can simply use ""
}
else if(expirer == 0)
{
printf("Player is Banned - Query Complete");
SendFormatMessage(playerid, COLOR_DEFAULT, "You are banned from this server untill %s", dater(expirer, 3));
Kick(playerid);
DontShow[playerid] = 1;
return 1;
}
}
return 1;
}