Unban Command
#1

Hi,

I have a command which bans a player ingame

pawn Код:
Kick(player2);
SetPVarInt(playerid2, "Banned", 1);
How do I create a command that unbans an offline player using /unban [name] ?

I would appreciate the help as i am a newbie
Reply
#2

I suggest you download ban/kick system,which is simple to use.I suggest you to don't mess with this,and do something faster and without problems.I suggest you download simple admin system: https://sampforum.blast.hk/showthread.php?tid=372508
Reply
#3

well you need to save the banned players in a list somewhere with their name
and when UnBanning loop to see what name matches and just unbann the ip next to it
Reply
#4

Can I get an example ? I'm new to scripting sorry
Reply
#5

Using Y_INI as the saving system
And ZCMD as the command processor
pawn Код:
COMMAND:ban(playerid, params[])
{
new targetid,String[60];
if(sscanf(params,"us[60]", targetid,String)) return SendClientMessage(playerid, COLOR_WHITE, "Usage: /Ban [playerid] [REASON]");
new OtherN[MAX_PLAYER_NAME];
GetPlayerName(targetid, OtherN, sizeof(OtherN));
//Save it
new file[128];
format(file,sizeof(file),"/Bans/%s.txt",OtherN);//you need a Ban folder
    {
        new INI:Acc = INI_Open(file);
        new IP[16];
        GetPlayerIp(targetid, IP, sizeof IP);
        INI_WriteString(Acc,"IP", IP);
        INI_Close(Acc);
    }
}
new PlayerIP;
COMMAND:unban(playerid, params[])
{
new TName[MAX_PLAYER_NAME];
if(sscanf(params,"s[MAX_PLAYER_NAME]", TName) return SendClientMessage(playerid, COLOR_WHITE, "Usage: /UnBan [player Name]");
new file[128],IPCMD[26];format(file,sizeof(file),"/Bans/%s.txt",TName);
if(fexist(file))//player found
    {
        INI_ParseFile(file, "LoadIP", false, false);
        format(IPCMD,sizeof IPCMD,"unbanip %s",PlayerIP);
        SendRconCommand(IPCMD);
    }
}
forward LoadIP(name[], value[]);
public LoadIP(name[], value[])
{
if(!strcmp(name, "IP", true)) { PlayerIP = strval(value); }
}
Something like that, there might a few mistakes here & there
Reply
#6

Thank you

I will test this later
Reply
#7

pawn Код:
format(IPCMD,sizeof IPCMD,"unbanip %s",PlayerIP);
        SendRconCommand(IPCMD);
Shouldnt I reloadbans after this ?
Reply
#8

Help
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)