If player is banned
#1

<fixed>
Reply
#2

pawn Код:
public OnPlayerSpawn(playerid)
{
    if(Player[playerid][Banned] == 1)
    {
        Kick(playerid)
        SendClientMessage(playerid,-1,"You are banned have a good life :P.");
    }
    return 1;
}
Reply
#3

<fixed>
Reply
#4

You need to read the user file and check if he is banned or not, what include are you using to read and write .ini files?
Reply
#5

<fixed>
Reply
#6

Well you can either load it into the var when the player logs in or us, y_ini, dini or DJson.
Reply
#7

Honestly, I've never read a file before the players logs in. Can someone give it a try? So I can learn something new?
Reply
#8

pawn Код:
public OnPlayerConnect(playerid)
{
    new file[128], pName[MAX_PLAYER_NAME];
    GetPlayerName(playerid, pName, MAX_PLAYER_NAME);
    format(file, sizeof(file), "Users/%s.ini", pName);
    if(!fexist(file))
    {
        ShowPlayerDialog(playerid, 1, DIALOG_STYLE_INPUT, "Please Register", "Enter Your Password Below", "Register", "Cancel");
    }
    else
    {
        Player[playerid][Banned] = dini_Int(file, "Banned");
        if(Player[playerid][Banned] == 0)
        {
            ShowPlayerDialog(playerid, 2, DIALOG_STYLE_INPUT, "Please Login", "Enter Your Password Below", "Login", "Cancel");
        }
        else
        {
            SendClientMessage(playerid, RED, "You are banned gtfo");
            Kick(playerid);
         }
    }
    return 1;
}
try this.
Reply
#9

pawn Код:
new file[32],Name[32];//Variable declaration, don't declare it here, just make a new one at the top of the script, this is just for the purpose of helping you.
        GetPlayerName(playerid,Name,sizeof(Name));// Getting the player's name.
        format(file,sizeof(file),"Accounts/%s.ini",Name);//You can see where I have 'Accounts' change that to the name of the folder in which the files are stored.
        PlayerData[playerid][Banned] = dini_Int(file, "Banned");//This is storing what's in the file, into the Player[playerid][Banned] variable.
I explained in that above.

EDIT: You need to use the edit button and put the Banned check under OnPlayerSpawn.
Reply
#10

Why checking if player is banned Must be under OnPlayerSpawn?
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)