Guest User

Untitled

a guest
Jul 25th, 2016
65
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 19.69 KB | None | 0 0
  1. const ICOL_WHITE = "\x000300";
  2. const ICOL_BLACK = "\x000301";
  3. const ICOL_BLUE = "\x000302";
  4. const ICOL_GREEN = "\x000303";
  5. const ICOL_RED = "\x000304";
  6. const ICOL_BROWN = "\x000305";
  7. const ICOL_PURPLE = "\x000306";
  8. const ICOL_ORANGE = "\x000307";
  9. const ICOL_YELLOW = "\x000308";
  10. const ICOL_LGREEN = "\x000309";
  11. const ICOL_CYAN = "\x000310";
  12. const ICOL_LCYAN = "\x000311";
  13. const ICOL_LBLUE = "\x000312";
  14. const ICOL_PINK = "\x000313";
  15. const ICOL_GREY = "\x000314";
  16. const ICOL_LGREY = "\x000315";
  17. const ICOL = "\x0003";
  18. const ICOL_BOLD = "\x0002";
  19. const ICOL_ULINE = "\x0031";
  20.  
  21. const RED = "[#FF0000]";
  22. const PINK = "[#FF1493]";
  23. const ORANGE = "[#FF8C00]";
  24. const YELLOW = "[#FFD700]";
  25. const PURPLE = "[#9400D3]";
  26. const GREEN = "[#32CD32]";
  27. const LBLUE = "[#1E90FF]";
  28. const BLUE = "[#4682B4]";
  29. const BROWN = "[#8B4513]";
  30. const WHITE = "[#FFFFFF]";
  31. const BLACK = "[#000000]";
  32. const GREY = "[#808080]";
  33. const MSG = "[#AFFF00]";
  34.  
  35. const FBS_NICK = "AC"; // The name of the echo bot
  36. const FBS_BPASS = ""; // The NickServ password of the echo bot
  37. const FBS_SERVER = "94.23.157.172"; // The numerical ip of the irc server - this will join irc.nl.project-apollo.co.uk
  38. const FBS_PORT = 6667; // The port for that irc server
  39. const FBS_CHAN = "#TDCS"; // The channel that you wont your echo bot to join
  40. const FBS_CPASS = ""; // The password for that channel, if there isnt one leave it as "".{
  41.  
  42. class FBSLIST
  43. {
  44. // This is how we are going to store the user level information for each nick currently on the channel
  45. Name = null;
  46. Level = 1;
  47. }
  48.  
  49. function FBSLIST::AddNick( szNick, iAdmin )
  50. {
  51. Name = szNick;
  52. Level = iAdmin;
  53. }
  54.  
  55. function ActivateEcho()
  56. {
  57. print( "Confirming echo bot details..." );
  58. FBS_BOT <- NewSocket( "FBSProcess" );
  59.  
  60. FBS_BOT.Connect( FBS_SERVER, FBS_PORT );
  61. FBS_BOT.SetNewConnFunc( "FBSLogin" );
  62. print( "Bot details confirmed!" );
  63.  
  64. FBS_NICKS <- array( 50, null );
  65. }
  66.  
  67. function DisconnectBots()
  68. {
  69. print( "Disconnecting bot from IRC..." );
  70.  
  71. FBS_BOT.Send( "QUIT " + FBS_NICK + "\n" );
  72. FBS_BOT.Delete();
  73.  
  74. print( FBS_NICK + " has succesfully disconnected from IRC." );
  75. }
  76.  
  77. function FBSLogin()
  78. {
  79. print( "Attempting to set user, nick and mode...." );
  80. // Set the bots name and real name
  81. FBS_BOT.Send( "USER " + FBS_NICK + " 0 * :Death City IRC BOT\n" );
  82. // Set the nick that the bot will use on the irc server
  83. FBS_BOT.Send( "NICK " + FBS_NICK + "\n" );
  84. // Set it so that the network classes the bot as a bot
  85. FBS_BOT.Send( "MODE " + FBS_NICK + " +B\n" );
  86. print( "Task completed successfully." );
  87. }
  88. function FBSProcess( sz )
  89. {
  90. // This function is used to process the raw data that the bot is recieving from the irc server
  91. local raw = split( sz, "\r\n" ), a, z = raw.len(), line;
  92.  
  93. for ( a = 0; a < z; a++ )
  94. {
  95. line = raw[ a ];
  96.  
  97. local FBS_PING = GetTok( line, " ", 1 ), FBS_EVENT = GetTok( line, " ", 2 ), FBS_CHANEVENT = GetTok( line, " ", 3 ),
  98. Count = NumTok( line, " " ), Nick, Command, Prefix, Text;
  99.  
  100. // The most important thing is making sure that the bot stays connected to IRC
  101. if ( FBS_PING ) FBS_BOT.Send( "PONG " + FBS_PING + "\n" );
  102.  
  103. if ( FBS_EVENT == "001" )
  104. {
  105. if ( FBS_BOT )
  106. {
  107. // Identify the bot with services, comment this line if its not registered
  108. FBS_BOT.Send( "PRIVMSG NickServ IDENTIFY " + FBS_BPASS + "\n" );
  109. // Set it so that the network classes the bot as a bot
  110. FBS_BOT.Send( "MODE " + FBS_NICK + " +B\n" );
  111. // Make the bot join the specified channel
  112. FBS_BOT.Send( "JOIN " + FBS_CHAN + " " + FBS_CPASS + "\n" );
  113. EchoMessage( ICOL_GREEN+ICOL_BOLD+">> GTX-Bot has successfully connected to #gtx." );
  114. Message( MSG+"--> GTX-Bot has now re-connected to Generation Trigger-X (GTX) Server." );
  115. // The bot now needs to collect information about users in the channel
  116. print( "Succesfully joined " + FBS_CHAN + "!" );
  117. }
  118. }
  119. else if ( FBS_EVENT == "353" ) FBSSortNicks( sz );
  120. else if ( ( FBS_EVENT == "MODE" ) || ( FBS_EVENT == "NICK" ) || ( FBS_EVENT == "JOIN" ) || ( FBS_EVENT == "PART" ) || ( FBS_EVENT == "QUIT" ) ) FBS_BOT.Send( "NAMES :" + FBS_CHAN + "\n" );
  121. if ( FBS_CHANEVENT == FBS_CHAN )
  122. {
  123. // Grab the nick
  124. Nick = GetTok( line, "!", 1 ).slice( 1 );
  125. // Figure out what the command is
  126. Command = GetTok( line, " ", 4 );
  127. // Figure out what prefix was used
  128. Prefix = Command.slice( 1, 2 );
  129. Command = Command.slice( 1 );
  130.  
  131. // Figure out the text after the command
  132. if ( NumTok( line, " " ) > 4 ) Text = GetTok( line, " ", 5, Count );
  133. else Command = split( Command, "\r\n" )[ 0 ];
  134.  
  135. // Parse the command
  136. /*
  137. if ( ( Prefix == "!" ) && ( Count > 4 ) ) FBSIrcCommand( Nick, Command, Text );
  138. else if ( ( Prefix == "!" ) && ( Count == 4 ) ) FBSIrcCommand( Nick, Command, null );
  139. */
  140. if (Nick && Command && Text) { FBSIrcCommand( Nick, Command, Text ); }
  141. else if (Nick && Command) { FBSIrcCommand( Nick, Command, null ); }
  142. }
  143. }
  144. }
  145. function LevelTag(lvl)
  146. {
  147. lvl = (lvl ? lvl:0);
  148. switch (lvl)
  149. {
  150. case 2:
  151. return "IRC=Mini-Moderator=";
  152. case 3:
  153. return "IRC=Moderator=";
  154. case 4:
  155. return "IRC=Admin=";
  156. case 5:
  157. return "IRC=Head Admin=";
  158. case 6:
  159. return "IRC=Owner=";
  160. default:
  161. return "IRC=User=";
  162. }
  163. }
  164. function lLevelTag(lvl) {
  165. lvl = (lvl ? lvl:0);
  166. switch (lvl) {
  167. case 2:
  168. return "7";
  169. case 3:
  170. return "9";
  171. case 4:
  172. return "6";
  173. case 5:
  174. return "10";
  175. case 6:
  176. return "4";
  177. default:
  178. return "5";
  179. }
  180. }
  181. function FBSIrcCommand( user, cmd, text )
  182. {
  183. // none of this needs to be touched, it is to do with getting channel levels
  184. local NickInfo = FindNick( user ), level, tLevel;
  185.  
  186. if ( NickInfo ) level = NickInfo.Level.tointeger();
  187. //---------------------------------------------------------------------------
  188. if (cmd) {
  189. if (cmd.slice(0,1) == "." && cmd.len() > 1) {
  190. local msg = LevelTag(level) + " " + user + ": " + cmd.slice(1);
  191. if (text) msg = msg + " " + text;
  192. EchoMessage(ICOL_BOLD+lLevelTag(level) + msg);
  193. if (level == 6) Message(RED+msg);
  194. else if (level == 5) Message(BLUE+msg);
  195. else if (level == 4) Message(PURPLE+msg);
  196. else if (level == 3) Message(GREEN+msg);
  197. else if (level == 2) Message(ORANGE+msg);
  198. else Message(BROWN+msg);
  199. }
  200. }
  201.  
  202.  
  203. if ( cmd == "!say" )
  204. {
  205. if ( !text ) EchoMessage( "Error - Syntax: " + cmd + " <text> " );
  206. else
  207. {
  208. if ( level > 3 ) ::IbMessage( "* Admin " + user + ": " + text );
  209. else if ( level == 3 ) ::IbMessage( "* Moderator " + user + ": " + text );
  210. else ::IbMessage( user + ": " + text );
  211. }
  212. }
  213.  
  214. else if ( cmd == "!me" )
  215. {
  216. if ( !text ) EchoMessage( "Error - Syntax: !" + cmd + " <text> " );
  217. else ::IbMessage( user + " " + text );
  218. }
  219.  
  220.  
  221. else if ( cmd == "!players" )
  222. {
  223. local plr, buffer = "", MAX_PLAYERS = GetMaxPlayers();
  224. for( local i=0; i < MAX_PLAYERS; ++i )
  225. {
  226. plr = FindPlayer( i );
  227. if ( plr ) buffer = buffer + " " + plr.Name + "[" + plr.ID + "]";
  228. }
  229. if ( buffer != "" ) EchoMessage( "Online Players: " + strip(buffer) );
  230. EchoMessage( "Total players: " + GetPlayers() );
  231. }
  232.  
  233.  
  234. else if ( ( cmd == "!admin" ) || ( cmd == "!admins" ) )
  235. {
  236. local a = 0, b = null;
  237. while ( a < GetMaxPlayers() )
  238. {
  239. local plr = GetPlayer( a );
  240. if ( plr )
  241. {
  242. local lvl = GetLevel( plr );
  243.  
  244. if ( lvl >= 2 )
  245. {
  246. if ( b ) b = b + " - " + plr.Name + " ";
  247. else b = plr.Name + " ";
  248. }
  249. }
  250. a ++;
  251. }
  252. if ( b ) { EchoMessage( ICOL_BLUE + "*--> Admins Online: " + b ); }
  253. else EchoMessage( ICOL_RED + "No Admins Online." );
  254. }
  255.  
  256.  
  257. else if ( cmd == "!ping" )
  258. {
  259. if ( !text ) EchoMessage( "Error - Syntax: " + cmd + " <Nick/ID> " );
  260. else
  261. {
  262. local plr = GetPlayer( GetTok( text, " ", 1 ) );
  263. if ( !plr ) EchoMessage( "Invalid Player..." );
  264. IbMessage( "" + plr.Name + "'s Ping: " + plr.Ping + ". " );
  265. }
  266. }
  267.  
  268.  
  269. else if ( cmd == "!server" )
  270. {
  271. EchoMessage( ICOL_PURPLE + "Server Name: " + GetServerName() );
  272. EchoMessage( ICOL_ORANGE + "Game-Mode: " + GetGamemodeName() );
  273. EchoMessage( ICOL_BLACK + "Map: " + GetMapName() );
  274. EchoMessage( ICOL_PINK + "Player Slots: " + GetMaxPlayers() );
  275. }
  276.  
  277.  
  278. else if ( cmd == "!script" )
  279. {
  280. EchoMessage( ICOL_PURPLE + "Server Is Scripted By :- [MRDK]" );
  281. EchoMessage( ICOL_ORANGE + "Script Version: TDC v-0.4" );
  282. }
  283.  
  284. else if ( cmd == "!country" )
  285. {
  286. if ( !text ) EchoMessage( "Error - !country <Nick/ID>." );
  287. else
  288. {
  289. local plr = GetPlayer( GetTok( text, " ", 1 ) );
  290. if ( !plr ) EchoMessasge( "Error: Invalid Player." );
  291. local IP = plr.IP;
  292. local country = geoip_country_name_by_addr(plr.IP);
  293. EchoMessage( "" + plr + "'s Country: " + country + ". [" + geoip_country_code_by_addr(plr.IP) + "]" );
  294. }
  295. }
  296.  
  297.  
  298. else if ( cmd == "!lvl" )
  299. {
  300. if ( !text ) EchoMessage( "Error - !lvl <Nick/ID>." );
  301. else
  302. {
  303. local plr = GetPlayer( GetTok( text, " ", 1 ) ), le = GetLevel( plr );
  304. if ( !plr ) EchoMessage( user, "Error: Invalid Player." );
  305. EchoMessage( "" + plr + "'s Level:[ " + GetLevel( plr ) + " ] Group:[ " + LevelTag( plr ) + " ]" );
  306. }
  307. }
  308.  
  309.  
  310. else if ( cmd == "!arm" )
  311. {
  312. if ( !text ) EchoMessage("Error - Syntax: " + cmd + " <Nick/ID>");
  313. else
  314. {
  315. local plr = GetPlayer( GetTok( text, " ", 1 ) );
  316. if ( !plr ) EchoMessage("Error - Invalid Nick/ID");
  317. EchoMessage("["+plr.ID+"] "+plr+" Armour:[ "+plr.Armour+"'% ]");
  318. }
  319. }
  320.  
  321.  
  322. else if ( cmd == "!hp" )
  323. {
  324. if ( !text ) EchoMessage("Error - Syntax: " + cmd + " <Nick/ID>");
  325. else
  326. {
  327. local plr = GetPlayer( GetTok( text, " ", 1 ) );
  328. if ( !plr ) EchoMessage("Error - Invalid Nick/ID");
  329. EchoMessage("["+plr.ID+"] "+plr+" Health:[ "+plr.Health+"'% ]");
  330. }
  331. }
  332.  
  333.  
  334. else if ( ( cmd == "!cmds" ) || ( cmd == "!commands" ) )
  335. {
  336. EchoMessage( ICOL_ORANGE + " !hp, !arm, !say, !me, !players, !admins, !script, !lvl, !ping, !server, !country ." );
  337. }
  338. // Admin Cmds
  339. else if ( ( cmd == "!acmds" ) || ( cmd == "!admincmds" ) )
  340. {
  341. if ( level < 3 ) EchoNotice( user, ICOL_RED + "Error - Your level is not high enough to use that command." );
  342. else EchoNotice( user, ICOL_BLACK + " !exe, !getip, !ann, !freeze, !unfreeze, !annall, !slap, !drown, !kill, !mute" );
  343. }
  344.  
  345. else if ( cmd == "!drown" )
  346. {
  347. if ( level < 3 ) EchoNotice( user, ICOL_RED + "Error - Your level is not high enough to use that command." );
  348. else if ( !text ) EchoNotice( user, ICOL_RED + "Error - Syntax: " + cmd + " <Nick/ID> <Reason> ");
  349. else
  350. {
  351. local plr = GetPlayer( GetTok( text, " ", 1 ) );
  352. if ( !plr ) EchoNotice( user, "Error - Unknown player." );
  353. else
  354. {
  355. local msg = GetTok( text, " ", 2, NumTok( text, " " ) );
  356. if ( !msg ) EchoNotice( user, "Error - Invalid format." );
  357. else
  358. {
  359. EchoMessage( ICOL_BLACK + "Drowned Player:[ " + plr.Name + " ]. Reason:[ " + msg + " ]" );
  360. Message( "Admin " + user + " has drowned " + plr.Name + ". Reason: " + msg + "." );
  361. plr.Pos = Vector( 283.521 , -1574.3 , 7.19846 );
  362. }
  363. }
  364. }
  365. }
  366.  
  367.  
  368. else if ( cmd == "!kill" )
  369. {
  370. if ( level < 3 ) EchoNotice( user, ICOL_RED + "Error - Your level is not high enough to use that command." );
  371. else if ( !text ) EchoNotice( user, ICOL_RED + "Error - Syntax: " + cmd + " <Nick/ID> <Reason> ");
  372. else
  373. {
  374. local plr = GetPlayer( GetTok( text, " ", 1 ) );
  375. if ( !plr ) EchoNotice( user, "Error - Unknown player." );
  376. else
  377. {
  378. local msg = GetTok( text, " ", 2, NumTok( text, " " ) );
  379. if ( !msg ) EchoNotice( user, "Error - Invalid format." );
  380. else
  381. {
  382. EchoMessage( ICOL_BLACK + "Killed Player:[ " + plr.Name + " ]. Reason:[ " + msg + " ]" );
  383. Message( "Admin " + user + " has killed " + plr.Name + ". Reason: " + msg + "." );
  384. plr.Pos = plr.Pos
  385. plr.Health = 0;
  386. }
  387. }
  388. }
  389. }
  390.  
  391.  
  392. else if ( cmd == "!slap" )
  393. {
  394. if ( level < 3 ) EchoNotice( user, ICOL_RED + "Error - Your level is not high enough to use that command." );
  395. else
  396. {
  397. local plr = GetPlayer( GetTok( text, " ", 1 ) );
  398. if ( !plr ) EchoNotice( user, "Error - Invalid player." );
  399. IbMessage( "Admin " + user + " has slapped " + plr.Name + "." );
  400. plr.Health -= 20;
  401. }
  402. }
  403.  
  404. else if ( cmd == "!ann" )
  405. {
  406. if ( level < 3 ) EchoNotice( user, ICOL_RED + "Error - Your level is not high enough to use that command." );
  407. else if ( !text ) EchoNotice( user, ICOL_RED + "Error - Syntax: " + cmd + " <Nick/ID/all> <Message> ");
  408. else if (GetTok( text, " ", 1 ).tolower() =="all")
  409. {
  410. local msg = GetTok( text, " ", 2, NumTok( text, " " ) );
  411. AnnounceAll( msg );
  412. EchoMessage( ICOL_BLACK + "Sent Announcement:[ " + msg + " ] to all players" );
  413. }
  414. else
  415. {
  416. local plr = GetPlayer( GetTok( text, " ", 1 ) );
  417. if ( !plr ) EchoNotice( user, "Unknow player." );
  418. else
  419. {
  420. local msg = GetTok( text, " ", 2, NumTok( text, " " ) );
  421. Announce( msg, plr, 3 );
  422. EchoMessage( ICOL_BLACK + "Sent Announcement:[ " + msg + " ] to:[ " + plr.Name + " ]" );
  423. }
  424. }
  425. }
  426.  
  427.  
  428. else if ( cmd == "!annall" )
  429. {
  430. if ( level < 3 ) EchoNotice( user, ICOL_RED + "Error - Your level is not high enough to use that command." );
  431. else if ( !text ) EchoNotice( user, ICOL_RED + "Error Syntax: " + cmd + " <Message>");
  432. else
  433. {
  434. local msg = GetTok( text, " ", 2,NumTok( text, " "));
  435. AnnounceAll( text, 3);
  436. EchoMessage( ICOL_BLACK + " " + user + " Sent Announcement to all players in game. Message:[ " + text + " ]" );
  437. }
  438. }
  439.  
  440.  
  441. else if ( cmd == "!freeze" )
  442. {
  443. if ( level < 3 ) EchoNotice( user, ICOL_RED + "Error - Your level is not high enough to use that command." );
  444. else if ( !text ) EchoNotice( user, ICOL_RED + "Error - Syntax: " + cmd + " <Nick/ID> <Reason> ");
  445. else
  446. {
  447. local plr = GetPlayer( GetTok( text, " ", 1 ) );
  448. if ( !plr ) EchoNotice( user, "Error - Unknow player." );
  449. else
  450. {
  451. local msg = GetTok( text, " ", 2, NumTok( text, " " ) );
  452. if ( !msg ) EchoNotice( user, "Error - Invalid format." );
  453. else
  454. {
  455. EchoMessage( ICOL_BLACK + "Freezed Player:[ " + plr.Name + " ]. Reason:[ " + msg + " ]" );
  456. Message( "Admin " + user + " has frozen " + plr.Name + ". Reason: " + msg + "." );
  457. plr.IsFrozen = true;
  458. }
  459. }
  460. }
  461. }
  462.  
  463.  
  464. else if ( cmd == "!mute" )
  465. {
  466. if ( level < 3 ) EchoNotice( user, ICOL_RED + "Error - Your level is not high enough to use that command." );
  467. else if ( !text ) EchoNotice( user, ICOL_RED + "Error - Syntax: " + cmd + " <Nick/ID> <Reason> ");
  468. else
  469. {
  470. local plr = GetPlayer( GetTok( text, " ", 1 ) );
  471. if (!plr) EchoNotice( user, " Error - Unknown player" );
  472. else
  473. {
  474. local msg = GetTok( text, " ", 2, NumTok( text, " " ) );
  475. if ( !msg ) EchoNotice( user, "Error - Invalid format." );
  476. else
  477. {
  478. EchoMessage( ICOL_BLACK + "Muted Player:[ " + plr.Name + " ]. Reason:[ " + msg + " ]" );
  479. Message( "Admin " + user + " has muted " + plr.Name + " ]. Reason: " + msg + "." );
  480. plr.IsMuted = true;
  481. }
  482. }
  483. }
  484. }
  485.  
  486. else if ( cmd == "!unmute" )
  487. {
  488. if ( level < 3 ) EchoNotice( user, ICOL_RED + "Error - Your level is not high enough to use that command." );
  489. else if ( !text ) EchoNotice( user, ICOL_RED + " Error - Syntax: !unmute <Nick/ID>" );
  490. else
  491. {
  492. local plr = GetPlayer( GetTok( text, " ", 1 ) );
  493. if (!plr) EchoNotice( user, " Error - Unknown Player" );
  494. else
  495. {
  496. EchoMessage( ICOL_BROWN + " Admin " + user + " has un-muted Player " + plr.Name + "." );
  497. Message( "Admin " + user + " has un-muted " + plr.Name + "." );
  498. plr.IsMuted = false;
  499. }
  500. }
  501. }
  502.  
  503.  
  504. else if ( cmd == "!unfreeze" )
  505. {
  506. if ( level < 3 ) EchoNotice( user, ICOL_RED + " Error - Your level is not high enough." );
  507. else if ( !text ) EchoNotice( user, ICOL_RED + " Error - Syntax: !unfreeze <Nick/ID>" );
  508. else
  509. {
  510. local plr = GetPlayer( GetTok( text, " ", 1 ) );
  511. if (!plr) EchoNotice( user, " Error - Unknown Player" );
  512. else
  513. {
  514. EchoMessage( ICOL_BLUE + "Admin " + user + " has un-frozen " + plr.Name + "." );
  515. Message( " **Admin " + user + " has un-frozen " + plr.Name + "." );
  516. plr.IsFrozen = false;
  517. }
  518. }
  519. }
  520.  
  521.  
  522. else if( cmd == "!exe" )
  523. {
  524. if ( !text ) EchoMessage( ICOL_RED + "Error - Syntax: !exec <Squirrel code>" );
  525. else if( level < 6 ) EchoNotice( user, ICOL_RED + "You have to be an admin to use such commands." );
  526. else
  527. {
  528. try
  529. {
  530. local script = compilestring( text );
  531. if(script)
  532. {
  533. script();
  534. EchoMessage( "4 command executed successfully!" );
  535. }
  536. else EchoMessage( "4 error!" );
  537.  
  538. }
  539. catch(e) EchoMessage( "Error:" + e );
  540. }
  541. }
  542.  
  543.  
  544. else if ( cmd == "!getip")
  545. {
  546. if ( !text ) EchoMessage( ICOL_RED + "Error - Syntax: !getip <Nick/ID>" );
  547. else if( level < 3 ) EchoNotice( user, ICOL_RED + "You have to be an admin to use such commands." );
  548. else
  549. {
  550. local plr = GetPlayer( GetTok( text, " ", 1 ) );
  551. if (!plr) EchoNotice( user, " Error - Unknown Player" );
  552. else
  553. {
  554. EchoNotice( user, ICOL_BLUE + " " + plr.Name + " IP:[ " + plr.IP + "]." );
  555. }
  556. }
  557. }
  558. }
  559.  
  560. function EchoNotice( nick, text )
  561. {
  562. // Send A notice :)
  563. FBS_BOT.Send( "NOTICE " + nick + " " + text + "\n" );
  564. }
  565.  
  566. function EchoMessage( text )
  567. {
  568. // This is used for events such as a player joining
  569. // EchoMessage( "** [" + player.ID + "] " + player + " has joined the server." );
  570. FBS_BOT.Send( "PRIVMSG " + FBS_CHAN + " " + text + "\n" );
  571. }
  572.  
  573. /* The following functions below are to do with parsing nick information and levels
  574. DO NOT TOUCH ANYTHING BELOW THIS LINE.......EVER!
  575. */
  576.  
  577. function FBSSortNicks( szList )
  578. {
  579. local a = NumTok( szList, " " );
  580. local NickList = GetTok( szList, " ", 6, a ), i = 1;
  581.  
  582. FBS_NICKS <- array( 50, null );
  583.  
  584. while( GetTok( NickList, " ", i ) != "366" )
  585. {
  586. local levelnick = GetTok( NickList, " ", i ), nick = levelnick.slice( 1 ), level = levelnick.slice( 0, 1 );
  587.  
  588. if ( level == ":" ) { level = nick.slice( 0, 1 ); nick = nick.slice( 1 ); }
  589.  
  590. if ( level == "+" ) AddNewNick( nick, 2 );
  591. else if ( level == "%" ) AddNewNick( nick, 3 );
  592. else if ( level == "@" ) AddNewNick( nick, 4 );
  593. else if ( level == "&" ) AddNewNick( nick, 5 );
  594. else if ( level == "~" ) AddNewNick( nick, 6 );
  595. else AddNewNick( nick, 1 );
  596. i ++;
  597. }
  598. }
  599.  
  600. function AddNewNick( szName, iLevel )
  601. {
  602. local i = FindFreeNickSlot();
  603.  
  604. if ( i != -1 )
  605. {
  606. FBS_NICKS[ i ] = FBSLIST();
  607. FBS_NICKS[ i ].AddNick( szName, iLevel );
  608. }
  609. }
  610.  
  611. function FindFreeNickSlot()
  612. {
  613. for ( local i = 0; i < FBS_NICKS.len(); i++ )
  614. {
  615. if ( !FBS_NICKS[ i ] ) return i;
  616. }
  617. return -1;
  618. }
  619.  
  620. function FindNick( szName )
  621. {
  622. for ( local i = 0; i < FBS_NICKS.len(); i++ )
  623. {
  624. if ( FBS_NICKS[ i ] )
  625. {
  626. if ( FBS_NICKS[ i ].Name == szName ) return FBS_NICKS[ i ];
  627. }
  628. }
  629. return null;
  630. }
Add Comment
Please, Sign In to add comment