globalbans: use expired vcolumn

This commit is contained in:
Jackzie 2021-06-03 19:10:03 -05:00
parent 7678f763a7
commit bb1226d30f
No known key found for this signature in database
GPG key ID: 1E834FE36520537A
2 changed files with 7 additions and 9 deletions

Binary file not shown.

View file

@ -61,7 +61,7 @@ public void OnClientAuthorized(int client, const char[] auth) {
if(!StrEqual(auth, "BOT", true)) { if(!StrEqual(auth, "BOT", true)) {
char query[256], ip[32]; char query[256], ip[32];
GetClientIP(client, ip, sizeof(ip)); GetClientIP(client, ip, sizeof(ip));
Format(query, sizeof(query), "SELECT `reason`, `steamid`, `expires` FROM `bans` WHERE `steamid` = '%s' OR ip = '?'", auth, ip); Format(query, sizeof(query), "SELECT `reason`, `steamid`, `expired` FROM `bans` WHERE `steamid` = '%s' OR ip = '?'", auth, ip);
g_db.Query(DB_OnConnectCheck, query, GetClientUserId(client), DBPrio_High); g_db.Query(DB_OnConnectCheck, query, GetClientUserId(client), DBPrio_High);
} }
} }
@ -154,18 +154,16 @@ public void DB_OnConnectCheck(Database db, DBResultSet results, const char[] err
//No failure, check the data. //No failure, check the data.
if(results.RowCount > 0 && client) { if(results.RowCount > 0 && client) {
results.FetchRow(); results.FetchRow();
char reason[128], expiresDate[64], steamid[32]; char reason[128], steamid[64];
DBResult result; DBResult reasonResult;
results.FetchString(1, steamid, sizeof(steamid)); results.FetchString(1, steamid, sizeof(steamid));
bool expired = results.FetchInt(2) == 1;
if(results.IsFieldNull(2)) { if(results.IsFieldNull(2)) {
DeleteBan(steamid); DeleteBan(steamid);
}else{ }else{
results.FetchString(0, reason, sizeof(reason), result); results.FetchString(0, reason, sizeof(reason), reasonResult);
results.FetchString(2, expiresDate, sizeof(expiresDate)); if(!expired) {
if(reasonResult == DBVal_Data)
int expires = StringToInt(expiresDate);
if(expires <= GetTime() && expires > 0) {
if(result == DBVal_Data)
KickClient(client, "You have been banned: %s", reason); KickClient(client, "You have been banned: %s", reason);
else else
KickClient(client, "You have been banned from this server."); KickClient(client, "You have been banned from this server.");