Vice City: Multiplayer

Server Development => Scripting and Server Management => Snippet Showroom => Topic started by: Diego^ on Mar 06, 2015, 10:59 AM

Title: SubBan System
Post by: Diego^ on Mar 06, 2015, 10:59 AM
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
Title: Re: SubBan System
Post by: PsyChO_KiLLeR on Mar 06, 2015, 03:13 PM
are u kidding? this just ban the player one time when u rejoin it will be unban
Title: Re: SubBan System
Post by: MacTavish on Mar 06, 2015, 03:14 PM
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
Title: Re: SubBan System
Post by: . on Mar 06, 2015, 03:15 PM
Care to elaborate what this "SubBan" script does? For  us out here who aren't familiar with all the crap out there.
Title: Re: SubBan System
Post by: Diego^ on Mar 06, 2015, 03:56 PM
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.
Title: Re: SubBan System
Post by: PsyChO_KiLLeR on Mar 06, 2015, 04:35 PM
well i have tested this when i ban my self and rejoin with other nick i am unbanned
Title: Re: SubBan System
Post by: jayant on Mar 06, 2015, 04:39 PM
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 ]
Title: Re: SubBan System
Post by: Diego^ on Mar 06, 2015, 05:16 PM
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.
Title: Re: SubBan System
Post by: PsyChO_KiLLeR on Mar 07, 2015, 04:34 AM
i check it ban there bro but when u join with another nick you gonna be unban
Title: Re: SubBan System
Post by: Thijn on Mar 07, 2015, 11:34 AM
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.
Title: Re: SubBan System
Post by: Kratos_ on Mar 07, 2015, 11:36 AM

He might be joining as the local-host after banning himself .
Title: Re: SubBan System
Post by: PsyChO_KiLLeR on Mar 07, 2015, 12:04 PM
yeah i join in local host
Title: Re: SubBan System
Post by: . on Mar 07, 2015, 12:10 PM
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 :-\
Title: Re: SubBan System
Post by: Kratos_ on Mar 07, 2015, 12:18 PM

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 .
Title: Re: SubBan System
Post by: Nazareth on Jul 19, 2017, 11:53 PM
Hi, I added, but the ban is on when you restart the modem :(
Title: Re: SubBan System
Post by: MatheuS on Jul 20, 2017, 08:44 AM
Quote from: Nazareth on Jul 19, 2017, 11:53 PMHi, I added, but the ban is on when you restart the modem :(

http://forum.vc-mp.org/?topic=200.msg1789#msg1789
Title: Re: SubBan System
Post by: =RK=MarineForce on Jul 20, 2017, 03:11 PM
Quote from: MacTavish on Mar 06, 2015, 03:14 PM
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

This is Work only Server Full Fucntion's
Title: Re: SubBan System
Post by: Cool on Jul 21, 2017, 02:44 PM
@MatheuS add a note of if you are hosting a server at home host this ban will not work on yourself