Ban on user file?
#1

Hi guys, I got a /ban command..
It's not working properly, It doesn't right Ban = 1 in the user file..
It just bans on samp.ban

Well what I need is to set it to 1, here is my code:
pawn Код:
COMMAND:ban(playerid, params[])
{
    if(PlayerInfo[playerid][pAdmin] >=3)
    {
        new File:Log = fopen(banPATH, io_append);
        new logData[128];
        new target;
        new reason[112];
        if(target == INVALID_PLAYER_ID) return SendClientMessage(playerid,COLOR_RED, "ERROR: That player is not connected.");
        if(sscanf(params,"us[112]",target,reason)) return SendClientMessage(playerid,COLOR_WHITE, "USAGE: /ban [playerid] [reason]");
        if(PlayerInfo[target][pAdmin] ==5) return SendClientMessage(playerid,COLOR_RED, "ERROR: Cannot ban this admin!");
        {
            new pstring[128];
            new pname[24];
            new xname[24];
            GetPlayerName(playerid, pname, sizeof(pname));
            GetPlayerName(target, xname, sizeof(xname));
            format(pstring,sizeof(pstring), "{2EAD15}[ADMIN] %s {FFFFFF} has banned {FF0000}%s. {E0A21B}(Reason: %s )",pname,xname,reason);
            SendClientMessageToAll(COLOR_ORANGE, pstring);
            format(logData,sizeof logData, "%s has been banned by %s. (Reason: %s) \r\n",xname,pname,reason);
            fwrite(Log, logData);
            fclose(Log);
            PlayerInfo[target][pBan] = 1;
            Ban(target);

        }
    }
    else SendClientMessage(playerid,COLOR_RED, "You're not authorized to use this command.");
    return 1;
}
Also here's my UNBAN command, I want it to set ban to 0, I dont know if its proper:
pawn Код:
CMD:unban(playerid, params[])
{
    if(PlayerInfo[playerid][pAdmin] >= 4)
    {
            new tname[24];
            if(sscanf(params, "s[24]", tname)) return SendClientMessage(playerid,-1,"Correct Usage: /unban [Name] ");
            new filestring[79];
            format(filestring, sizeof(filestring), "/Users/%s.ini", tname);
            if(!fexist(filestring)) return SendClientMessage(playerid,COLOR_RED, "ERROR: Player Not Found!");
            new string[64];
            format(string, sizeof(string), "Successfully unbanned player: %s", tname);
            SendClientMessage(playerid, COLOR_ORANGE, string);
            new INI:File = INI_Open(filestring);
            INI_SetTag(File, "data");
            INI_WriteInt(File, "Ban",0);
            INI_Close(File);
            return 1;
    }
    else return SendClientMessage(playerid, COLOR_BRIGHTRED, "You're not authorized to use this command.");
}
It didnt work when I tried it, so..



I also got a question, is there anyway we can do it like unban from samp.ban by name and not IP?
Maybe if we can detect the player's IP and check the name, then unban from samp.ban, is it possible?


Okay thanks guys, I hope anyone can help.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)