/banip cmd not working
#1

Yoyo guys, this time salt is here with his own problems.
I've created this /banip command ages ago and tested it. It didn't work, and I just left it like that cause I didn't need it. But not I need this, so I've come here.
pawn Код:
CMD:banip(playerid,params[])//doesn't work. But will work soon. I don't think so
{
    if(PlayerAcc[playerid][Admin] < 2) return SendClientMessage(playerid,0xFFFFFFFF,"   "COL_ERROR"You cannot use this command");
    new id;
    new reason[256];
    new ip[16];
    new string[256];
    if(sscanf(params,"us[256]",id,reason)) return SendClientMessage(playerid,0xFFFFFFFF,"   "COL_PARAM"/banip [playerid] [reason]");
    if(!IsPlayerConnected(id)) return SendClientMessage(playerid,0xFFFFFFFF,"   "COL_ERROR"This player isn't online. Please specify a valid player.");
    /*if(playerid == id) return SendClientMessage(playerid,0xFFFFFFFF,"   "COL_ERROR"You cannot ban yourself!");*/
    if(PlayerAcc[id][Admin] > PlayerAcc[playerid][Admin]) SendClientMessage(playerid,0xFFFFFFFF,"   "COL_ERROR"You cannot ban any Administrator having a higher level than you.");
    GetUserAdminLevel(playerid);
    GetPlayerIp(id,ip,sizeof(ip));
    SetTimerEx("BanIpTimer",100,false,"s",ip);
    format(string,sizeof(string),"     %s "COL_RULE"has banned "COL_PLAYER"%s"COL_RULE"'s ip for the "COL_NREASON"reason: %s",AdminLevel,GetUserName(id),reason);
    SendClientMessageToAll(0xFFFFFFFF,string);
    return 1;
}
forward BanIpTimer(ip);
public BanIpTimer(ip)
{
    new banstring[256];
    format(banstring,sizeof(banstring),"banip %s",ip);
    SendRconCommand(banstring);
    SendRconCommand("reloadbans");
}
I am sending simple rcon commands for now, so y_ini stuff doesn't matter.
Client Messages are sent, and timer is being called.
I'd appreciate any useful help.
Reply
#2

Can you tell us what exact thing is not working? The player is not getting banned?
Reply
#3

Is the timer necessary ? if not, remove and then try.
Reply
#4

Yes, that. The player is not getting banned. --> same meaning as /banip cmd not working
EDIT: @ rittik,
the timer is needed. Otherwise the player will get banned without seeing the reason of the ban, I mean he can't see the client message.
pawn Код:
format(string,sizeof(string),"     %s "COL_RULE"has banned "COL_PLAYER"%s"COL_RULE"'s ip for the "COL_NREASON"reason: %s",AdminLevel,GetUserName(id),reason);
    SendClientMessageToAll(0xFFFFFFFF,string);
Reply
#5

Quote:
Originally Posted by NaClchemistryK
Посмотреть сообщение
Yes, that. The player is not getting banned. --> same meaning as /banip cmd not working
EDIT: @ rittik,
the timer is needed. Otherwise the player will get banned without seeing the reason of the ban, I mean he can't see the client message.
pawn Код:
format(string,sizeof(string),"     %s "COL_RULE"has banned "COL_PLAYER"%s"COL_RULE"'s ip for the "COL_NREASON"reason: %s",AdminLevel,GetUserName(id),reason);
    SendClientMessageToAll(0xFFFFFFFF,string);
Can i ask you one simple question .
/banip should be used for offline bans at my perspective as its more easier to /ban [id] [reason] and auto-ban his ip(if you have this scripted) . But sure .

EDIT: The command works and it says that the player got banned but he remains online .

Replace :
pawn Код:
forward BanIpTimer(ip);
public BanIpTimer(ip)
{
    new banstring[256];
    format(banstring,sizeof(banstring),"banip %s",ip);
    SendRconCommand(banstring);
    SendRconCommand("reloadbans");
}
With
pawn Код:
forward BanIpTimer(ip);
public BanIpTimer(ip)
{
    new banstring[256];
    format(banstring,sizeof(banstring),"banip %s",ip);
    SendRconCommand(banstring);
    SendRconCommand("reloadbans");
    Kick(playerid);
}
It worked for me ....
Reply
#6

banning a player ip and a player account isn't the same.
banning an ip - A player's ip is banned. Therefore, any ip that is related to any banned ip can't connect to the server
banning an account - only the account can't login. The user can use a new account and re-connect. Works.

So banning an ip is a much more strict punishment for users, and is rather used for bigger traitors than simple rulebreakers. I'll add a script that compares ips later when someone multi-accounts. But first I need help with this cmd.. I realleh need this.
EDIT: I'll be testing that Kick stuff. And yours should work. Thanks.
EDIT2: It can't work for you, cause there isn't a "playerid" in the header of the timer. Liar. I'll fix that by myself xD
Reply
#7

Quote:
Originally Posted by Johnson_Brooks
Посмотреть сообщение
pawn Код:
forward BanIpTimer(ip);
public BanIpTimer(ip)
{
    new banstring[256];
    format(banstring,sizeof(banstring),"banip %s",ip);
    SendRconCommand(banstring);
    SendRconCommand("reloadbans");
    Kick(playerid);
}
Yep - that is correct. The player gets BANNED but he is still In-Game. Actually, banip was made to ban offline players but it'll work still.
Just put Kick(playerid); under the timer [already put on the Code Johnson provided] so he gets kicked when he is banned.


EDIT: Just saw this:
Quote:
Originally Posted by NacLChemistry
EDIT2: It can't work for you, cause there isn't a "playerid" in the header of the timer. Liar. I'll fix that by myself xD
Lol - you need sense for lying too. :c
Reply
#8

Quote:
Originally Posted by SA-MP Wiki
Format Syntax
Specifier Meaning
i Integer.
d Integer.
a Array. The next parameter must be an integer ("i") with the array's size. [CURRENTLY UNUSABLE]
s String. [CURRENTLY UNUSABLE]
f Float.
b Boolean (true/false).
You cannot use the "s" parameter in SetTimerEx afaik. (Yet)

pawn Код:
CMD:banip(playerid,params[])//doesn't work. But will work soon. I don't think so
{
    if(PlayerAcc[playerid][Admin] < 2) return SendClientMessage(playerid, 0xFFFFFFFF, "   "COL_ERROR"You cannot use this command");
    new id, reason[30];
    if(sscanf(params,"us[30]",id,reason)) return SendClientMessage(playerid, 0xFFFFFFFF, "   "COL_PARAM"/banip [playerid] [reason]");
    if(!IsPlayerConnected(id)) return SendClientMessage(playerid, 0xFFFFFFFF, "   "COL_ERROR"This player isn't online. Please specify a valid player.");
    //if(playerid == id) return SendClientMessage(playerid, 0xFFFFFFFF, "   "COL_ERROR"You cannot ban yourself!");
    if(PlayerAcc[id][Admin] > PlayerAcc[playerid][Admin]) return SendClientMessage(playerid, 0xFFFFFFFF, "   "COL_ERROR"You cannot ban any Administrator with a higher level than you.");
    GetUserAdminLevel(playerid); //No idea what this does :l
    GetPlayerIp(id, ip, sizeof(ip));
    new string[128];
    format(string, sizeof(string), "banip %s", ip);
    SendRconCommand(string);
    SendRconCommand("reloadbans");
    format(string, sizeof(string), "     %s "COL_RULE"has banned "COL_PLAYER"%s"COL_RULE"'s ip for the "COL_NREASON"reason: %s", AdminLevel, GetUserName(id), reason);
    SendClientMessageToAll(0xFFFFFFFF,string);
    return 1;
}
Reply
#9

The script only kicked me :S
@ benzo I want the client messages to be sent.
Anyways, when I use the rcon banip command, will it ban me, instead of leaving me ig? if it leaves me ig, then it is my profit, then I can successfully kick the player and ban the ip at the same time. I'll test it.
Reply
#10

Sorreh for double post :S
I've got this new , edited script.
pawn Код:
//blablabla...
    GetUserAdminLevel(playerid);
    GetPlayerIp(id,ip,sizeof(ip));
    new banstring[256];
    format(banstring,sizeof(banstring),"banip %s",ip);
    SendRconCommand(banstring);
    SendRconCommand("reloadbans");
    SetTimerEx("BanIpTimer",100,false,"u",playerid);
    format(string,sizeof(string),"     %s "COL_RULE"has banned "COL_PLAYER"%s"COL_RULE"'s ip for the "COL_NREASON"reason: %s",AdminLevel,GetUserName(id),reason);
    SendClientMessageToAll(0xFFFFFFFF,string);
    return 1;
}
forward BanIpTimer(playerid,ip);
public BanIpTimer(playerid,ip)
{
    Kick(playerid);
}
still doesn't work, and still onleh kicks me :O
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)