terrorstyles

Hotdogcat TempBan System

Jul 18th, 2017
152
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 6.19 KB | None | 0 0
  1. //tempban script by hotdogcat
  2. Edited by TerrorStyles ( PrivMessages, Kick Errors, EchoMessages )
  3. //put these funcions in onscriptload
  4.  
  5. function onScriptLoad()
  6. {
  7. tb <- ConnectSQL( "Tempban.db" );
  8. NewTimer( "tunban", 3600000, 0 );
  9. NewTimer( "ct", 3600, 1 );
  10. }
  11.  
  12. //put this in onplayerjoin
  13. function onPlayerJoin( player )//i suggest to remove autokick from here if you use timers in onplayerjoin
  14. {
  15.  
  16. if ( tban( player ) == 1 ) Message(" " + player.Name + " kicked reason: Temp-Banned");
  17. if ( tban( player ) == 1 ) player.Kick();
  18. }
  19.  
  20.  
  21. //now some functions
  22.  
  23.  
  24. function ct( )//this function auto-create tempban table in your database
  25. {
  26. QuerySQL( tb, "CREATE TABLE IF NOT EXISTS Tempban ( IP VARCHAR(25), Name TEXT, Expires NUMERIC, Admin TEXT, Reason TEXT, Hours NUMERIC, time TEXT )" );
  27. }
  28.  
  29. function tunban( )//this function decrase 1 hour from tempban, if there are 0 hours left server remove the ban.
  30. {
  31.  
  32. QuerySQL( tb, "UPDATE Tempban SET Expires=(Expires-1) WHERE IP" );
  33. QuerySQL( tb, "DELETE FROM Tempban WHERE Expires='0'" );
  34.  
  35. }
  36.  
  37. function PrivMessages( text, player )
  38. {
  39. ClientMessage( "** pm >> " + text, player, 255, 165, 0);
  40. }
  41. function tban( p ) //this check if player is banned or not.
  42. {
  43. local q = QuerySQL( tb, "SELECT * FROM Tempban WHERE IP='" + p.IP + "'" );
  44. local IP = GetSQLColumnData( q, 0 );
  45. if ( IP ) return 1;
  46. else return 0;
  47. }
  48.  
  49. //some commands(game)
  50.  
  51. else if ( cmd == "tempban" )
  52. {
  53.  
  54. if ( !text ) PrivMessages( "Use / tempban <player> <hours> <reason>", player );
  55.  
  56. else
  57. {
  58. local plr = GetPlayer( GetTok( text, " ", 1 ) );
  59.  
  60. local t = GetTok( text, " ", 2);
  61. local reason = GetTok( text, " ", 3 NumTok( text, " " ) );
  62. if (!IsNum(t)) PrivMessages("hours Must Be In Numbers..",player);
  63.  
  64. if ( reason == null ) PrivMessages( "Insert the reason", player );
  65. if ( t == null ) PrivMessages( "Insert the time", player );
  66. if ( !plr ) PrivMessages( "Invalid Nick/ID.", player );
  67. if (!IsNum(t)) t = "1";
  68. if ( reason == null ) reason = "no info.";
  69.  
  70. else
  71. {
  72. Message( "Admin " + player + " Temp-Banned:[ " + plr + " ], Reason [ " + reason + " ] Time Left:[ " + t + " Hours, 0 Minutes, 0 Seconds ]" );
  73. QuerySQL( tb, "INSERT INTO Tempban ( IP, Name, Expires, Admin, Reason, hours, time ) VALUES ( '" + plr.IP + "', '" + plr.Name + "', '" + t + "', '" + player.Name + "', '" + reason + "', '" + t + "','" + GetFullTime() + "' )" );
  74.  
  75.  
  76. plr.Kick();
  77.  
  78. }
  79. }
  80. }
  81.  
  82. else if ( cmd == "tempbanip" )
  83. {
  84.  
  85. if ( !text ) PrivMessages( "Use / tempbanip <nick> <ip> <hours> <reason> ", player );
  86.  
  87. else
  88. {
  89. local nick = GetTok( text, " ", 1);
  90. local ip = GetTok( text, " ", 2);
  91. local t = GetTok( text, " ", 3);
  92. local reason = GetTok( text, " ", 4 NumTok( text, " " ) );
  93. if ( nick == null ) PrivMessages( "Error - insert nick", player );
  94. if ( ip == null ) PrivMessages( "Error - insert ip", player );
  95. if ( t == null ) PrivMessages( "Error - insert hours", player );
  96. if ( reason == null ) PrivMessages( "Reason is needed", player );
  97. if (!IsNum(t)) t = "1";
  98. if ( reason == null ) reason = "no info.";
  99.  
  100.  
  101.  
  102.  
  103. else
  104. {
  105.  
  106.  
  107. Message( "Admin " + player + " Temp-Banned:[ " + nick + " ], IP: [ " + IP + " ], Reason [ " + reason + " ] Duration:[ " + t + " Hours , 0 Minutes, 0 Seconds ]" );
  108.  
  109. QuerySQL( tb, "INSERT INTO Tempban ( IP, Name, Expires, Admin, Reason, hours, time ) VALUES ( '" + ip + "', '" + nick + "', '" + t + "', '" + player.Name + "', '" + reason + "', '" + t + "','" + GetFullTime() + "' )" );
  110.  
  111. }
  112. }
  113. }
  114.  
  115.  
  116. else if ( cmd == "days" )
  117. {
  118.  
  119. if ( !text ) PrivMessages( "Use / days", player );
  120.  
  121. else
  122. {
  123. local hours = GetTok( text, " ", 1);
  124. local time = hours.tointeger() * 24;
  125. PrivMessages( " " + hours + " days are " + time + " hours.", player );
  126. }
  127. }
  128.  
  129. else if ( cmd == "tunban" )
  130. {
  131. if ( !text ) PrivMessages( "Use / unban <ip> ", player );
  132. else
  133. {
  134. local ip = GetTok( text, " ", 1);
  135. QuerySQL( tb, "DELETE FROM Tempban WHERE IP='" + ip + "'" );
  136. Message( "Admin " + player.Name + " removed tempban of ip " + ip + "." );
  137.  
  138. }
  139. }
  140.  
  141.  
  142. //Irc commands (fbs-echo)
  143.  
  144. else if ( cmd == "!tempbanip" )
  145. {
  146. if ( level < 4 ) EchoNotice( user, ICOL_RED + " - Your Level is not Enough." );
  147. else if ( !text ) EchoNotice( user, ICOL_RED + "Error - Syntax: " + cmd + " <Nick> <IP> <Hours> <Reason>");
  148. else
  149. {
  150. local nick = GetTok( text, " ", 1);
  151. local ip = GetTok( text, " ", 2);
  152. local t = GetTok( text, " ", 3);
  153. local reason = GetTok( text, " ", 4 NumTok( text, " " ) );
  154. if ( nick == null ) EchoNotice( user, "Insert an valid nick" );
  155. if ( ip == null ) EchoNotice( user, "Insert ip" );
  156. if ( t == null ) EchoNotice( user, "Insert hours" );
  157. if ( reason == null ) EchoNotice( user, "Insert reason" );
  158. if ( reason == null ) reason = "no info.";
  159. if (!IsNum(t)) t = "1";
  160. else
  161. {
  162. Message( "Admin Irc " + user + " Temp-Banned:[ " + nick + " ], IP [ " + ip + " ], Reason [ " + reason + " ] Duration:[ " + t + " Hours, 0 Minutes, 0 Seconds ]" );
  163. QuerySQL( tb, "INSERT INTO Tempban ( IP, Name, Expires, Admin, Reason, hours, time ) VALUES ( '" + ip + "', '" + nick + "', '" + t + "', '" + user + "', '" + reason + "', '" + t + "','" + GetFullTime() + "' )" );
  164. }
  165. }
  166. }
  167.  
  168. else if ( cmd == "!tunban" )
  169. {
  170. if ( level < 4 ) EchoNotice( user, ICOL_RED + "Error - Your Level is not Enough." );
  171. else if ( !text ) EchoNotice( user, ICOL_RED + "Error - Syntax: " + cmd + " <nick>");
  172. else
  173. {
  174. local nick = GetTok( text, " ", 1);
  175. QuerySQL( tb, "DELETE FROM Tempban WHERE Name='" + nick + "'" );
  176. EchoMessage( "Admin irc " + user + " [TEMP]UnBanned Nick " + nick + "." );
  177. Message( "Admin irc " + user + " [TEMP]UnBanned Nick " + nick + "." );
  178. }
  179. }
  180.  
  181. else if ( cmd == "!tunbanip" )
  182. {
  183. if ( level < 4 ) EchoNotice( user, ICOL_RED + "Error - Your Level is not Enough." );
  184. else if ( !text ) EchoNotice( user, ICOL_RED + "Error - Syntax: " + cmd + " <ip>");
  185. else
  186. {
  187. local IP = GetTok( text, " ", 1);
  188. QuerySQL( tb, "DELETE FROM Tempban WHERE Name='" + IP + "'" );
  189. EchoMessage( "Admin irc " + user + " [TEMP]UnBanned Nick " + IP + "." );
  190. Message( "Admin irc " + user + " [TEMP]UnBanned Nick " + IP + "." );
  191. }
  192. }
Add Comment
Please, Sign In to add comment