Help With dcmd_unban
#1

This is my ban cmd

pawn Код:
dcmd_ban(playerid,params[]) {
    if(IsPlayerCommandLevel(playerid,"ban")) {
        if(!strlen(params)) return SendClientMessage(playerid,red,"Syntax Error: \"/BAN <NICK OR ID> (<REASON>)\".");
        new tmp[256],Index; tmp = strtok(params,Index);
        new id; if(!IsNumeric(tmp)) id = ReturnPlayerID(tmp); else id = strval(tmp);
        if(IsPlayerConnected(id) && id != INVALID_PLAYER_ID && id != playerid) {
            SendCommandMessageToAdmins(playerid,"BAN");
            new string[256],name[24],ActionName[24]; GetPlayerName(playerid,name,24); GetPlayerName(id,ActionName,24);
            if(!strlen(params[strlen(tmp)+1])) format(string,256,"\"%s\" has been Banned by Administrator \"%s\".",ActionName,name);
            else format(string,256,"\"%s\" has been Banned by Administrator \"%s\". (Reason: %s)",ActionName,name,params[strlen(tmp)+1]);
            SendClientMessageToAll(yellow,string); return Ban(id);
        } else return SendClientMessage(playerid,red,"ERROR: You can not ban yourself or a disconnected player.");
    } else return SendLevelErrorMessage(playerid,"ban");
}
Can anyone help in unban cmd, something like /unban (IP) or /unban (name) that unban's ip too. thanks in advanced.
LET the variable if(IsPlayerCommandLevel(playerid,"ban")) {
Reply
#2

Anyone?
Reply
#3

Just wait, for people to see your post...
Anyway, you want a command where you write the name and it unban his character and is IP?
like: /unban Hitter_Hitman
And the account Hitter_Hitman gets unbanned, and his ip too?
Reply
#4

yeah that should be better then /unban ip thats why i need that. Secondly, ban [name] cmd bans the ip too (as much as iI know) so i need the same cmd that unbans ip using name.
Reply
#5

pawn Код:
dcmd_unban(playerid,params[])
{
    if(!strlen(params)) return SendClientMessage(playerid,red,"Syntax Error: /unban <IP>");//syntax if he typed nothing in params.
    new ip[16],string[68];//declaring the ip and a new string.
    format(string,sizeof(string),"unbanip %s",ip);//formating Rcon command
    SendRconCommand(string);//sending the command
    SendRconCommand("reloadbans");//reloading ban list.
    return 1;
}
Source : https://sampwiki.blast.hk/wiki/SendRconCommand
Reply
#6

Then, you need to add two fields in the account saves:
-pIP
-pBanned

When the player connect to your server refresh the pIP field, and save it to his file.
Edit your ban command, and before the Ban(id); Add
pawn Код:
PlayerInfo[id][pBanned] = 1; //edit this in base of your script
Then in the unban command open the file with the name written in the command, get the two fields, set pBanned = 0
and get the IP as string, then use
pawn Код:
new bcmd[32];
format(bcmd, sizeof(bcmd), "unban %s", IP); //WHERE IP is the IP read from the file
SendRconCommad(bcmd);
Reply
#7

I got these

Quote:

D:\Sa-mp server\filterscripts\XtremeAdmin2.pwn(1214) : error 001: expected token: "-string end-", but found "-identifier-"
D:\Sa-mp server\filterscripts\XtremeAdmin2.pwn(1214) : error 029: invalid expression, assumed zero
D:\Sa-mp server\filterscripts\XtremeAdmin2.pwn(1214) : warning 215: expression has no effect
D:\Sa-mp server\filterscripts\XtremeAdmin2.pwn(1214) : error 001: expected token: ";", but found ")"
D:\Sa-mp server\filterscripts\XtremeAdmin2.pwn(1214) : fatal error 107: too many error messages on one line

Compilation aborted.Pawn compiler 3.2.3664 Copyright © 1997-2006, ITB CompuPhase


4 Errors.

Reply
#8

Ahh , sorry i have edited my post , that was through fast typing re-try that
pawn Код:
dcmd_unban(playerid,params[])
{
    if(!strlen(params)) return SendClientMessage(playerid,red,"Syntax Error: /unban <IP>");//syntax if he typed nothing in params.
    new ip[16],string[68];//declaring the ip and a new string.
    format(string,sizeof(string),"unbanip %s",ip);//formating Rcon command
    SendRconCommand(string);//sending the command
    SendRconCommand("reloadbans");//reloading ban list.
    return 1;
}
Reply
#9

Yeah that worked thanks man!
Reply
#10

DELETED--
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)