Functions List
- BanSubnet(player,admin,reason) : Ban a players Subnet
- IsSubban(player) : Check if the player's Subnet is banned
- GetSubnet(player) : Get the players Subnet from IP
OnScriptLoad
LoadModule("lu_sqlite");
Load the Module.
database <- sqlite_open( "LU/data/Subnet.subnetz" );
sqlite_query( database, "CREATE TABLE IF NOT EXISTS Subnet (Subnet FLOAT, Time TEXT, Admin TEXT, Reason TEXT )" );
Create a database to store the subnet bans data
Functions
BanSubnet(player,admin,reason)function BanSubnet(player,admin,reason)
{
local sub = GetSubnet(player);
sqlite_query( database,"INSERT INTO Subnet ( Subnet, Time, Admin, Reason ) VALUES ( '"+sub+"', '"+GetFullTime()+"', '"+admin+"', '"+reason+"' )" );
Message( "Banning Subnet:[ "+ sub +" ] by [ " + admin + " ] Reason:[ " + reason + " ]");
KickPlayer(player);
}
IsSubban(player)function IsSubban(player)
{
local sub = GetSubnet(player);
local User = sqlite_column_data( sqlite_query(database, "SELECT Admin FROM Subnet WHERE Subnet='" + sub + "'" ), 0 );
if ( User ) return User;
else return 0;
}
GetSubnet(player)function GetSubnet(player)
{
local ip = player.IP.tostring();
local sliceip = split( ip, ".");
local ip1 = sliceip[ 0 ], ip2 = sliceip[ 1 ];
local subnet = format(ip1 + "." + ip2 );
return subnet;
}
USAGE: Command
if( cmd == "subban" )
{
else if ( !text ) MessagePlayer( "Error: /" +cmd+ " [Nick/ID] [Reason]", player );
else
{
local plr = FindPlayer(GetTok( text, " ", 1 ));
if(!plr) MessagePlayer( "Error: No such player is online!", player );
else {
local Reason = GetTok( text, " ", 2, NumTok( text, " " ) );
if(!Reason) BanSubnet(plr,player, "none");
else BanSubnet(plr,player,Reason);
}
}
else MessagePlayer( "You don't have access to use this command!", player );
}
USAGE: Checking
function onPlayerJoin( player )
{
if( IsSubban(player) )
{
Message("Kicking:[ " + player.Name + " ] for:[ Subnet banned ] Subnet:[ " + GetSubnet(player).tostring()+ " ]");
KickPlayer(player);
}
return 1;
}
- If you want to view: the date of the ban, by which admin, reason or if you want to manually add subnet bans or manually delete subnet Download
- You will also need lu_sqlite Module which can be found within the server package.
- Thanks you and if you find any bugs please inform me
Scripted by: [FS]Rocky and Rifle