I get kicked every I connect in game
#1

Even if im not banned on the server i get automatic kick and the dialog shows. anyone can see any problem on my code?

OnPlayerConnect Callback
pawn Код:
public OnPlayerConnect(playerid)
{
    IsPlayerBanned(playerid); //IsPlayerBanned called and checking if playerid is banned
    return 1;
}
IsPlayerBanned stock
pawn Код:
stock IsPlayerBanned(playerid)
{
    new
        Query[128],
        reason[64],
        Name[24],
        Admin[24],
        IpAdress[16],
        fetchVal[128],
        string[256]
     ;
    format(Query, sizeof(Query), "SELECT * FROM `bans` WHERE (`Username` = '%s' OR `IpAdress` = '%s') AND `Banned` = '1' LIMIT 1", PlayerName(playerid), GetIP(playerid)); //check if Banned = 1 else continue to log in
    mysql_query(Query);
    //
    mysql_store_result();
    if(mysql_num_rows() != 0)
    {
        while(mysql_fetch_row_format(Query, "|"))
        {
            mysql_fetch_field_row(fetchVal, "Username"); format(Name, sizeof(Name), fetchVal);
            mysql_fetch_field_row(fetchVal, "Reason"); format(reason, sizeof(reason), fetchVal);
            mysql_fetch_field_row(fetchVal, "BannedBy"); format(Admin, sizeof(Admin), fetchVal);
            mysql_fetch_field_row(fetchVal, "IpAdress"); format(IpAdress, sizeof(IpAdress), fetchVal);
        }
    }
    mysql_free_result();
    //
    format(string,sizeof(string),"Username: %s\nIpAdress: %s\nStatus: Banned\nThe Reason you've been banned: %s\nBanned by Admin: %s",Name,IpAdress,reason,Admin);
    ShowPlayerDialog(playerid, INFO, DIALOG_STYLE_MSGBOX,"Banned | Don't Ban Evade",string,"Accept","Decline");
    SetTimerEx("KickPlayer",1000,false,"i",playerid);
    IsKicking[playerid] = true;
    return 1;
}
Reply
#2

pawn Код:
new
        Query[128],
        reason[64],
        Name[24],
        Admin[24],
        IpAdress[16],
        fetchVal[128],
        string[256]
     ;
    format(Query, sizeof(Query), "SELECT * FROM `bans` WHERE (`Username` = '%s' OR `IpAdress` = '%s') AND `Banned` = '1' LIMIT 1", PlayerName(playerid), GetIP(playerid)); //check if Banned = 1 else continue to log in
    mysql_query(Query);
    //
    mysql_store_result();
    if(mysql_num_rows() > 0)
    {
        while(mysql_fetch_row_format(Query, "|"))
        {
            mysql_fetch_field_row(fetchVal, "Username"); format(Name, sizeof(Name), fetchVal);
            mysql_fetch_field_row(fetchVal, "Reason"); format(reason, sizeof(reason), fetchVal);
            mysql_fetch_field_row(fetchVal, "BannedBy"); format(Admin, sizeof(Admin), fetchVal);
            mysql_fetch_field_row(fetchVal, "IpAdress"); format(IpAdress, sizeof(IpAdress), fetchVal);
        }
        format(string,sizeof(string),"Username: %s\nIpAdress: %s\nStatus: Banned\nThe Reason you've been banned: %s\nBanned by Admin: %s",Name,IpAdress,reason,Admin);
        ShowPlayerDialog(playerid, INFO, DIALOG_STYLE_MSGBOX,"Banned | Don't Ban Evade",string,"Accept","Decline");
        SetTimerEx("KickPlayer",1000,false,"i",playerid);
        IsKicking[playerid] = true;
    }
    mysql_free_result();
    return 1;
thats whats wrong, you were executing the kick after the query finished.
Reply
#3

Thanks ill be testing this when i arrive from school.
Reply
#4

Quote:
Originally Posted by kamzaf
Посмотреть сообщение
pawn Код:
new
        Query[128],
        reason[64],
        Name[24],
        Admin[24],
        IpAdress[16],
        fetchVal[128],
        string[256]
     ;
    format(Query, sizeof(Query), "SELECT * FROM `bans` WHERE (`Username` = '%s' OR `IpAdress` = '%s') AND `Banned` = '1' LIMIT 1", PlayerName(playerid), GetIP(playerid)); //check if Banned = 1 else continue to log in
    mysql_query(Query);
    //
    mysql_store_result();
    if(mysql_num_rows() > 0)
    {
        while(mysql_fetch_row_format(Query, "|"))
        {
            mysql_fetch_field_row(fetchVal, "Username"); format(Name, sizeof(Name), fetchVal);
            mysql_fetch_field_row(fetchVal, "Reason"); format(reason, sizeof(reason), fetchVal);
            mysql_fetch_field_row(fetchVal, "BannedBy"); format(Admin, sizeof(Admin), fetchVal);
            mysql_fetch_field_row(fetchVal, "IpAdress"); format(IpAdress, sizeof(IpAdress), fetchVal);
        }
        format(string,sizeof(string),"Username: %s\nIpAdress: %s\nStatus: Banned\nThe Reason you've been banned: %s\nBanned by Admin: %s",Name,IpAdress,reason,Admin);
        ShowPlayerDialog(playerid, INFO, DIALOG_STYLE_MSGBOX,"Banned | Don't Ban Evade",string,"Accept","Decline");
        SetTimerEx("KickPlayer",1000,false,"i",playerid);
        IsKicking[playerid] = true;
    }
    mysql_free_result();
    return 1;
thats whats wrong, you were executing the kick after the query finished.
As given in this post, this will work. PDS, this WILL work, you sent me a skype msg to help, and this guy has already made it for you.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)