SubBan System

Started by Diego^, Mar 06, 2015, 10:59 AM

Previous topic - Next topic

Diego^

SubBan System

function onScriptLoad()
{
print(">>> System SubBan loaded <<<");
db <- ConnectSQL( "DataBase.db" );
QuerySQL( db, "CREATE TABLE IF NOT EXISTS SubBans ( Name VARCHAR(32), IP VARCHAR(25), Admin TEXT, Reason TEXT )" );
}

function onScriptUnload()
{
DisconnectSQL( db );
}

function onPlayerJoin( player )
{
NewTimer( "CheckBan", 1000, 1, player.ID );
}

function CheckBan( user )
{
local player = FindPlayer( user );
if ( player )
{
local ip = player.IP;
local sub = split( ip, "." );
local q = QuerySQL( db,  "SELECT * FROM SubBans WHERE IP='" + sub[0].tofloat() + "." + sub[1].tofloat() + "'" );
if ( GetSQLColumnData( q, 0 ) )
{
Message( ">>> " + player + " Banned From Server <<<");
KickPlayer( player );
return 1;
}
}
}

function onPlayerCommand( player, cmd, text )
{
 if ( cmd == "ban" )
        {
    if ( !text ) MessagePlayer( "[Syntax] - /" + cmd + " <Nick/ID> <Reason>", player );
else {
local plr = GetPlayer( GetTok( text, " ", 1 ) );
   if ( !plr ) MessagePlayer( "[Error] - Unknown Player..", player );
   else {
            local reason = GetTok( text, " ", 2 NumTok( text, " " ) );
            local ip = plr.IP;
            local sub = split( ip, "." );
             if ( reason == null ) reason = "None";
             QuerySQL( db, "INSERT INTO SubBans ( Name, IP, Admin, Reason ) VALUES ( '" + plr.Name + "', '" + sub[0].tofloat() + "." + sub[1].tofloat() + "', '" + player.Name + "', '" + reason + "' )" );
            Message( "[#EE82EE]** Admin " + player.Name + " Banned " + plr.Name + " Reason: " + reason );
   KickPlayer( plr );
   }
   }
}

else if ( cmd == "unban" )
{
local q = QuerySQL( db,  "SELECT * FROM SubBans WHERE Name='" + text + "'" );
    if ( !text ) MessagePlayer( "[Syntax] - /" + cmd + " <Nick Full>", player );
   else if ( GetSQLColumnData( q, 0 ) != text ) MessagePlayer( "[Error] - " + text + " is not Banned.", player );
   else {
   QuerySQL( db, "DELETE FROM SubBans WHERE Name='" + text + "'" );
   Message( "[#EE82EE]** Admin " + player.Name + " UnBanned Player [ [#FFA500]" + text + " [#EE82EE]]." );
}
}
}

function GetPlayer( plr )
{
    if ( plr )
    {
        if ( IsNum( plr ) )
        {
            plr = FindPlayer( plr.tointeger() );
            if ( plr ) return plr;
            else return false;
        }
    else
        {
            plr = FindPlayer( plr );
            if ( plr ) return plr;
            else return false;
        }
    }
    else return false;
}

function GetTok(string, separator, n, ...)
{
local m = vargv.len() > 0 ? vargv[0] : n,
  tokenized = split(string, separator),
  text = "";

if (n > tokenized.len() || n < 1) return null;
for (; n <= m; n++)
{
text += text == "" ? tokenized[n-1] : separator + tokenized[n-1];
}
return text;
}

function NumTok(string, separator)
{
local tokenized = split(string, separator);
return tokenized.len();
}

DataBase link -> http://www.mediafire.com/download/28hnw7s1h2m8cf6/DataBase.db
BRL's Developer.

PsyChO_KiLLeR

are u kidding? this just ban the player one time when u rejoin it will be unban

MacTavish

Quote from: PsyChO_KiLLeR on Mar 06, 2015, 03:13 PMare u kidding? this just ban the player one time when u rejoin it will be unban
You Are totally wrong about it His code will work

Grand Hunting Project
Join #SLC, #KAKAN, #Doom, #GHP @LUnet

Retired VC:MP Player/Scripter :P

.

Care to elaborate what this "SubBan" script does? For  us out here who aren't familiar with all the crap out there.
.

Diego^

In most servers the ban is done through the full ip, but with this system is done through the first two numbers of the IP, so it is a safer ban.
BRL's Developer.

PsyChO_KiLLeR

well i have tested this when i ban my self and rejoin with other nick i am unbanned

jayant

Quote from: PsyChO_KiLLeR on Mar 06, 2015, 04:35 PMwell i have tested this when i ban my self and rejoin with other nick i am unbanned
The code by Diego will work..The fault is on your side [ You are doing something wrong everytime, the code people provide here are tested by them before release ]

Diego^

Quote from: PsyChO_KiLLeR on Mar 06, 2015, 04:35 PMwell i have tested this when i ban my self and rejoin with other nick i am unbanned

When you banned, check the DataBase is saved was his banishment.
BRL's Developer.

PsyChO_KiLLeR

i check it ban there bro but when u join with another nick you gonna be unban

Thijn

Quote from: PsyChO_KiLLeR on Mar 07, 2015, 04:34 AMi check it ban there bro but when u join with another nick you gonna be unban
For fucks sake. The script works. What else do we need to say?
You're too stupid to actually copy paste scripts into your own script and then blame the script author saying the script he provided is bugged.

Kratos_


He might be joining as the local-host after banning himself .
In the middle of chaos , lies opportunity.

PsyChO_KiLLeR

yeah i join in local host

.

#12
Quote from: PsyChO_KiLLeR on Mar 07, 2015, 12:04 PMyeah i join in local host

I just *facepalm*'ed right now. I'm literally speechless :o


Also, can you please remove that signature? It's starting to become annoying after a while considering it's distorting the theme layout and takes a huge space on screen. Now I scroll 2 times more than I usually do. I still have no idea why that signature :-\
.

Kratos_


Quote from: S.L.C on Mar 07, 2015, 12:10 PMcan you please remove that signature? it's distorting the theme layout and takes a huge space on screen. Now I scroll 2 times more than I usually do. I still have no idea why that signature :-\

Same thing is happening here .
In the middle of chaos , lies opportunity.

Nazareth

Hi, I added, but the ban is on when you restart the modem :(