Range Ban Command - Printable Version
+- SA-MP Forums Archive (
https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (
https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (
https://sampforum.blast.hk/forumdisplay.php?fid=12)
+---- Forum: Help Archive (
https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: Range Ban Command (
/showthread.php?tid=123817)
Range Ban Command -
BP13 - 27.01.2010
So Rangeban is basically broken on ladmin4v2? It bans like this: 99.248.243.238 > 99.248.243.2**. That's pretty much a useless ban because most evaders IP's need to be blocked like this: 99.248.*.* or at least at a minimum 99.248.243.* I tried to do it myself and I just broke the command somehow. Can someone post a working code that bans like this 99.248.*.* and not like this 99.248.243.2**
Here is what the command looks like:
pawn Code:
dcmd_rban(playerid,params[]) {
if(PlayerInfo[playerid][LoggedIn] == 1) {
if(PlayerInfo[playerid][Level] >= 4) {
new ip[128], tmp[256], tmp2[256], Index; tmp = strtok(params,Index), tmp2 = strtok(params,Index);
if(!strlen(params)) return SendClientMessage(playerid, red, "USAGE: /rban [playerid] [reason]");
if(!strlen(tmp2)) return SendClientMessage(playerid, red, "ERROR: You must give a reason");
new player1, playername[MAX_PLAYER_NAME], adminname[MAX_PLAYER_NAME], string[128];
player1 = strval(tmp);
if(IsPlayerConnected(player1) && player1 != INVALID_PLAYER_ID && player1 != playerid && (PlayerInfo[player1][Level] != ServerInfo[MaxAdminLevel]) ) {
GetPlayerName(player1, playername, sizeof(playername)); GetPlayerName(playerid, adminname, sizeof(adminname));
new year,month,day,hour,minuite,second; getdate(year, month, day); gettime(hour,minuite,second);
CMDMessageToAdmins(playerid,"RBAN");
format(string,sizeof(string),"%s has been range banned by Administrator %s [Reason: %s] [Date: %d/%d/%d] [Time: %d:%d]",playername,adminname,params[2],day,month,year,hour,minuite);
SendClientMessageToAll(grey,string);
SaveToFile("BanLog",string);
print(string);
if(udb_Exists(PlayerName2(player1)) && PlayerInfo[player1][LoggedIn] == 1) dUserSetINT(PlayerName2(player1)).("banned",1);
GetPlayerIp(player1,ip,sizeof(ip));
strdel(ip,strlen(ip)-2,strlen(ip));
format(ip,128,"%s**",ip);
format(ip,128,"banip %s",ip);
SendRconCommand(ip);
return 1;
} else return SendClientMessage(playerid, red, "Player is not connected or is yourself or is the highest level admin");
} else return SendClientMessage(playerid,red,"ERROR: You are not a high enough level to use this command");
} else return SendClientMessage(playerid,red,"ERROR: You must be logged in to use this commands");
}
Re: Range Ban Command -
[MWR]Blood - 05.03.2010
Put this: strdel(ip,strlen(ip)-4,strlen(ip)); instead strdel(ip,strlen(ip)-2,strlen(ip));
Re: Range Ban Command -
BP13 - 06.04.2010
that would work if the IP was like this 1.1.1.111
but not like this 1.1.1.11 or 1.1.1.1
Re: Range Ban Command -
woot - 07.04.2010
Hi! I recommend you using sscanf or split() and split the IP by dots into an array. Then put it back together using the [0] and [1] of the array. I recently did the same thing in PHP. I might be able to show you an example if you'd need it.
Re: Range Ban Command -
YmOn - 07.04.2010
Use this great function by MySan
Code:
stock RangeBan(playerid)
{
new pos, oldpos, ip[15], ip2[15], tmp[21];
GetPlayerIp(playerid, ip, sizeof(ip));
pos = strfind(ip, ".", true);
pos++;
for(new i = 0; i < pos; i++)
{
ip2[i] = ip[pos-pos+i];
}
pos--;
ip[pos] = ' ';
oldpos = pos;
oldpos++;
pos = strfind(ip, ".", true);
pos++;
for(new i = oldpos; i < pos; i++)
{
ip2[i] = ip[pos-pos+i];
}
format(ip2, sizeof(ip2), "%s*.*", ip2);
format(tmp, sizeof(tmp), "banip %s", ip2);
SendRconCommand(tmp);
return ip2;
}