Banned Variable
#1

Alright guys i've got a little question i've made a banned variable for my server so if a players gets banned the variable in his userfile will turn 1 and he won't be able to connect.
But i can only seem to add this in Dialog_LOGIN when i try to add it on the onplayerconnect it simpely doesn't work.



pawn Код:
case DIALOG_LOGIN: {
            if(!response) return Kick(playerid);
            if(response) {
                new password[23],password2[23],rank[60];
                if(sscanf(inputtext, "s[23]", password)) return ShowPlayerDialog(playerid, DIALOG_LOGIN, DIALOG_STYLE_INPUT,"Login","You have entered an incorrect password.\nType your password below to login.","Login","Quit");
                new file[64],PlayerName[24];
                GetPlayerName(playerid, PlayerName, sizeof PlayerName);
                format(file, sizeof file, "Admin/%s.ini", PlayerName);
                if(!fexist(file)) return ShowPlayerDialog(playerid, DIALOG_REGISTER, DIALOG_STYLE_INPUT, "Register Below", "Enter A Password To Register And Play!", "Register", "Quit");
                INI_Open(file);
                INI_ReadString(password2, "Password");
                if(strcmp(password, password2) != 0) return ShowPlayerDialog(playerid, DIALOG_LOGIN, DIALOG_STYLE_INPUT,"Login","You have entered an incorrect password.\nType your password below to login.","Login","Quit");
                PInfo[playerid][Rank] = INI_ReadInt("Rank");
                PInfo[playerid][Level] = INI_ReadInt("Level");
                PInfo[playerid][Operator] = INI_ReadInt("Operator");
                PInfo[playerid][Banned] = INI_ReadInt("Banned");
                PInfo[playerid][Kills] = INI_ReadInt("Kills");
                PInfo[playerid][Deaths] = INI_ReadInt("Deaths");
                PInfo[playerid][Score] = INI_ReadInt("Score");
                PInfo[playerid][Money] = INI_ReadInt("Money");
                if(PInfo[playerid][Banned] != 0)
                {
                SendClientMessage(playerid, 0xFF0000FF, "ERROR: This account is banned if this is a mistake apply at our forums");
                SetTimerEx("KickPlayer",500,0,"d", playerid);
                return 1;
                }
                INI_Close();
                SendClientMessage(playerid,-1,"You have been successfully logged in!");
                format(rank, sizeof(rank), "Your rank is %s", GetRankName(playerid));
                SendClientMessage(playerid, -1, rank);
                PInfo[playerid][Logged] = 1;
                SetPlayerScore(playerid, PInfo[playerid][Score]);
                GivePlayerMoney(playerid, PInfo[playerid][Money]);
                return 1;
            }
        }
pawn Код:
public OnPlayerConnect(playerid)
{
    SendClientMessage(playerid,red,"Welcome to Priority WarTorn! Dont forget to check /updates ! ");
    SendClientMessage(playerid,GREEN,"Remember to /buyrank to buy a rank ");
    new name[MAX_PLAYER_NAME], string[24+MAX_PLAYER_NAME];
    GetPlayerName(playerid, name, sizeof(name));
    format(string, sizeof(string), "** %s has joined Priority WarTorn", name);
    IsOnAdminDuty[playerid] = false;
    PInfo[playerid][Money] = 0;
    PInfo[playerid][Score] = 0;
    PInfo[playerid][Kills] = 0;
    PInfo[playerid][Deaths] = 0;
    PInfo[playerid][Level] = 0;
    PInfo[playerid][Rank] = 0;
    SendClientMessageToAll(-1, string);
    PMEnabled[playerid] = 1;
    IsMuted[playerid] = 0;
    TogglePlayerSpectating(playerid, false);

    new file[64],PlayerName[25];//Creating a variable where we can store the file path, and the variable to store the player's name.
    GetPlayerName(playerid,PlayerName,sizeof PlayerName);//Storing the players name in the PlayerName variable.
    format(file,sizeof file,"Admin/%s.ini",PlayerName);//Storing the file path with the players name.
    if(fexist(file)) {
        ShowPlayerDialog(playerid, DIALOG_LOGIN, DIALOG_STYLE_INPUT, "Login Below", "Enter Your Password To Login!", "Login", "Quit");
    } else {
        ShowPlayerDialog(playerid, DIALOG_REGISTER, DIALOG_STYLE_INPUT, "Register Below", "Enter A Password To Register And Play!", "Register", "Quit");
    }
    return 1;
}
Reply
#2

Are you making sure that the banned variable actually gets saved in the .ini file? I'd recommend you make a new timer for about 1 second and then put the if(PInfo[playerid][Banned] != 0) there because sometimes the files might not be loaded on time.
Reply
#3

As i said it works, but it only works when i put it in the Login Dialog not the onplayerconnect.
Reply
#4

Try this, make sure on your (/ban) command you do have PInfo[playerid][Banned =1;

pawn Код:
case DIALOG_LOGIN:
{
    if(!response) return Kick(playerid);
    if(response)
    {
        new password[23],password2[23],rank[60];
        if(sscanf(inputtext, "s[23]", password)) return ShowPlayerDialog(playerid, DIALOG_LOGIN, DIALOG_STYLE_INPUT,"Login","You have entered an incorrect password.\nType your password below to login.","Login","Quit");

        new file[64],PlayerName[24];
        GetPlayerName(playerid, PlayerName, sizeof PlayerName);
        format(file, sizeof file, "Admin/%s.ini", PlayerName);

        if(!fexist(file)) return ShowPlayerDialog(playerid, DIALOG_REGISTER, DIALOG_STYLE_INPUT, "Register Below", "Enter A Password To Register And Play!", "Register", "Quit");

        INI_Open(file);
        INI_ReadString(password2, "Password");
        if(strcmp(password, password2) != 0) return ShowPlayerDialog(playerid, DIALOG_LOGIN, DIALOG_STYLE_INPUT,"Login","You have entered an incorrect password.\nType your password below to login.","Login","Quit");
        PInfo[playerid][Rank] = INI_ReadInt("Rank");
        PInfo[playerid][Level] = INI_ReadInt("Level");
        PInfo[playerid][Operator] = INI_ReadInt("Operator");
        PInfo[playerid][Banned] = INI_ReadInt("Banned");
        PInfo[playerid][Kills] = INI_ReadInt("Kills");
        PInfo[playerid][Deaths] = INI_ReadInt("Deaths");
        PInfo[playerid][Score] = INI_ReadInt("Score");
        PInfo[playerid][Money] = INI_ReadInt("Money");
        INI_Close();
       
        if(PInfo[playerid][Banned] == 1)
        {
            SendClientMessage(playerid, 0xFF0000FF, "ERROR: This account is banned if this is a mistake apply at our forums");
            SetTimerEx("KickPlayer",500,0,"d", playerid);
        } else {
        SendClientMessage(playerid,-1,"You have been successfully logged in!");
        format(rank, sizeof(rank), "Your rank is %s", GetRankName(playerid));
        SendClientMessage(playerid, -1, rank);
        PInfo[playerid][Logged] = 1;
        SetPlayerScore(playerid, PInfo[playerid][Score]);
        GivePlayerMoney(playerid, PInfo[playerid][Money]);
        }
       
        return 1;
    }
}
Reply
#5

Quote:
Originally Posted by pds2012
Посмотреть сообщение
Try this, make sure on your (/ban) command you do have PInfo[playerid][Banned =1;

pawn Код:
case DIALOG_LOGIN:
{
    if(!response) return Kick(playerid);
    if(response)
    {
        new password[23],password2[23],rank[60];
        if(sscanf(inputtext, "s[23]", password)) return ShowPlayerDialog(playerid, DIALOG_LOGIN, DIALOG_STYLE_INPUT,"Login","You have entered an incorrect password.\nType your password below to login.","Login","Quit");

        new file[64],PlayerName[24];
        GetPlayerName(playerid, PlayerName, sizeof PlayerName);
        format(file, sizeof file, "Admin/%s.ini", PlayerName);
       
        if(!fexist(file)) return ShowPlayerDialog(playerid, DIALOG_REGISTER, DIALOG_STYLE_INPUT, "Register Below", "Enter A Password To Register And Play!", "Register", "Quit");

        INI_Open(file);
        INI_ReadString(password2, "Password");
        if(strcmp(password, password2) != 0) return ShowPlayerDialog(playerid, DIALOG_LOGIN, DIALOG_STYLE_INPUT,"Login","You have entered an incorrect password.\nType your password below to login.","Login","Quit");
        PInfo[playerid][Rank] = INI_ReadInt("Rank");
        PInfo[playerid][Level] = INI_ReadInt("Level");
        PInfo[playerid][Operator] = INI_ReadInt("Operator");
        PInfo[playerid][Banned] = INI_ReadInt("Banned");
        PInfo[playerid][Kills] = INI_ReadInt("Kills");
        PInfo[playerid][Deaths] = INI_ReadInt("Deaths");
        PInfo[playerid][Score] = INI_ReadInt("Score");
        PInfo[playerid][Money] = INI_ReadInt("Money");
        INI_Close();
        SendClientMessage(playerid,-1,"You have been successfully logged in!");
        format(rank, sizeof(rank), "Your rank is %s", GetRankName(playerid));
        SendClientMessage(playerid, -1, rank);
        PInfo[playerid][Logged] = 1;
        SetPlayerScore(playerid, PInfo[playerid][Score]);
        GivePlayerMoney(playerid, PInfo[playerid][Money]);
       
        if(PInfo[playerid][Banned] == 1)
        {
            SendClientMessage(playerid, 0xFF0000FF, "ERROR: This account is banned if this is a mistake apply at our forums");
            SetTimerEx("KickPlayer",500,0,"d", playerid);
        }
       
        return 1;
    }
}
You didn't read my post, i told you i want it on onplayerconnect. Because it only kicks them after they logged in if the variable is 1.
Reply
#6

Then you can't do that, since the variables needs to load, before detecting it.
Reply
#7

It should work when you can check if they're banned on connect.

Would you mind showing us the code you did and it didn't work?
Reply
#8

Quote:
Originally Posted by Konstantinos
Посмотреть сообщение
It should work when you can check if they're banned on connect.

Would you mind showing us the code you did and it didn't work?
His code works but he wants to auto-kick the banned player connects to the server
pawn Код:
public OnPlayerConnect(...)
I guess it's impossible since the variable isn't loaded yet, so obviously the callback won't detect it since the player variable isn't loaded yet.
Reply
#9

Quote:
Originally Posted by pds2012
Посмотреть сообщение
His code works but he wants to auto-kick the banned player connects to the server
pawn Код:
public OnPlayerConnect(...)
I guess it's impossible since the variable isn't loaded yet, so obviously the callback won't detect it since the player variable isn't loaded yet.
Loading the data about whether they're banned or not in OnPlayerConnect and kick them if they are - it works fine like that.
Reply
#10

Quote:
Originally Posted by Konstantinos
Посмотреть сообщение
It should work when you can check if they're banned on connect.

Would you mind showing us the code you did and it didn't work?
pawn Код:
new file[64],PlayerName[25];//Creating a variable where we can store the file path, and the variable to store the player's name.
    GetPlayerName(playerid,PlayerName,sizeof PlayerName);//Storing the players name in the PlayerName variable.
    format(file,sizeof file,"Admin/%s.ini",PlayerName);//Storing the file path with the players name.
    INI_Open(file);
    PInfo[playerid][Banned] = INI_ReadInt("Banned");
    if(PInfo[playerid][Banned] != 0)
    {
    SendClientMessage(playerid, 0xFF0000FF, "ERROR: This account is banned if this is a mistake apply at our forums");
    SetTimerEx("KickPlayer",500,0,"d", playerid);
    return 1;
    }
    INI_Close();
    if(fexist(file)) {
        ShowPlayerDialog(playerid, DIALOG_LOGIN, DIALOG_STYLE_INPUT, "Login Below", "Enter Your Password To Login!", "Login", "Quit");
    } else {
        ShowPlayerDialog(playerid, DIALOG_REGISTER, DIALOG_STYLE_INPUT, "Register Below", "Enter A Password To Register And Play!", "Register", "Quit");
    }
    return 1;
}
I tried that.

EDIT: After testing it again it does work now really weird, thanks anyway
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)