Range Banning
#1

You guys are going to get tired of seeing me. ^-^

So my issue, I have a command that kicks me and doesn't ban me. Any sugguestions?

Код:
CMD:rban(playerid, params[])
{
	LoginCheck(playerid);
	LevelCheck(playerid, 4);

	new
		str[130],
		id
	;

	if(sscanf(params, "uS(No Reason)[128]", id, params)) return SendUsage(playerid, "/rban <PlayerID> <Reason(Optional)>", "Range bans the specified player's IP.");
	if(id == INVALID_PLAYER_ID) return SendError(playerid, "Player is not connected.");
	if(id == playerid) return SendError(playerid, "You cannot ban yourself.");
	if(pInfo[playerid][Admin] < pInfo[id][Admin]) return SendError(playerid, "You cannot use this command on a higher level administrator.");
	ClearChatB(id, 100);
    format(str, sizeof(str), "{AFAFAF}%s{FF6347} has been ranged banned by [ADMIN] {AFAFAF}%s{FF6347} (Reason: {AFAFAF}%s{FF6347})", GetName(id), GetName(playerid), params);
    SendClientMessageToAll(COLOR_CHAT, str);
	format(str, sizeof(str), "You have range banned {AFAFAF}%s{FF6347} (Reason: {AFAFAF}%s{FF6347})", GetName(id), params);
	SendClientMessage(playerid, COLOR_CHAT, str);
	format(str, sizeof(str), "You have been banned by [ADMIN] {AFAFAF}%s{FF6347}", GetName(playerid));
	SendClientMessage(id, COLOR_CHAT, str);
    PlaySoundForAll(1140);
	new ip[50];
	GetPlayerIp(id, ip, 16);
    strdel(ip, strlen(ip)-4, strlen(ip));
    format(ip, sizeof(ip), "%s**.**", ip);
    format(ip, sizeof(ip), "banip %s", ip);
    SendRconCommand(ip);
    SendRconCommand("reloadbans");
    //KickDelay(id);
	SendAdm(playerid, "RBAN");
    return 1;
}
Reply
#2

Well, this basically looks like a mess. You define the players IP via GetPlayerIP and then format their IP again, changing it's value. Try this:
pawn Код:
new ip[16], ipaddress[50], banningip[16];
GetPlayerIP(id, ip, 16);
strdel(ipaddress, strlen(ip)-4, strlen(ip));
format(ipaddress, sizeof(ipaddress), "%s**.**", ip);
format(banningip, sizeof(banningip), "banip %s", ipaddress);
SendRconCommand(banningip);
SendRconCommand("reloadbans");
SendAdm(playerid, "RBAN");
return 1;
Lemme know if there are any issues, I'm sure there probably will be.
Reply
#3

undefined symbol "GetPlayerIP" I changed it to GetPlayerIp and it compiled but the command it's self didn't work, I checked the samp.ban to see if my IP was in there and nothing was. I am in for a bit of a loop
Reply
#4

Perhaps this previous thread could be some use to ya.
https://sampforum.blast.hk/showthread.php?tid=369269
Reply
#5

Mhm. I knew I could do that, I was trying to simplify it into a command. :P Thanks though.
Reply
#6

Quote:
Originally Posted by sgtph3n1x
Посмотреть сообщение
Mhm. I knew I could do that, I was trying to simplify it into a command. :P Thanks though.
Well you can, but I think you were over-doing it just a bit with the strings. It got confusing for me to even deal with, as you had string after string, and you were trying to redefine it constantly and format it into itself and everything.
Reply
#7

Well the command is from a Admin script, and with many things it has.. ALOT of the commands didn't even work! I've fixed almost 99% of it but that is one of thew few commands that refuse to work. It doesn't matter how hard I try to fix it. Nothing. Not that it's a big deal. /ban works perfectly though.
Reply
#8

I dont think so your script is adding the banned range in your ban file, try this also it will add the banned range in ban.cfg
pawn Код:
CMD:rban(playerid, params[])
{
    LoginCheck(playerid);
    LevelCheck(playerid, 4);

    new
        str[130],
        id, range[4][4];

    if(sscanf(params, "uS(No Reason)[128]", id, params)) return SendUsage(playerid, "/rban <PlayerID> <Reason(Optional)>", "Range bans the specified player's IP.");
    if(id == INVALID_PLAYER_ID) return SendError(playerid, "Player is not connected.");
    if(id == playerid) return SendError(playerid, "You cannot ban yourself.");
    if(pInfo[playerid][Admin] < pInfo[id][Admin]) return SendError(playerid, "You cannot use this command on a higher level administrator.");
    ClearChatB(id, 100);
    format(str, sizeof(str), "{AFAFAF}%s{FF6347} has been ranged banned by [ADMIN] {AFAFAF}%s{FF6347} (Reason: {AFAFAF}%s{FF6347})", GetName(id), GetName(playerid), params);
    SendClientMessageToAll(COLOR_CHAT, str);
    format(str, sizeof(str), "You have range banned {AFAFAF}%s{FF6347} (Reason: {AFAFAF}%s{FF6347})", GetName(id), params);
    SendClientMessage(playerid, COLOR_CHAT, str);
    format(str, sizeof(str), "You have been banned by [ADMIN] {AFAFAF}%s{FF6347}", GetName(playerid));
    SendClientMessage(id, COLOR_CHAT, str);
    PlaySoundForAll(1140);
    new ip[50];
    split(GetPlayerIp(id, ip, sizeof(ip), range, '.');
    format(str, sizeof(str), "%s.%s.*.*", range[0], range[1]);
    AddRangeBan(str);
    //KickDelay(id);
    SendAdm(playerid, "RBAN");
    return 1;
}
Reply
#9

Weird, I don't remember 'AddRangeBan' being a function?

pawn Код:
CMD:rban(playerid, params[])
{
    LoginCheck(playerid);
    LevelCheck(playerid, 4);
    new id, reason[20];
    if(sscanf(params, "uS(No Reason)[20]", id, reason)) return SendUsage(playerid, "/rban <PlayerID> <Reason(Optional)>", "Range bans the specified player's IP.");
    if(id == INVALID_PLAYER_ID || !IsPlayerConnected(id)) return SendError(playerid, "Player is not connected.");
    if(id == playerid) return SendError(playerid, "You cannot ban yourself.");
    if(pInfo[playerid][Admin] < pInfo[id][Admin]) return SendError(playerid, "You cannot use this command on a higher level administrator.");
    new str[128], ip[16];
    ClearChatB(id, 100);
    format(str, sizeof(str), "{AFAFAF}%s{FF6347} has been ranged banned by [ADMIN] {AFAFAF}%s{FF6347} (Reason: {AFAFAF}%s{FF6347})", GetName(id), GetName(playerid), reason);
    SendClientMessageToAll(COLOR_CHAT, str);
    format(str, sizeof(str), "You have range banned {AFAFAF}%s{FF6347} (Reason: {AFAFAF}%s{FF6347})", GetName(id), reason);
    SendClientMessage(playerid, COLOR_CHAT, str);
    format(str, sizeof(str), "You have been banned by [ADMIN] {AFAFAF}%s{FF6347}", GetName(playerid));
    SendClientMessage(id, COLOR_CHAT, str);
    PlaySoundForAll(1140);
    GetPlayerIp(id, ip, sizeof(ip));
    split(ip, range, '.');
    format(reason, sizeof(reason), "banip %s.%s.*.*", range[0], range[1]);
    SendRconCommand(reason);
    SendAdm(playerid, "RBAN");
    return 1;
}
There's no need to use 'reloadbans' either, you only really need to do that when you unban someone.
Reply
#10

Ok my bad there should be a stock of AddRangeBan like this
pawn Код:
stock AddRangeBan(IP[])
{
    new string[24];
    new File:ban = fopen("ban.cfg", io_append);
    format(string, sizeof(string), "%s\r\n", IP);
    fwrite(ban, string);
    fclose(ban);
}
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)