Mahmoud Tornado

  • Full Member
  • Posts: 214
Basic Ban System
« on May 10th, 2018, 09:13 PM »Last edited
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()
Code: [Select]
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 )
Code: [Select]
CheckBan(player);   //Checking if the player banned or not.

Checkban Function
Code: [Select]
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.
Code: [Select]
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
Code: [Select]
      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.

Kid_Buu

  • Newbie
  • Posts: 33

Mahmoud Tornado

  • Full Member
  • Posts: 214

Saiyan Attack

  • Jr. Member
  • [KoF]Killer
  • Posts: 72
Re: Basic Ban System
« Reply #3, on May 10th, 2018, 11:33 PM »
warchief ban system detected ...

Mahmoud Tornado

  • Full Member
  • Posts: 214

Saiyan Attack

  • Jr. Member
  • [KoF]Killer
  • Posts: 72
Re: Basic Ban System
« Reply #5, on May 11th, 2018, 10:36 AM »
Quote from Mahmoud Tornado on May 11th, 2018, 12:24 AM
I 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 10th, 2018, 09: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!
Thanks, Your Friend
MahmoudTornado

Mahmoud Tornado

  • Full Member
  • Posts: 214
Re: Basic Ban System
« Reply #6, on May 11th, 2018, 02:49 PM »
Quote from Saiyan Attack on May 11th, 2018, 10:36 AM
Quote from Mahmoud Tornado on May 11th, 2018, 12:24 AM
I 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 10th, 2018, 09: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!
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.

Mohamed

  • Full Member
  • Regards, We3da
  • Posts: 246
Re: Basic Ban System
« Reply #7, on May 11th, 2018, 03:27 PM »Last edited on May 11th, 2018, 03:32 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:
Code: [Select]
if( Stats[ player.ID ].Log == false ) MessagePlayer( "[#00de00]Inforamtion: [#fbf3f3]You Need Login or Register First.", player );  // Check if the player registered and logged
Some Players will not know how to deal with the system, but u try to add a definition of Class.
Feel Free To PM Me For Any Support, I'm Care.
Anyway u can Contact Me Ingame!
Ingame Name: [AFt]We3da^
My Own Server: ViceEvil Server

Mahmoud Tornado

  • Full Member
  • Posts: 214
Re: Basic Ban System
« Reply #8, on May 11th, 2018, 04:54 PM »
Quote from Mohamed on May 11th, 2018, 03: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:
Code: [Select]
if( Stats[ player.ID ].Log == false ) MessagePlayer( "[#00de00]Inforamtion: [#fbf3f3]You Need Login or Register First.", player );  // Check if the player registered and logged
Some 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

=RK=MarineForce

  • Sr. Member
  • WAR IS HELL!
  • Posts: 475
Re: Basic Ban System
« Reply #9, on July 18th, 2018, 04:59 PM »
its not show admin name exmaple banned by admin [varchar] reason hp hax
Try to UnderStand ME!

Mahmoud Tornado

  • Full Member
  • Posts: 214
Re: Basic Ban System
« Reply #10, on July 18th, 2018, 05:34 PM »
Quote from =RK=MarineForce on July 18th, 2018, 04:59 PM
its 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:
Code: [Select]
  Message( "[#00de00]Administration Command: [#fbf3f3]" + plr.Name + " Has Been Banned By " + player.Name + " for " + reason );


=RK=MarineForce

  • Sr. Member
  • WAR IS HELL!
  • Posts: 475
Re: Basic Ban System
« Reply #11, on July 19th, 2018, 01:12 PM »
Thanks i can use it on diego ban ur diego same but ur best :P i will check it on diego
Try to UnderStand ME!

Mahmoud Tornado

  • Full Member
  • Posts: 214
Re: Basic Ban System
« Reply #12, on July 28th, 2018, 09:29 PM »
Quote from =RK=MarineForce on July 19th, 2018, 01:12 PM
Thanks 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?

[KM]Helathien

  • Newbie
  • Posts: 21
Re: Basic Ban System
« Reply #13, on July 29th, 2018, 07:43 AM »Last edited on July 29th, 2018, 05:13 PM
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
Code: [Select]
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.
Feel free to PM me for any help.
If I am not available on the forum come to VKs Official Server I am usually there.

Tajammul

  • Newbie
  • Posts: 9
Re: Basic Ban System
« Reply #14,  »
Warcheif Ban System lol !!! xD
 :o 8)