Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //tempban script by hotdogcat
- Edited by TerrorStyles ( PrivMessages, Kick Errors, EchoMessages )
- //put these funcions in onscriptload
- function onScriptLoad()
- {
- tb <- ConnectSQL( "Tempban.db" );
- NewTimer( "tunban", 3600000, 0 );
- NewTimer( "ct", 3600, 1 );
- }
- //put this in onplayerjoin
- function onPlayerJoin( player )//i suggest to remove autokick from here if you use timers in onplayerjoin
- {
- if ( tban( player ) == 1 ) Message(" " + player.Name + " kicked reason: Temp-Banned");
- if ( tban( player ) == 1 ) player.Kick();
- }
- //now some functions
- function ct( )//this function auto-create tempban table in your database
- {
- QuerySQL( tb, "CREATE TABLE IF NOT EXISTS Tempban ( IP VARCHAR(25), Name TEXT, Expires NUMERIC, Admin TEXT, Reason TEXT, Hours NUMERIC, time TEXT )" );
- }
- function tunban( )//this function decrase 1 hour from tempban, if there are 0 hours left server remove the ban.
- {
- QuerySQL( tb, "UPDATE Tempban SET Expires=(Expires-1) WHERE IP" );
- QuerySQL( tb, "DELETE FROM Tempban WHERE Expires='0'" );
- }
- function PrivMessages( text, player )
- {
- ClientMessage( "** pm >> " + text, player, 255, 165, 0);
- }
- function tban( p ) //this check if player is banned or not.
- {
- local q = QuerySQL( tb, "SELECT * FROM Tempban WHERE IP='" + p.IP + "'" );
- local IP = GetSQLColumnData( q, 0 );
- if ( IP ) return 1;
- else return 0;
- }
- //some commands(game)
- else if ( cmd == "tempban" )
- {
- if ( !text ) PrivMessages( "Use / tempban <player> <hours> <reason>", player );
- else
- {
- local plr = GetPlayer( GetTok( text, " ", 1 ) );
- local t = GetTok( text, " ", 2);
- local reason = GetTok( text, " ", 3 NumTok( text, " " ) );
- if (!IsNum(t)) PrivMessages("hours Must Be In Numbers..",player);
- if ( reason == null ) PrivMessages( "Insert the reason", player );
- if ( t == null ) PrivMessages( "Insert the time", player );
- if ( !plr ) PrivMessages( "Invalid Nick/ID.", player );
- if (!IsNum(t)) t = "1";
- if ( reason == null ) reason = "no info.";
- else
- {
- Message( "Admin " + player + " Temp-Banned:[ " + plr + " ], Reason [ " + reason + " ] Time Left:[ " + t + " Hours, 0 Minutes, 0 Seconds ]" );
- QuerySQL( tb, "INSERT INTO Tempban ( IP, Name, Expires, Admin, Reason, hours, time ) VALUES ( '" + plr.IP + "', '" + plr.Name + "', '" + t + "', '" + player.Name + "', '" + reason + "', '" + t + "','" + GetFullTime() + "' )" );
- plr.Kick();
- }
- }
- }
- else if ( cmd == "tempbanip" )
- {
- if ( !text ) PrivMessages( "Use / tempbanip <nick> <ip> <hours> <reason> ", player );
- else
- {
- local nick = GetTok( text, " ", 1);
- local ip = GetTok( text, " ", 2);
- local t = GetTok( text, " ", 3);
- local reason = GetTok( text, " ", 4 NumTok( text, " " ) );
- if ( nick == null ) PrivMessages( "Error - insert nick", player );
- if ( ip == null ) PrivMessages( "Error - insert ip", player );
- if ( t == null ) PrivMessages( "Error - insert hours", player );
- if ( reason == null ) PrivMessages( "Reason is needed", player );
- if (!IsNum(t)) t = "1";
- if ( reason == null ) reason = "no info.";
- else
- {
- Message( "Admin " + player + " Temp-Banned:[ " + nick + " ], IP: [ " + IP + " ], Reason [ " + reason + " ] Duration:[ " + t + " Hours , 0 Minutes, 0 Seconds ]" );
- QuerySQL( tb, "INSERT INTO Tempban ( IP, Name, Expires, Admin, Reason, hours, time ) VALUES ( '" + ip + "', '" + nick + "', '" + t + "', '" + player.Name + "', '" + reason + "', '" + t + "','" + GetFullTime() + "' )" );
- }
- }
- }
- else if ( cmd == "days" )
- {
- if ( !text ) PrivMessages( "Use / days", player );
- else
- {
- local hours = GetTok( text, " ", 1);
- local time = hours.tointeger() * 24;
- PrivMessages( " " + hours + " days are " + time + " hours.", player );
- }
- }
- else if ( cmd == "tunban" )
- {
- if ( !text ) PrivMessages( "Use / unban <ip> ", player );
- else
- {
- local ip = GetTok( text, " ", 1);
- QuerySQL( tb, "DELETE FROM Tempban WHERE IP='" + ip + "'" );
- Message( "Admin " + player.Name + " removed tempban of ip " + ip + "." );
- }
- }
- //Irc commands (fbs-echo)
- else if ( cmd == "!tempbanip" )
- {
- if ( level < 4 ) EchoNotice( user, ICOL_RED + " - Your Level is not Enough." );
- else if ( !text ) EchoNotice( user, ICOL_RED + "Error - Syntax: " + cmd + " <Nick> <IP> <Hours> <Reason>");
- else
- {
- local nick = GetTok( text, " ", 1);
- local ip = GetTok( text, " ", 2);
- local t = GetTok( text, " ", 3);
- local reason = GetTok( text, " ", 4 NumTok( text, " " ) );
- if ( nick == null ) EchoNotice( user, "Insert an valid nick" );
- if ( ip == null ) EchoNotice( user, "Insert ip" );
- if ( t == null ) EchoNotice( user, "Insert hours" );
- if ( reason == null ) EchoNotice( user, "Insert reason" );
- if ( reason == null ) reason = "no info.";
- if (!IsNum(t)) t = "1";
- else
- {
- Message( "Admin Irc " + user + " Temp-Banned:[ " + nick + " ], IP [ " + ip + " ], Reason [ " + reason + " ] Duration:[ " + t + " Hours, 0 Minutes, 0 Seconds ]" );
- QuerySQL( tb, "INSERT INTO Tempban ( IP, Name, Expires, Admin, Reason, hours, time ) VALUES ( '" + ip + "', '" + nick + "', '" + t + "', '" + user + "', '" + reason + "', '" + t + "','" + GetFullTime() + "' )" );
- }
- }
- }
- else if ( cmd == "!tunban" )
- {
- if ( level < 4 ) EchoNotice( user, ICOL_RED + "Error - Your Level is not Enough." );
- else if ( !text ) EchoNotice( user, ICOL_RED + "Error - Syntax: " + cmd + " <nick>");
- else
- {
- local nick = GetTok( text, " ", 1);
- QuerySQL( tb, "DELETE FROM Tempban WHERE Name='" + nick + "'" );
- EchoMessage( "Admin irc " + user + " [TEMP]UnBanned Nick " + nick + "." );
- Message( "Admin irc " + user + " [TEMP]UnBanned Nick " + nick + "." );
- }
- }
- else if ( cmd == "!tunbanip" )
- {
- if ( level < 4 ) EchoNotice( user, ICOL_RED + "Error - Your Level is not Enough." );
- else if ( !text ) EchoNotice( user, ICOL_RED + "Error - Syntax: " + cmd + " <ip>");
- else
- {
- local IP = GetTok( text, " ", 1);
- QuerySQL( tb, "DELETE FROM Tempban WHERE Name='" + IP + "'" );
- EchoMessage( "Admin irc " + user + " [TEMP]UnBanned Nick " + IP + "." );
- Message( "Admin irc " + user + " [TEMP]UnBanned Nick " + IP + "." );
- }
- }
Add Comment
Please, Sign In to add comment