Quote:
Originally Posted by KyleSmith
pawn Код:
public OnPlayerConnect(playerid) { mysql_format(MySQLConnection, MySQL, "SELECT Date FROM bans WHERE IP = '%s' AND Date > UNIX_TIMESTAMP()", plrIP); mysql_function_query(MySQLConnection, MySQL, true, "CheckBanned", "is", playerid, plrIP); return 1; }
stock ReturnNull() { return 1; }
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); cache_get_row(1, 0, data2); new expire = strval(data); new expirer = strval(data2); printf("Extracted unban time %d from string '%s'", expire, data);
if(expirer == 1) { printf("Player is NOT Banned - Query Complete"); mysql_format(MySQLConnection, MySQL, "DELETE FROM bans WHERE Name = '%s' LIMIT 1", ip); mysql_function_query(MySQLConnection, MySQL, false, "ReturnNull", "i", INVALID_PLAYER_ID); } 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; }
|
1. Your query returns
ONE FIELD (SELECT
Date FROM ...), not two (you're trying to get 2 fields
) I don't understand why you added an extra field?
2. Your mysql_function_query makes the plugin execute public CheckBanned, not public OnBanQueryFinish when done. Also take into consideration that in OnPlayerConnect, in the code that you posted, plrIP is not defined.
3. What are you trying to do with the expirer variable?
4. ReturnNull is a stock function, not a public callback. Further on, it is USELESS, since you can also do:
pawn Код:
mysql_function_query(MySQLConnection, MySQL, false, "", "");
... to send a simple UPDATE query.
5. The DontShow does not have to be an array. It can be a simple variable due to the fact that two things never happen at once.
pawn Код:
DontShow = true;
public OnPlayerDisconnect(playerid, reason)
{
if(!DontShow)
{
// Send disconnect message
}
else DontShow = false;
}
Please, dude, try to learn a bit about how MySQL queries work before making such assumptions.