19.02.2017, 19:07
Hello.Im using this ban system,its based on mySQL.It works good when it come to players name,but it wont detect banned IP.So,if player come with a diferent name it wont detect that it's IP are banned.
Code:
Something must be wrong on THREAD_BAN_CHECK_IP. Anyone can help me please?Thanks
Code:
Код:
OnPlayerConnect CheckDatabase(playerid);
Код:
CheckDatabase(playerid) { new q[200]; new playername[24]; GetPlayerName(playerid,playername,sizeof(playername)); format(q, 200, "SELECT * FROM bans WHERE name = '%s' ORDER BY id DESC LIMIT 1", playername); mysql_query(q,THREAD_BAN_CHECK_NAME,playerid); new ip[16]; GetPlayerIp(playerid, ip, sizeof(ip)); format(q, 200, "SELECT * FROM bans WHERE ip = '%s' ORDER BY id DESC LIMIT 1", ip); mysql_query(q,THREAD_BAN_CHECK_IP,playerid); }
Код:
Onqueryfinish: public OnQueryFinish(query[], resultid, extraid, connectionHandle) { new string2[164]; switch(resultid) { case THREAD_BAN_CHECK_NAME: { mysql_store_result(); if(mysql_num_rows() == 1) { if(mysql_retrieve_row()) { new banid, expiry, reason[64], admin[32], tmp[64]; GET_INT(banid, "id"); //GET_INT(bantime, "issue_time"); //GET_INT(length, "ban_time"); GET_INT(expiry, "expiry_time"); GET_STR(reason, "reason"); GET_STR(admin, "admin"); new curtime = gettime(); if(curtime < expiry) { new ip[32]; GetPlayerIp(extraid, ip, 32); format(ToBeKickedString[extraid], 512, "You have been banned from this server for the following reason:\n\n%s\nIf you believe this is a bug, simply relog and rejoin the server.\nIf you think that this ban was in error, please go to www.panel-la.tk and appeal it.\nYou will need the following info to appeal the ban:\n\nBan ID: %d\nAdmin that banned you: %s\nReason of the ban: %s\nBan expiration: %s", reason, banid, admin, reason, expiry); format(string2, sizeof(string2), "{AA3333}AdmWarning{FFFF00}: %s (IP:%s) tried to login whilst banned and has been auto-banned.", GetPlayerNameEx( extraid ), ip); ABroadCast(COLOR_YELLOW, string2, 2); ToBeKicked[extraid] = 1; } } } mysql_free_result(); } case THREAD_BAN_CHECK_IP: { mysql_store_result(); if(mysql_num_rows() == 1) { if(mysql_retrieve_row()) { new banid, expiry, reason[64], admin[32], tmp[64], dbip[16]; GET_INT(banid, "id"); //GET_INT(bantime, "issue_time"); //GET_INT(length, "ban_time"); GET_INT(expiry, "expiry_time"); GET_STR(reason, "reason"); GET_STR(admin, "admin"); GET_STR(dbip, "ip"); new curtime = gettime(); new ip[16]; GetPlayerIp(extraid,ip,sizeof(ip)); if(strcmp(ip, dbip) == 0 && curtime < expiry) { format(ToBeKickedString[extraid], 512, "Your IP has been banned from this server for the following reason:\n\n%s\nIf you believe this is a bug, simply relog and rejoin the server.\n\nIf you think that this ban was in error, please go to www.panel-la.tk and appeal it.\nYou will need the following info to appeal the ban:\n\nBan ID: %d\nAdmin that banned you: %s\nReason of the ban: %s", reason, banid, admin, reason); ToBeKicked[extraid] = 1; } } } mysql_free_result(); }