SA-MP Forums Archive
Help with "Ban" Variable (++rep) - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: Help with "Ban" Variable (++rep) (/showthread.php?tid=324455)



Help with "Ban" Variable (++rep) - ServerScripter - 09.03.2012

Hi , i want to set a Ban variable who checks if the Banned =1 kick him from server / else let him connecting so i did that:
pawn Код:
public OnPlayerLogin(playerid, Password[])
{
    if(IsPlayerConnected(playerid)) {
        if(strlen(Password) == 0) return ShowPlayerDialog(playerid, LOGIN, DIALOG_STYLE_PASSWORD, "{00CCFF}Login", "{FFFFFF}Please enter password for login \n\n\n{FF0000}Login is required", "Login", "");
        if(strcmp(dini_Get(file[playerid], "Password"), Password, true) == 0) {
            IsLogged[playerid] = true;
            SendClientMessage(playerid, COLOR_YELLOW, "Welcome Back in Swat 5 Server !");
            GivePlayerMoney(playerid, dini_Int(file[playerid], "Money"));
            SetPlayerScore(playerid, dini_Int(file[playerid], "Score"));
            Vip[playerid] = dini_Int(file[playerid], "Vip");
            AdminLevel[playerid] = dini_Int(file[playerid], "Admin");
            Banned[playerid] = dini_Int(file[playerid], "IGBAN");
        }
        else {
            ShowPlayerDialog(playerid, LOGIN, DIALOG_STYLE_PASSWORD, "{00CCFF}Login", "{FF0000}Incorrect Password{FFFFFF}\nplease try again", "Login", "");
        }
    }
    return 1;
}
i think the problem is here :*
pawn Код:
public OnPlayerConnect(playerid)
{
if(Banned[playerid] == 1)
{
SendClientMessage(playerid, COLOR_ORANGE,"You are banned !");
Kick(playerid);
}
if(Banned[playerid] == 0)
{
    new NAME[100];
    SendClientMessageToAll(0xff0000, NAME);
    printf("OnPlayerConnect(%d)", playerid);
    GetPlayerName(playerid, NAME, 24);
    format(NAME, 100, "  %s [ID:%d] has connected to the server", NAME, playerid);
    SendClientMessageToAll(COLOR_GREY, NAME);
    Vip[playerid] = 0;
    AdminLevel[playerid] = 0;
   
    if(IsPlayerConnected(playerid) && !IsPlayerNPC(playerid)) {
        format(file[playerid], 128, "cs/%s.ini", PlayerName(playerid));
        IsLogged[playerid] = false;
        if(fexist(file[playerid])) {
            ShowPlayerDialog(playerid, LOGIN, DIALOG_STYLE_PASSWORD, "{00CCFF}Login", "{FFFFFF}Please enter password for login \n\n\n{FF0000}Login is required", "Login", "");
        }
        }
        else {
            ShowPlayerDialog(playerid, REGISTER, DIALOG_STYLE_INPUT, "{00CCFF}Registration", "{FFFFFF}Please enter password for registration \n\n\n{FF0000}Registration is required", "Register", "");
        }
    }
    return 1;
}



Re: Help with "Ban" Variable (++rep) - CmZxC - 09.03.2012

add the
pawn Код:
if(Banned[playerid] == 1)
{
SendClientMessage(playerid, COLOR_ORANGE,"You are banned !");
Kick(playerid);
}
in OnPlayerLogin after the
pawn Код:
Banned[playerid] = dini_Int(file[playerid], "IGBAN");



Re: Help with "Ban" Variable (++rep) - SpiritEvil - 09.03.2012

Put this:

pawn Код:
Banned[playerid] = dini_Int(file[playerid], "IGBAN");
On top of OnPlayerConnect.


Re: Help with "Ban" Variable (++rep) - ServerScripter - 09.03.2012

thanks CmZxC ! works fine ! thank u both !