Vice City: Multiplayer

Server Development => Scripting and Server Management => Snippet Showroom => Topic started by: Mahmoud Tornado on May 10, 2018, 08:13 PM

Title: Basic Ban System
Post by: Mahmoud Tornado on May 10, 2018, 08:13 PM
Hi Guys, As i will back to VC-MP again in 23/5 and i was making Ban system now.
I decide that i will share it, Enjoy!

onScriptLoad()
Bans <- ConnectSQL( "Bans.db" );
 QuerySQL( Bans, "CREATE TABLE IF NOT EXISTS Bans ( Name VARCHAR(32), IP VARCHAR(25), Admin TEXT, Reason TEXT, Time VARCHAR(255) DEFAULT CURRENT_TIMESTAMP)" );

onPlayerJoin( player )
CheckBan(player);   //Checking if the player banned or not.

Checkban Function
function CheckBan( player )
{
local q1 = QuerySQL( Bans, "SELECT * FROM Bans WHERE IP ='" +player.IP+"'") //Getting the database details
local ip = GetSQLColumnData(q1, 1) // Getting player ip
local name = GetSQLColumnData( q1, 0 ); // Getting player name
if (ip) KickPlayer(player)
else if (name) KickPlayer(player)
else if ( ip && name) KickPlayer( player)
else return 0
}

Baninfo function /which used in unban command.
function Baninfo( p )
{
   local q = QuerySQL( Bans, "SELECT * FROM Bans WHERE Name='" + p + "'" );
   local name = GetSQLColumnData( q, 0 );
   if ( name ) return 1;
   else return 0;
}

Commnads
      if ( cmd == "ban" )
      {
if( Stats[ player.ID ].Log == false ) MessagePlayer( "Inforamtion: You Need Login or Register First.", player );  // Check if the player registered and logged
else if ( Stats[ player.ID ].Level < 7 ) MessagePlayer("Inforamtion: You aren't authorized to use this command.", player ); // Check player level
else if ( !text ) MessagePlayer( "Syntax, /" + cmd + " <nick> <reason>", player ); // the syntax of the command
                else
{
local plr = GetPlayer( GetTok( text, " ", 1 ) ); //getplayer
if ( !plr ) MessagePlayer( "Information: Invalid Player Nick / ID!", player ); // if player not playing
else
{
local reason = GetTok( text, " ", 2 ); //get reason
local now = date(); // For the time date.
if ( reason == null ) reason = "None"; //if no reason return None
{
QuerySQL( Bans, "INSERT INTO Bans ( Name, IP, Admin, Reason, Time ) VALUES ( '" + plr.Name + "', '" + plr.IP + "', '" + player.Name + "', '" + reason + "', '"+ now.year +"/"+now.month+"/"+now.day+"/"+now.hour+":"+ now.min + "' )" ); //Add player to Ban List "added the time"
Message( "Administration Command: Admin " + player.Name + " Banned " + plr.Name + " for Reason: " + reason ); //Msg
KickPlayer( plr ); //kick player
}
}
}
}
else if ( cmd == "unban" )
{
if( Stats[ player.ID ].Log == false ) MessagePlayer( "Inforamtion: You Need Login or Register First.", player );  // Check if the player registered and logged
else if ( Stats[ player.ID ].Level < 7 ) MessagePlayer("Inforamtion: You aren't authorized to use this command.", player ); // Check player level
else if ( !text ) MessagePlayer( "Syntax, /" + cmd + " <Full Nick>", player ); //The Syntax of the command
else if ( Baninfo( text ) == 0 ) MessagePlayer( "Information:" + text + " is not Banned.", player ); //Check if player in banned list
else
{
  QuerySQL( Bans, "DELETE FROM Bans WHERE Name='" + text + "'" ); //Deleting player from the list
Message( "Administration Command: Admin " + player.Name + " UnBanned " +  text + "."); /msg
}
}

else if ( cmd == "baninfo" )
{
if ( !text ) MessagePlayer( "Inforamtion: /"+cmd+" <Full-Nick>", player );
else {
local q = QuerySQL( Bans, "SELECT * FROM Bans WHERE Name='" + text + "' COLLATE NOCASE" );
if ( GetSQLColumnData( q, 0 ) != text ) MessagePlayer( "Information: " + text + " is not Banned.", player );
else
{
MessagePlayer("BanInfo: Name("+GetSQLColumnData( q, 0 )+"), IP("+GetSQLColumnData( q, 1 )+"), Reason("+GetSQLColumnData( q, 3 )+"), Time("+GetSQLColumnData( q, 4 )+", BannedBy("+GetSQLColumnData( q, 2 )+").",player)
}
}
}

Thanks, Your Friend
MahmoudTornado

 :edit:
Adding Time, Checkban with Ip "By Helathien", baninfo command.
 :edit:
Fixing some small bugs.
Title: Re: Basic Ban System
Post by: Kid_Buu on May 10, 2018, 08:31 PM
Good Work Bro :)
Title: Re: Basic Ban System
Post by: Mahmoud Tornado on May 10, 2018, 08:34 PM
Quote from: Kid_Buu on May 10, 2018, 08:31 PMGood Work Bro :)
Thx. :D
Title: Re: Basic Ban System
Post by: Saiyan Attack on May 10, 2018, 10:33 PM
warchief ban system detected ...
Title: Re: Basic Ban System
Post by: Mahmoud Tornado on May 10, 2018, 11:24 PM
I don't have warchief Script.
Title: Re: Basic Ban System
Post by: Saiyan Attack on May 11, 2018, 09:36 AM
Quote from: Mahmoud Tornado on May 10, 2018, 11:24 PMI don't have warchief Script.
hahaha stop lying then where did you copied this code and stop saying that you make this ban system ...
Quote from: Mahmoud Tornado on May 10, 2018, 08:13 PMHi Guys, As i will back to VC-MP again in 23/5 and i was making Ban system now.
I decide that i will share it, Enjoy!
Thanks, Your Friend
MahmoudTornado
Title: Re: Basic Ban System
Post by: Mahmoud Tornado on May 11, 2018, 01:49 PM
Quote from: Saiyan Attack on May 11, 2018, 09:36 AM
Quote from: Mahmoud Tornado on May 10, 2018, 11:24 PMI don't have warchief Script.
hahaha stop lying then where did you copied this code and stop saying that you make this ban system ...
Quote from: Mahmoud Tornado on May 10, 2018, 08:13 PMHi Guys, As i will back to VC-MP again in 23/5 and i was making Ban system now.
I decide that i will share it, Enjoy!
Thanks, Your Friend
MahmoudTornado
You don't know if I have warchief Script or not to say that I'm lying.
And if I had that script I was added my server from along time ago.
And I'm who made that system.
Title: Re: Basic Ban System
Post by: Mohamed Boubekri on May 11, 2018, 02:27 PM
GooD Work Bro!
But when someone Type /ban, the cmd will not work because 'Stats' Didn't Exist!
First Try to Add Class, Else delete the line in /ban Like:
if( Stats[ player.ID ].Log == false ) MessagePlayer( "[#00de00]Inforamtion: [#fbf3f3]You Need Login or Register First.", player );  // Check if the player registered and loggedSome Players will not know how to deal with the system, but u try to add a definition of Class.
Title: Re: Basic Ban System
Post by: Mahmoud Tornado on May 11, 2018, 03:54 PM
Quote from: Mohamed on May 11, 2018, 02:27 PMGooD Work Bro!
But when someone Type /ban, the cmd will not work because 'Stats' Didn't Exist!
First Try to Add Class, Else delete the line in /ban Like:
if( Stats[ player.ID ].Log == false ) MessagePlayer( "[#00de00]Inforamtion: [#fbf3f3]You Need Login or Register First.", player );  // Check if the player registered and loggedSome Players will not know how to deal with the system, but u try to add a definition of Class
it's not a problem as the people can see it.
But anyways Thanks
Title: Re: Basic Ban System
Post by: =RK=MarineForce on Jul 18, 2018, 03:59 PM
its not show admin name exmaple banned by admin [varchar] reason hp hax
Title: Re: Basic Ban System
Post by: Mahmoud Tornado on Jul 18, 2018, 04:34 PM
Quote from: =RK=MarineForce on Jul 18, 2018, 03:59 PMits not show admin name exmaple banned by admin [varchar] reason hp hax
I don't think so, as i tested it.
if you wanna it like this " banned by admin [varchar] reason hp hax "
use this:
  Message( "[#00de00]Administration Command: [#fbf3f3]" + plr.Name + " Has Been Banned By " + player.Name + " for " + reason );

Title: Re: Basic Ban System
Post by: =RK=MarineForce on Jul 19, 2018, 12:12 PM
Thanks i can use it on diego ban ur diego same but ur best :P i will check it on diego
Title: Re: Basic Ban System
Post by: Mahmoud Tornado on Jul 28, 2018, 08:29 PM
Quote from: =RK=MarineForce on Jul 19, 2018, 12:12 PMThanks i can use it on diego ban ur diego same but ur best :P i will check it on diego
Can anyone translate this to english, please?
Title: Re: Basic Ban System
Post by: [KM]Helathien on Jul 29, 2018, 06:43 AM
I haven't checked it on server, but seeing from the code I can see that the CheckBan function only checks the Name of the player, whereas when you banned the player his name and IP Both were saved.
This way player can just change his name and come. So please also add
local q1 = QuerySQL( Bans, "SELECT * FROM Bans WHERE IP ='" +player.IP+"'")
local ip = GetSQLColumnData(q1, 1)
if (ip) KickPlayer(player)
else if (name) KickPlayer(player)
else if ( ip && name) KickPlayer( player)
else return 0

I am on mobile right now, but you get the idea.
Good job BTW.
Title: Re: Basic Ban System
Post by: Tajammul on Oct 21, 2018, 05:57 AM
Warcheif Ban System lol !!! xD
 :o 8)
Title: Re: Basic Ban System
Post by: Mahmoud Tornado on Oct 21, 2018, 10:59 PM
We will back to that again? WTF!

Quote from: Mahmoud Tornado on May 10, 2018, 11:24 PMI don't have warchief Script.