mysql_ban system is not working
#1

why this is not working fully i mean its not detecting if player is banned and also /uban and /playerbans both not working

pawn Код:
CMD:ban(playerid, params[]) //ban a player
    {
            if(pInfo[playerid][Admin] >= 4)
            {
                    new targetid, reason[100];
                    if(sscanf(params,"ds[100]", targetid, reason)) return SendClientMessage(playerid, C_WHITE,"USAGE: /ban [playerid][reason]");
                    if(!IsPlayerConnected(playerid) && targetid != INVALID_PLAYER_ID) return SendClientMessage(playerid, C_RED,"SERVER: Player is not connected!");
                new bquery[200], IPm[16];
                GetPlayerIp(targetid, IPm, 16);
                mysql_format(mysql ,bquery, sizeof(bquery),"INSERT INTO bandata(admin, player, reason, IP, banned) VALUES('%s', '%s', '%s','%s', 1)", GetName(playerid),GetName(targetid), reason, IPm);
                mysql_tquery(mysql, bquery, "", "");
                new string[256];
                format(string, sizeof(string),"%s (ID:%d) has been banned by Admin %s (ID:%d) for %s", GetName(targetid), targetid, GetName(playerid), playerid, reason);
                SendClientMessageToAll(C_RED, string);
                PlaySoundForAll(1140);
                Kick(playerid);
     
            }
            else return SendClientMessage(playerid, C_RED,"You are not authorized to use this command!");
            return 1;
    }
     
CMD:unban(playerid, params[]) //unban a player
    {
                    if(pInfo[playerid][Admin] >= 4)
                    {
                            new target[50];
                            if(sscanf(params,"s[50]", target)) return SendClientMessage(playerid, C_RED,"USAGE: /unban [player name]");
                            new query[200];
                            new rows, fields; //a variable that will be used to retrieve rows and fields in the database.
                    cache_get_data(rows, fields, mysql);//let's get the rows and fields from the database.
                            format(query, sizeof(query),"SELECT * FROM `bandata` WHERE `player`='%s' AND `banned`=1 LIMIT 1", target);
                            mysql_tquery(mysql, query, "", "");
                            if(rows) //if there is row
                            {
                                    new uquery[200];
                                    format(uquery, sizeof(uquery),"DELETE FROM `bandata` WHERE player='%s'", target);
                                    mysql_tquery(mysql, uquery, "", "");
     
                                    new string[200];
                                    format(string, sizeof(string),"You have unbanned %s", target);
                                    SendClientMessage(playerid, C_BLUE,string);
                            }
                            else if(!rows)
                            {
                                    new str[128];
                                    format(str, sizeof(str),"[ERROR]: No ban was found on this name %s", target);
                                    SendClientMessage(playerid, C_RED, str);
                            }
                    }
                    else return SendClientMessage(playerid, C_RED,"You are not authorized to use this command!");
                    return 1;
    }
     
CMD:playerbans(playerid, params[])// search for existing bans
    {
            if(pInfo[playerid][Admin] >= 4)
            {
                    new target[50], admin[50], player[50], reason[100], IPm[16];
                    if(sscanf(params,"s[50]", target)) return SendClientMessage(playerid, C_RED,"USAGE: /playerbans [player name]");
                    new query[200];
                    new rows, fields; //a variable that will be used to retrieve rows and fields in the database.
                    cache_get_data(rows, fields, mysql);//let's get the rows and fields from the database.
                    format(query, sizeof(query),"SELECT admin,player,reason,IP FROM `bandata` WHERE `player`='%s' AND `banned`=1 LIMIT 1", target);
                    mysql_tquery(mysql, query, "", "");
                    if(rows)
                    {
     
                    cache_get_field_content(0, "admin",admin, mysql, 24);
                    cache_get_field_content(0, "player", player, mysql, 24);
                    cache_get_field_content(0, "IP", IPm, mysql, 16);
                    cache_get_field_content(0, "reason", reason, mysql, 100);
     
                            new string[128];
                            format(string, sizeof(string),"Admin: %s  | Player:%s | Reason:%s | IP:%s " , admin, player, reason, IPm);
                            SendClientMessage(playerid, C_RED, string);
                    }
                    if(!rows)
                    {
                                    SendClientMessage(playerid, C_RED,"SERVER: No ban found on this name!");
                    }
            }
            else return SendClientMessage(playerid, C_RED,"You are not authorized to use this command!");
            return 1;
    }
     
stock MySQL_BanCheck(playerid)
    {
            new query[200], admin[50], player[50], IPm[16], string1[100];
            new rows, fields; //a variable that will be used to retrieve rows and fields in the database.
            cache_get_data(rows, fields, mysql);//let's get the rows and fields from the database.
            GetPlayerIp(playerid, IPm, 16);
            format(query, sizeof(query),"SELECT * FROM `bandata` WHERE(`player`='%s' OR `IP`='%s') AND `banned`=1 LIMIT 1", escpname(playerid), IPm);
            mysql_tquery(mysql, query, "", "");
            if(rows)
            {
     
             cache_get_field_content(0, "admin",admin, mysql, 24);
             cache_get_field_content(0, "player", player, mysql, 24);
             cache_get_field_content(0, "IP", IPm, mysql, 16);
             cache_get_field_content(0, "reason", string1, mysql, 100);
     
     
                     new string[50], str[50], str1[100], str3[50];
                     format(string, sizeof(string),"Admin: %s", admin);
                     format(str, sizeof(str),"Player: %s", player);
                     format(str1, sizeof(str1),"Reason: %s", string1);
                     format(str3, sizeof(str3), "IP: %s", IPm);
                     SendClientMessage(playerid, C_RED,"You are banned from this server!");
                     SendClientMessage(playerid, C_RED,"___________________");
                     SendClientMessage(playerid, C_RED, str);
                     SendClientMessage(playerid, C_RED, string);
                     SendClientMessage(playerid, C_RED, str3);
                     SendClientMessage(playerid, C_RED, str1);
                     SendClientMessage(playerid, C_RED,"___________________");
                     SendClientMessage(playerid, C_RED, "If you think that this BAN was a mistake, then post a screenshot(using F8) on our website");
                     SendClientMessage(playerid, C_RED, "www.realone.site11.com");
                     Kick(playerid);
            }
            return 1;
    }
     
    stock escpname(playerid)
    {
            new escname[24], Pname[24];
            GetPlayerName(playerid, Pname, 24);
            mysql_real_escape_string(Pname, escname);
            return escname;
    }
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)