Advertisement
Guest User

Untitled

a guest
May 30th, 2017
88
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. ({
  2. /** Server Events **/
  3. serverStartUp : function() {
  4.     this.afterNewMessage("Script Check: OK");
  5.     return; }
  6. ,
  7. afterNewMessage : function (message) {
  8.     if (message == "Script Check: OK") {
  9.         sys.sendAll("~~Server~~: Scripts were updated.");
  10.         if (typeof floodcount == "undefined") {
  11.             floodcount = new Array(); }
  12.         if (typeof mailWait == "undefined") {
  13.             mailWait = new Array(); }
  14.         if (typeof inBattle == "undefined") {
  15.             inBattle = new Array();}
  16.         if (typeof hyperMode == "undefined") {
  17.             hyperMode = new Array();}
  18.         if (typeof numUsers == "undefined") {
  19.             numUsers = 0}
  20.         if (typeof ver == 'undefined') {
  21.             ver = 1;
  22.             print('Thank you for loading Astruvis\' scripts! If this is the first time loading this script please type /debug as an admin while there are no pending connections, or restart the server.'); }
  23.             if  (typeof password == 'undefined') {
  24.                 password = new Array(); }
  25.         if (typeof serverpass == 'undefined') {
  26.             serverpass = ''; }
  27.         if (typeof rank == "undefined") {
  28.             rank = new Array();
  29.             rank[0] = 'a user';
  30.             rank[1] = 'a moderator';
  31.             rank[2] = 'an admin';
  32.             rank[3] = 'an owner';
  33.             rank[4] = 'a moderator(invisible)';
  34.             rank[5] = 'an admin(invisible)';
  35.             rank[6] = 'an owner(invisible)'; }
  36.         if (typeof(variablesset) == "undefined"){
  37.             variablesset = 1;
  38.             tourmode = 0;
  39.             border = "»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»:";}
  40.         }
  41.     if (message.toLowerCase().indexOf(' changed their team, and their name to ') != -1) {
  42.         var eventsrc = new Array();
  43.         eventsrc = message.split(' changed their team, and their name to ');
  44.         this.beforeTeamChange(sys.id(eventsrc[0]),eventsrc[1]); }
  45.     return; }
  46. ,
  47. /** Log in and Out **/
  48. afterLogIn : function(src) {
  49.     numUsers += 1;
  50.     /** Impersonation Check **/
  51.     if (sys.name(src).toLowerCase().indexOf('server') != -1 || sys.name(src).toLowerCase().indexOf('admin') != -1 || sys.name(src)[0] == '#' || sys.name(src)[0] == '@' || sys.name(src)[0] == '&' || sys.name(src)[0] == '.' || sys.name(src)[0] == '-' && sys.auth(src) == 0) {
  52.         sys.sendMessage(src,'Invalid name. Change your name.');
  53.         sys.kick(tar);
  54.         return; }
  55.     password[src] = '';
  56.     hyperMode[src] = false;
  57.     inBattle[src] = false;
  58.     mailWait[src] = false;
  59.     floodcount[src] = 0;
  60.     if (sys.auth(src) < 1 && sys.getVal('banned' + sys.ip(src)) == 1) {
  61.         sys.sendAll("~~Server~~: Banned user  " + sys.name(src) + ' (' + sys.ip(src) + ') was kicked!');
  62.         sys.kick(src);
  63.         return; }
  64.     if (sys.auth(src) < 1 && (typeof restrict != "undefined")) {
  65.         sys.sendMessage(src,"~~Server~~: The server is in restricted mode and can only be accesed by staff.");
  66.         sys.kick(src);
  67.         return; }
  68.     var str = '~~Server~~: Server status';
  69.     var muteis = sys.getVal('muted' + sys.ip(src));
  70.     var protis = sys.getVal('protected' + sys.ip(src));
  71.     if (typeof(stop) != "undefined")
  72.         { str += ', battles stopped'; }
  73.     if (typeof(hush) != "undefined")
  74.         { str += ', chat hushed'; }
  75.     if (serverpass != "")
  76.         { str += ', password protected'; }
  77.     if (typeof restrict != "undefined")
  78.         { str += ', restricted'; }
  79.     if (str == '~~Server~~: Server status') {
  80.     str = '~~Server~~: Server status, normal' }
  81.     str = str + '.';
  82.     sys.sendMessage(src,str);
  83.     str = '~~Server~~: Your status';
  84.     if (muteis == 1)
  85.         { str += ', muted'; }
  86.     if (protis == 1)
  87.         { str += ', protected'; }
  88.     if (muteis != 1 && protis != 1)
  89.         { str += ', normal'; }
  90.     str += '.';
  91.     sys.sendMessage(src,str +' You are ' + rank[sys.auth(src)] +'.');
  92.     sys.sendMessage(src,'~~Server~~: Type /cmdlist for the commands. Type /rules for the rules');
  93.     if (serverpass != '') {
  94.         if (sys.auth(src) == 0)  {
  95.             sys.sendMessage(src,'~~Server~~: The server is password protected, please enter the password using /pass password.'); }
  96.         else {
  97.             sys.sendAll('~~Server~~: '+sys.name(src)+' has joined!'); }
  98.         }
  99.     if (sys.auth(src) >= 1) {
  100.         var cnt = numUsers;
  101.         var user = 0;
  102.         while(user < cnt && user < 300)
  103.             { if (sys.loggedIn(user) == true) {
  104.                 if (sys.auth(user) >= 1) {
  105.                     sys.sendMessage(src,'~~Server~~: Online staff member ' + sys.name(user) + ' is ' +rank[sys.auth(user)]); }
  106.                 }
  107.             else {
  108.                 cnt += 1;}
  109.             user += 1; }
  110.         }
  111.     sys.sendMessage(src,"~~MailBox~~: You have " + (sys.getVal('msgque' + sys.name(src).toLowerCase()).split('+').length - 1) + " messages in your inbox, use /readmail to view.");
  112.     /** Lutra's Tourn Script **/
  113.     if (tourmode == 1){
  114.         receiver = src;
  115.         this.tourdisplay();
  116.         sys.sendMessage(src,"~~Server~~:  " + tourcount + " space(s) are left!");
  117.         return;}
  118.     if (tourmode == 2){
  119.         sys.sendMessage(src, "~~Server~~: A tournament is currently running.");
  120.     return; }
  121.     }
  122. ,
  123. afterLogOut : function (src) {
  124.     numUsers -= 1;
  125.     return;
  126.     }
  127. ,
  128. beforeTeamChange : function(src,old) {
  129.     /** Impersonation Check **/
  130.     if (sys.name(src).toLowerCase().indexOf('server') != -1 || sys.name(src).toLowerCase().indexOf('admin') != -1 || sys.name(src)[0] == '#' || sys.name(src)[0] == '@' || sys.name(src)[0] == '&' || sys.name(src)[0] == '.' || sys.name(src)[0] == '-' && sys.auth(src) == 0) {
  131.         sys.sendMessage(src,'Invalid name. Change your name.');
  132.         sys.kick(tar);
  133.         return; }
  134.     }
  135. ,
  136. /** Moderation Menu **/
  137. unmute : function(tar){
  138.     sys.removeVal('muted' + sys.ip(tar));
  139.     return; }
  140. ,
  141. beforePlayerKick : function(src,tar) {
  142.     sys.stopEvent();
  143.     if (sys.getVal('protected' + sys.ip(tar)) == 1)
  144.         {sys.sendMessage(src,"~~Server~~: " + sys.name(tar) + " is protected and can not be kicked.");
  145.         return; }
  146.     if (sys.auth(tar) > 0)
  147.         {sys.sendMessage(src,"~~Server~~: Moderators and above can not be kicked.");
  148.         return; }
  149.     if (sys.auth(src) <= 3) {
  150.     sys.sendAll("~~Server~~: " + sys.name(tar) + " was kicked by " + sys.name(src) + "!"); } else { sys.sendAll("~~Server~~: " + sys.name(tar) + " was mysteriously kicked!"); }
  151.     sys.kick(tar);
  152.     return; }
  153. ,
  154. beforePlayerBan : function(src,tar) {
  155.     sys.stopEvent();
  156.     if (sys.auth(src) == 4) {
  157.     return; }
  158.     if (sys.getVal('protected' + sys.ip(tar)) == 1)
  159.         {sys.sendMessage(src,"~~Server~~: " + sys.name(tar) + " is protected and can not be banned.");
  160.         return; }
  161.     if (sys.auth(tar) > 0)
  162.         {sys.sendMessage(src,"~~Server~~: Moderators and above can not be banned.");
  163.         return; }
  164.     if (sys.auth(src) <= 3) {
  165.         sys.sendAll("~~Server~~: " + sys.name(tar) + " ("+ sys.ip(tar) + ") was banned for 1 hour by " + sys.name(src) + "!"); }
  166.         else
  167.         { sys.sendAll("~~Server~~: " + sys.name(tar) + " ("+ sys.ip(tar) + ") was mysteriously banned for 1 hour!"); }
  168.     var rnd = sys.rand(1,99999999);
  169.     sys.saveVal('banned' + sys.ip(tar),1);
  170.     sys.saveVal('banchk' + sys.ip(tar),rnd);
  171.     sys.callLater("if (sys.getVal('banchk" + sys.ip(tar) +"') == "+ rnd+ " ) { sys.removeVal('banned" + sys.ip(tar) +"'); (sys.removeVal('banchk" + sys.ip(tar) +"'); sys.sendAll('~~Server~~: " + sys.name(tar) + " is no longer banned.'); }",3600);
  172.     var cnt = numUsers;
  173.     var user = 0;
  174.     while(user < cnt)
  175.         {if (sys.loggedIn(user) == true) {
  176.             if (sys.ip(tar) == sys.ip(user) && sys.auth(user) < 1)
  177.                  { sys.kick(user);}
  178.             } else {
  179.                 cnt += 1;}
  180.             user += 1;
  181.             }
  182.     sys.kick(tar);
  183.     return; }
  184. ,
  185. /** Battles **/
  186. beforeBattleEnded : function(win, lose, result) {
  187.     inBattle[lose] = false;
  188.     inBattle[win] = false;
  189.     /**if (result == "win" || result == "forfeit") {
  190.     sys.sendAll(sys.name(win) + " won against "+ sys.name(lose)+'.'); } **/
  191.     if (mailWait[win] == true) {
  192.         sys.sendMessage(win,"~~MailBox~~: You have " + (sys.getVal('msgque' + sys.name(win).toLowerCase()).split('+').length - 1) + " messages in your inbox, use /readmail to view.");
  193.         mailWait[win] = false; }
  194.     if (mailWait[lose] == true) {
  195.         sys.sendMessage(lose,"~~MailBox~~: You have " + (sys.getVal('msgque' + sys.name(lose).toLowerCase()).split('+').length - 1) + " messages in your inbox, use /readmail to view.");
  196.         mailWait[lose] = false; }
  197.     if (tourmode == 2 &&  result != "tie"){
  198.         this.tourbattleend(sys.name(win), sys.name(lose));}
  199.     return; }
  200. ,
  201. checkhazards : function(id) {  
  202.     var stealthrock = sys.moveNum('Stealth Rock');
  203.     var toxicspikes = sys.moveNum('Toxic Spikes');
  204.     var spikes = sys.moveNum('Spikes');
  205.     if (sys.hasTeamMove(id,stealthrock) == true || sys.hasTeamMove(id,spikes) == true || sys.hasTeamMove(id,toxicspikes) == true) {
  206.         return(true); } else { return(false); }
  207.     }
  208. ,
  209. beforeBattleMatchup : function(src, tar, clauses) {
  210.     if ( typeof(stop) != "undefined") {
  211.         sys.stopEvent();
  212.         sys.sendMessage(src, "~~Server~~: The battles are stoped.");
  213.         return; }
  214.     var xx = 0;
  215.     if (sys.tier(src) == 'NoHazards' && this.checkhazards(src) == true) {
  216.         sys.sendMessage(src,'~~Server~~: Your team is invalid for that tier, come back with a valid team!');
  217.         sys.kick(src);
  218.         sys.sendAll('~~Server~~: '+sys.name(src)+' was kicked by ~~Server~~');
  219.         xx = 1; }
  220.     if (sys.tier(tar) == 'NoHazards' && this.checkhazards(tar) == true) {
  221.         sys.sendMessage(tar,'~~Server~~: Your team is invalid for that tier, come back with a valid team!');
  222.         sys.kick(tar);
  223.         sys.sendAll('~~Server~~: '+sys.name(tar)+' was kicked by ~~Server~~');
  224.         xx = 1; }
  225.     if (xx) {
  226.     return; }
  227.     inBattle[src] = true;
  228.     inBattle[tar] = true;
  229.     return; }
  230. ,
  231. beforeBattleStarted : function(src, tar, clauses, rated, mode) {
  232.     inBattle[src] = true;
  233.     inBattle[tar] = true;
  234.     return; }
  235. ,
  236. afterBattleStarted: function(src, trgt){
  237.           if (tourmode == 2){
  238.                     var srctier = sys.tier(src).toLowerCase();
  239.                     var trgttier = sys.tier(trgt).toLowerCase();
  240.                     var srcname = sys.name(src);
  241.                     var trgtname = sys.name(trgt);
  242.                     var tourmembershigh = tourmembers.indexOf(srcname);
  243.                     var tourmemberslow = tourmembers.indexOf(trgtname);
  244.                     if (srctier == trgttier && srctier == tourtier && tourmembershigh in tourmembers && tourmemberslow in tourmembers){
  245.                               if (tourmemberslow > tourmembershigh){
  246.                                         var temphigh = tourmemberslow;
  247.                                         tourmemberslow = tourmembershigh;
  248.                                         tourmembershigh = temphigh;
  249.                               }
  250.                               if (tourmemberslow % 2 == 0 && tourmembershigh == tourmemberslow + 1){
  251.                                         tourbattlers.push(srcname);
  252.                                         tourbattlers.push(trgtname);
  253.                               }
  254.                     }
  255.           }
  256. }
  257. ,
  258. beforeChallengeIssued : function(src, tar, clauses) {
  259.     if ( typeof(stop) != "undefined") {
  260.         sys.stopEvent();
  261.         sys.sendMessage(src, "~~Server~~: The battles are stoped.");
  262.         return; }
  263.     if (sys.tier(src) == 'NoHazards' && this.checkhazards(src) == true) {
  264.         sys.sendMessage(src,'~~Server~~: Your team is invalid for that tier, come back with a valid team!');
  265.         sys.kick(src);
  266.         sys.sendAll('~~Server~~: '+sys.name(src)+' was kicked by ~~Server~~.');
  267.         xx = 1; }
  268.     if (sys.tier(tar) == 'NoHazards' && this.checkhazards(tar) == true) {
  269.         sys.sendMessage(tar,'~~Server~~: Your team is invalid for that tier, come back with a valid team!');
  270.         sys.kick(tar);
  271.         sys.sendAll('~~Server~~: '+sys.name(tar)+' was kicked by ~~Server~~.');
  272.         xx = 1; }
  273.         }
  274. ,
  275. /** Other **/
  276. beforePlayerAway : function(src, aa) {
  277.     if (mailWait[src] == 1 && aa == 0) {
  278.         sys.sendMessage(src,"~~MailBox~~: You have " + (sys.getVal('msgque' + sys.name(src).toLowerCase()).split('+').length - 1) + " messages in your inbox, use /readmail to view.");
  279.         mailWait[src] = false; }
  280.     return; }
  281. ,
  282. beforeChatMessage: function(src, message) {
  283.     if (message[0] != '/' && message[0] != '!') {
  284.         /** Hush check **/
  285.         if (sys.auth(src) < 1 && typeof(hush) != "undefined") {
  286.             sys.stopEvent();
  287.             sys.sendMessage(src, "~~Server~~: The chat is hushed.");
  288.             print("Hushed message from " + sys.name(src) + ": " + message);
  289.             return; }
  290.         /** Mute check **/
  291.         if (sys.auth(src) < 1 && sys.getVal('muted' + sys.ip(src)) == 1) {
  292.             sys.stopEvent();
  293.             sys.sendMessage(src, "~~Server~~: You are muted.");
  294.             print("Muted message from " + sys.name(src) + ": " + message);
  295.             return; }
  296.         sys.stopEvent(); /** Stops event to prevent users without the password from viewing **/
  297.         /** Password Check **/
  298.         if (serverpass != password[src] && serverpass != '' && sys.auth(src) == 0) {
  299.             sys.sendMessage(src,'~~Server~~: Please enter the password using /pass password.');
  300.             return; }
  301.         /** Swear Check **/
  302.         var safemsg = message.replace(/fuck/gi,'****').replace(/nazi/gi,'****').replace(/penis/gi,'****').replace(/bitch/gi,'****').replace(/faggot/gi,'****').replace(/vagina/gi,'****').replace(/nigger/gi,'****').replace(/rape/gi,'****');
  303.         if (message != safemsg) {
  304.             print("Filtered message from " + sys.name(src) + ": " + message);
  305.             message = safemsg; }
  306.         /** Flood Check **/
  307.         floodcount[src] += 1;
  308.         sys.callLater('if (floodcount['+src+'] > 0) { floodcount['+src+'] -= 1;}',30);
  309.         if (floodcount[src] > 10 && sys.auth(src) < 1) {
  310.             sys.stopEvent();
  311.             floodcount[src] = 0;
  312.             sys.sendAll("~~Server~~: " + sys.name(src) + " was muted for 5 minutes by ~~Server~~!");
  313.             var rnd = sys.rand(1,9999);
  314.             sys.saveVal('mutechk' + sys.ip(src),rnd);
  315.             sys.callLater("if (sys.getVal('mutechk" + sys.ip(src) +"') == "+ rnd+ " ) { sys.removeVal('muted" + sys.ip(src) +"'); sys.removeVal('mutechk" + sys.ip(src) +"'); sys.sendAll('~~Server~~: " + sys.name(src) + " is no longer muted.'); }",300);
  316.             sys.saveVal('muted' + sys.ip(src),1);
  317.             return; }
  318.         /** Staff Check **/
  319.         var yy = '';
  320.         if (sys.auth(src) == 1) {
  321.             yy = '+'; }
  322.         if (sys.auth(src) == 2 || sys.auth(src) == 3) {
  323.             yy = '~'; }
  324.         if (hyperMode[src] == true && sys.auth(src) != 0) {
  325.             yy = '*** ' + yy; }
  326.         /** Userloop, send messages to users with the password **/
  327.         var cnt = numUsers;
  328.         var user = 0;
  329.         var xx = yy + sys.name(src) +': ' + message;
  330.         print(xx);
  331.         while(user < cnt) {
  332.             if (sys.loggedIn(user) == true) {
  333.                 if (serverpass == password[user] || serverpass == '' || sys.auth(user) > 0) {
  334.                     sys.sendMessage(user,xx); }
  335.             } else {
  336.                 cnt += 1;}
  337.             user += 1; }
  338.         return; }
  339.     /** Commands **/
  340.     if ((message[0] == '/' || message[0] == '!') && message.length > 1)
  341.          {print("Command -- " + sys.name(src) + ": " + message);
  342.         sys.stopEvent();
  343.         var command;
  344.         var commandData;
  345.         var pos = message.indexOf(' ');
  346.         var mcmd = new Array();
  347.         if (pos != -1) {
  348.             command = message.substring(1, pos).toLowerCase();
  349.             commandData = message.substr(pos+1);
  350.             mcmd = commandData.split(':'); }
  351.          else
  352.             { command = message.substr(1).toLowerCase(); }
  353.         var tar = sys.id(mcmd[0]);
  354. /** User Commands **/
  355.     /** Password **/
  356.         if (command == "pass" || command == "password") {
  357.             if (serverpass == '') {
  358.                 sys.sendMessage(src,'~~Server~~: The server is not password protected.');
  359.                 return; }              
  360.             password[src] = commandData;
  361.             if (serverpass != password[src]) {
  362.                 sys.sendMessage(src,'~~Server~~: Bad password, please enter the password using /pass password.');  }
  363.             else {
  364.                 sys.sendAll('~~Server~~: '+sys.name(src)+' has joined!'); }
  365.             return; }
  366.     /** Mail **/
  367.         if (command == "sendmail" || command == "smail" || command == "mail") {
  368.             var mail;
  369.             if (mcmd[1] == undefined) {
  370.             sys.sendMessage(src, "~~MailBox~~: Error: No content! Message was not sent!");
  371.             return; }
  372.             mail = mcmd[1];
  373.             if (mail.indexOf('+') == -1) {
  374.                 sys.saveVal('msgque' + mcmd[0].toLowerCase(),sys.getVal('msgque' + mcmd[0].toLowerCase()) + ' + Message from ' + sys.name(src) + ": " + mail);
  375.                 var rcv = sys.id(mcmd[0]);
  376.                 sys.sendMessage(src, "~~MailBox~~: Message sent to user " + mcmd[0] + "!");
  377.                 if (rcv != undefined) {
  378.                     sys.sendMessage(rcv,"~~MailBox~~: New message, type /readmail to view your inbox.");
  379.                     if (sys.away(rcv) == true || inBattle[rcv] == true) {
  380.                         mailWait[rcv] = true; }
  381.                     }
  382.             } else {
  383.                 sys.sendMessage(src, "~~MailBox~~: Error: The + symbol can not be used in mail! Message was not sent!"); }
  384.             return; }
  385.         if (command == "readmail" || command == "rmail") {
  386.             var msg = new Array();
  387.             msg = sys.getVal('msgque' + sys.name(src).toLowerCase()).split('+');
  388.             var length = (sys.getVal('msgque' + sys.name(src).toLowerCase()).split('+').length - 1);
  389.             sys.sendMessage(src,'~~MailBox~~: Here are your messages:');
  390.             for (i = 1; i <= length; i++)
  391.             {sys.sendMessage(src,msg[i]); }
  392.             sys.sendMessage(src,'~~MailBox~~: End of messages.');  
  393.  
  394.             sys.sendMessage(src,'~~MailBox~~: Use /deletemail to clear your inbox. Use "/sendmail USERNAME:MESSAGE" to send a message to another user.');
  395.             return; }
  396.         if (command == "deletemail" || command == "dmail") {
  397.             sys.removeVal('msgque' + sys.name(src).toLowerCase());
  398.             sys.sendMessage(src, "~~Mailbox~~: Mail deleted!");
  399.             return; }
  400.     /** Lists **/
  401.         if (command == "list" || command == "stafflist" || command == "modlist" || command == "l") {
  402.             if (sys.auth(src) >= 1) {
  403.                 var cnt = numUsers;
  404.                 var user = 0;
  405.                 while(user < cnt && user < 300)
  406.                     { if (sys.loggedIn(user) == true) {
  407.                         if (sys.auth(user) >= 1) {
  408.                             sys.sendMessage(src,'~~Server~~: Online staff member ' + sys.name(user) + ' is ' +rank[sys.auth(user)]); }
  409.                     } else {
  410.                         cnt += 1;}
  411.                     user += 1; }
  412.                 }
  413.             else
  414.                 {var cnt = numUsers;
  415.                 var user = 0;
  416.                 while(user < cnt && user < 300)
  417.                     { if (sys.loggedIn(user) == true) {
  418.                         if (sys.auth(user) >= 1 && sys.auth(user) < 4) {
  419.                             sys.sendMessage(src,'~~Server~~: Online staff member ' + sys.name(user) + ' is ' +rank[sys.auth(user)]); }
  420.                     } else {
  421.                         cnt += 1;}
  422.                     user += 1; }
  423.                 }
  424.         return; }
  425.         if (command == "rules" || command == "rule" || command == "laws") {
  426.             sys.sendMessage(src,"~~Server~~: Here are the commands:");
  427.         if (command == "commands" || command == "command" || command == "cmdlist") {
  428.             sys.sendMessage(src,"~~Server~~: Here are the commands:");
  429.             sys.sendMessage(src,"*** User commands ***");
  430.             sys.sendMessage(src,"~~Server~~: The command '/cmdlist': Lists commands.");
  431.             sys.sendMessage(src,"~~Server~~: The command '/sendmail user:message': Sends mail to another player.");
  432.             sys.sendMessage(src,"~~Server~~: The command '/readmail': Shows your mail.");
  433.             sys.sendMessage(src,"~~Server~~: The command '/deletemail': Deletes all your mail.");
  434.             sys.sendMessage(src,"~~Server~~: The command '/list': Lists online staff members.");
  435.             sys.sendMessage(src,"~~Server~~: The command '/pass password': Allows you to join a password protected server if you know the password.");
  436.             sys.sendMessage(src,"~~Server~~: The command '/join': Allows you to join a tournament.");
  437.             sys.sendMessage(src,"~~Server~~: The command '/viewround': Allows you to view a tournament round pairings.");      
  438.             if (sys.auth(src) >= 1) {
  439.             sys.sendMessage(src,"*** Moderator Commands ***"); 
  440.             sys.sendMessage(src,"~~Server~~: The command '/info': Gives various information about a user.");
  441.             sys.sendMessage(src,"~~Server~~: The command '/writenote user:note': Writes a note to a users account.");
  442.             sys.sendMessage(src,"~~Server~~: The command '/viewnotes user': Reads notes from a users account.");
  443.             sys.sendMessage(src,"~~Server~~: The command '/removenotes user': Removes notes from a users account.");
  444.             sys.sendMessage(src,"~~Server~~: The command '/mute user:time:unit': Bans a user for time units, time must be a number, and unit must be a unit of time.");
  445.             sys.sendMessage(src,"~~Server~~: Note: You do not have to input a time or unit, it will be 5 minutes by deafault. '/mute user:forever' also works.");
  446.             sys.sendMessage(src,"~~Server~~: The command '/mute user:forever': Mutes a user untill they are unmuted.");
  447.             sys.sendMessage(src,"~~Server~~: The command '/unmute user': Allows a user to talk.");
  448.             sys.sendMessage(src,"~~Server~~: The command '/ban user:time:unit': Bans a user for time units, time must be a number, and unit must be a unit of time.");     
  449.             sys.sendMessage(src,"~~Server~~: Note: You do not have to input a time or unit, it will be 1 hour by deafault.");
  450.             sys.sendMessage(src,"~~Server~~: The command '/unban IP': Removes a ban(IP only).");
  451.             sys.sendMessage(src,"~~Server~~: The command '/kick user': Kicks a user from the chat");
  452.             sys.sendMessage(src,"~~Server~~: The command '/hush': Stops all users from talking.");
  453.             sys.sendMessage(src,"~~Server~~: The command '/unhush': Removes hush.");
  454.             sys.sendMessage(src,"~~Server~~: The command '/stop': Prevents all user from entering battles.");
  455.             sys.sendMessage(src,"~~Server~~: The command '/unstop': Removes stop.");
  456.             sys.sendMessage(src,"~~Server~~: The command '/invisible': Causes rank not to show and commands to become mysterious.");
  457.             sys.sendMessage(src,"~~Server~~: The command '/visible': Removes invisible.");
  458.             sys.sendMessage(src,"~~Server~~: The command '/hyper': Causes your messages to become alerts.");
  459.             sys.sendMessage(src,"~~Server~~: The command '/dehyper': Undoes hyper.");
  460.             sys.sendMessage(src,"~~Server~~: The command '/getpass': Shows you the server password.");
  461.             sys.sendMessage(src,"~~Server~~: The command '/newtour tier:players': Creates a tournament of a tier with a number of players.");
  462.             sys.sendMessage(src,"~~Server~~: The command '/endtour': Allows you to end a tournament.");}
  463.             if (sys.auth(src) >= 2 && sys.auth(src) != 4) {
  464.             sys.sendMessage(src,"*** Admin Commands ***");
  465.             sys.sendMessage(src,"~~Server~~: The command '/ban user:forever': Bans a user untill they are unbanned.");
  466.             sys.sendMessage(src,"~~Server~~: The command '/setpass': Sets a password on the server.");
  467.             sys.sendMessage(src,"~~Server~~: The command '/removepass': Removes the password.");
  468.             sys.sendMessage(src,"~~Server~~: The command '/restrict': Removes non-staff from the server and prevents them from joining.");
  469.             sys.sendMessage(src,"~~Server~~: The command '/derestrict': Removes restriction from the server.");
  470.             sys.sendMessage(src,"~~Server~~: The command '/protect user': Protected user can not be kicked, muted, blocked, or banned.");
  471.             sys.sendMessage(src,"~~Server~~: The command '/deprotect user': Removes protection.");
  472.             sys.sendMessage(src,"~~Server~~: The command '/auth user': Changes a user into a moderator.");
  473.             sys.sendMessage(src,"~~Server~~: The command '/deauth user': Changes a moderator into a user.");
  474.             sys.sendMessage(src,"~~Server~~: The command '/s-kick user': Kicks a user without a message.");
  475.             sys.sendMessage(src,"~~Server~~: The command '/s-mute user': Mutes a user without a message.");
  476.             sys.sendMessage(src,"~~Server~~: The command '/s-ban user': Bans a user without a message.");
  477.             sys.sendMessage(src,"~~Server~~: The command '/s-unmute user': Removes mute without a message.");
  478.             sys.sendMessage(src,"~~Server~~: The command '/s-unban user': Removes ban without a message."); }
  479.             sys.sendMessage(src,"*** End of list ***");
  480.             return; }
  481.     /** Tournament **/
  482.     if (command == "join" || command == "j"){
  483.         if (tourmode == 0){
  484.             sys.sendMessage(src, "~~Server~~: Sorry, you are unable to join because a tournament is not currently running.");
  485.             return; }
  486.         if (inBattle[src] == true){
  487.             sys.sendMessage(src, "~~Server~~: Sorry, you are unable to join because you are in a battle.");
  488.             return; }
  489.         var tourmembername = sys.name(src);
  490.         if (tourmembers.indexOf(tourmembername) in tourmembers){
  491.             sys.sendMessage(src, "~~Server~~: Sorry, you are already in the tournament. You are not able to join more than once.");
  492.             return; }
  493.         if (tourmode == 2){
  494.             sys.sendMessage(src, "~~Server~~: Sorry, you are unable to join because the tournament has passed the sign-up phase.");
  495.             return; }  
  496.         var srctier = sys.tier(src);
  497.         if (tourtier != srctier.toLowerCase()){
  498.             sys.sendMessage(src, "~~Server~~: You are currently not battling in the " + tourtier + " tier. Change your tier to " + tourtier + " to be able to join.");
  499.             return; }
  500.         if (tourcount > 0){
  501.             tourcount--;
  502.             tourmembers.push(tourmembername);
  503.             sys.sendAll('~~Server~~: '+tourmembername + " joined the tournament! " + tourcount + " more spot(s) left!");
  504.             if (tourcount == 0){
  505.                 tourmode = 2;
  506.                 roundnumber = 0;
  507.                 this.roundpairing();}
  508.             return;}
  509.         return; }
  510.     if (command == "viewround" || command == "round") {
  511.         if (tourmode == 0){
  512.             sys.sendMessage(src, "~~Server~~: Sorry, you are unable to view the round because a tournament is not currently running.");
  513.             return;}
  514.         if (tourmode == 1){
  515.             sys.sendMessage(src, "~~Server~~: Sorry, you are unable to view the round because the signing up for the tournament is still in progress.");
  516.             return;}
  517.         receiver = src;
  518.         this.rounddisplay();
  519.         return;}
  520. /** Moderator Commands **/
  521.         if (sys.auth(src) < 1)
  522.              {sys.sendMessage(src, "~~Server~~: The command " + command + " can not be used by normal users or does not exist.");
  523.             return; }
  524.     /**info **/
  525.         if (command == "hyper" || command == "hypermode" || command == "alert" || command == "alertmode" || command == "e") {
  526.             if (hyperMode[src] == true) {
  527.                 sys.sendMessage(src,'~~Server~~: You are already in HyperMode.');
  528.                 return; }
  529.             hyperMode[src] = true;
  530.             sys.sendMessage(src,'~~Server~~: You are now in HyperMode.');
  531.             return; }
  532.         if (command == "dehyper" || command == "dehypermode" || command == "dealert" || command == "dealertmode" || command == "-e") {
  533.             hyperMode[src] = false;
  534.             sys.sendMessage(src,'~~Server~~: You are no longer in HyperMode.');
  535.             return; }
  536.         if (command == "info" || command == "whois" || command == "i") {
  537.             if (tar == undefined)
  538.                 {sys.sendMessage(src, "~~Server~~: Error: Target is undefined");
  539.                 return; }
  540.             var alts = ''
  541.             var cnt = numUsers;
  542.             var user = 0;
  543.             var einfo = '';
  544.             if (sys.getVal('muted'+sys.ip(tar)) != '') {
  545.             einfo = einfo + ' The user is muted.' }
  546.             if (sys.getVal('protected'+sys.ip(tar)) != '') {
  547.             einfo = einfo + ' The user is protected.' }
  548.             if (hyperMode[tar] == true) {
  549.             einfo = einfo + ' The user is in HyperMode.' }
  550.             while(user < cnt)
  551.                 {if (sys.loggedIn(user) == true) {
  552.                     if (sys.ip(tar) == sys.ip(user))
  553.                          { alts = alts +' ('+ sys.name(user) + ')';}
  554.                 } else {
  555.                     cnt += 1; }
  556.                 user += 1;
  557.                 }
  558.             sys.sendMessage(src,'~~Server~~: '+sys.name(tar)+' is ' + rank[sys.auth(tar)] + '. User has these online accounts.' + alts + '. User\'s IP is (' + sys.ip(tar) +').'+einfo+' The user has ' + (sys.getVal('modnotes' + sys.ip(tar).toLowerCase()).split('+').length - 1) + ' notes to the account.');
  559.             var msg = new Array();
  560.             msg = sys.getVal('modnotes' + sys.ip(tar)).split('+');
  561.             var length = (sys.getVal('modnotes' + sys.ip(tar).toLowerCase()).split('+').length - 1);
  562.             sys.sendMessage(src,'~~Server~~: These are the notes on the account:');
  563.             for (i = 1; i <= length; i++)
  564.             {sys.sendMessage(src,msg[i]); }
  565.             sys.sendMessage(src,'~~Server~~: End of notes.');
  566.             return; }
  567.         if (command == "writenote" || command == "wnote") {
  568.             var point = commandData.indexOf(':');
  569.             var note;
  570.             if (point == -1) {
  571.             sys.sendMessage(src, "~~Server~~: Error: No content! Note was not added!");
  572.             return; }
  573.             note = commandData.substr(commandData.indexOf(':')+1);
  574.             if (note.indexOf('+') == -1) {
  575.                 sys.saveVal('modnotes' + sys.ip(sys.id(mcmd[0])),sys.getVal('modnotes' + sys.ip(sys.id(mcmd[0]))) + ' + Note by ' + sys.name(src) + ": " + note);
  576.                 sys.sendMessage(src, "~~Server~~: Note added to user " + mcmd[0] + "!");
  577.                 } else { sys.sendMessage(src, "~~Server~~: Error: The + symbol can not be used in notes! Note was not added!"); }
  578.             return; }
  579.         if (command == "viewnote" || command == "viewnotes" || command == "vnote") {
  580.             if (tar == undefined)
  581.                 {sys.sendMessage(src, "~~Server~~: Error: Target is undefined");
  582.                 return; }
  583.             var msg = new Array();
  584.             msg = sys.getVal('modnotes' + sys.ip(tar)).split('+');
  585.             var length = (sys.getVal('modnotes' + sys.ip(tar).toLowerCase()).split('+').length - 1);
  586.             sys.sendMessage(src,'~~Server~~: These are the notes on the account:');
  587.             for (i = 1; i <= length; i++)
  588.             {sys.sendMessage(src,msg[i]); }
  589.             sys.sendMessage(src,'~~Server~~: End of notes.');
  590.             return; }
  591.         if (command == "removenotes" || command == "removenote") {
  592.             if (tar == undefined)
  593.                 {sys.sendMessage(src, "~~Server~~: Error: Target is undefined");
  594.                 return; }
  595.             sys.removeVal('modnotes' + sys.ip(tar));
  596.             sys.sendMessage(src, "~~Server~~: Notes removed!");
  597.             return; }
  598.         if (command == "getpass" || command == "getpassword") {
  599.             sys.sendMessage(src,'~~Server~~: The password is ('+serverpass+').');
  600.             return; }
  601.     /** Mute **/
  602.         if (command == "mute" || command == "m") {
  603.             if (tar == undefined)
  604.                 {sys.sendMessage(src, "~~Server~~: Error: Target is undefined. Use /test username:time:type, username is the name of the user to mute, time is a number, and type is the unit of time(ex hour or minute).");
  605.                 return; }
  606.             if (sys.getVal('protected' + sys.ip(tar)) == 1)
  607.                 {sys.sendMessage(src,"~~Server~~: " + sys.name(tar) + " is protected and can not be muted.");
  608.                 return; }
  609.             if (sys.auth(tar) > 0)
  610.                 {sys.sendMessage(src,"~~Server~~: Moderators and above can not be muted.");
  611.                 return; }
  612.             if (mcmd[1] == 'forever' || mcmd[1] == 'permanent') {
  613.                 if (sys.auth(src) <= 3) {
  614.                     sys.sendAll("~~Server~~: " + sys.name(tar) + " was muted forever by " + sys.name(src) + "!");}
  615.                 else
  616.                     { sys.sendAll("~~Server~~: " + sys.name(tar) + " was mysteriously muted forever!"); }
  617.                 sys.saveVal('muted' + sys.ip(tar),1);
  618.                 sys.removeVal('mutechk' + sys.ip(tar));
  619.                 return; }
  620.             if (mcmd[1] == 0 || mcmd[1] == 'unmute') {
  621.                 sys.removeVal('muted' + sys.ip(tar));
  622.                 sys.removeVal('mutechk' + sys.ip(tar));
  623.                 if (sys.auth(src) <= 3) {
  624.                     sys.sendAll("~~Server~~: " + sys.name(tar) + " was unmuted by " + sys.name(src) + "!");}
  625.                 else
  626.                     { sys.sendAll("~~Server~~: " + sys.name(tar) + " was mysteriously unmuted!"); }
  627.                 return; }              
  628.             var typeno = 60;
  629.             var typestr = 'minute';
  630.             if (isNaN (mcmd[1]*1) == true) {
  631.             mcmd[1] = 5;
  632.             mcmd[1] = 'm';}
  633.             mcmd[2] =(typeof mcmd[2] == 'undefined')?'m':mcmd[2];
  634.             mcmd[2] = mcmd[2].toLowerCase();
  635.             mcmd[1] = Math.round(Math.abs(mcmd[1]));
  636.             if (mcmd[2] == 's' || mcmd[2] == 'second' || mcmd[2] == 'seconds' || mcmd[2] == 'sec') {
  637.             typeno = 1;
  638.             typestr = 'second';}
  639.             if (mcmd[2] == 'h' || mcmd[2] == 'hour' || mcmd[2] == 'hours' || mcmd[2] == 'hr') {
  640.             typeno = 3600;
  641.             typestr = 'hour';}
  642.             if (mcmd[2] == 'd' || mcmd[2] == 'day' || mcmd[2] == 'days' || mcmd[2] == 'dy') {
  643.             type = 86400;
  644.             typestr = 'day';}
  645.             if (mcmd[2] == 'w' || mcmd[2] == 'week' || mcmd[2] == 'weeks' || mcmd[2] == 'wk') {
  646.             typeno = 604800;
  647.             typestr = 'week';} 
  648.             if (mcmd[1] != 1) {
  649.             typestr = typestr + 's' }
  650.             if (sys.auth(src) <= 3) {
  651.                 sys.sendAll("~~Server~~: " + sys.name(tar) + " was muted for "+mcmd[1]+ ' ' + typestr + " by " + sys.name(src) + "!");}
  652.             else
  653.                 { sys.sendAll("~~Server~~: " + sys.name(tar) + " was mysteriously muted for "+mcmd[1]+ ' ' + typestr + "!"); }
  654.             var rnd = sys.rand(1,9999);
  655.             sys.saveVal('mutechk' + sys.ip(tar),rnd);
  656.             sys.callLater("if (sys.getVal('mutechk" + sys.ip(tar) +"') == "+ rnd+ " ) { sys.removeVal('muted" + sys.ip(tar) +"'); sys.removeVal('mutechk" + sys.ip(tar) +"'); sys.sendAll('~~Server~~: " + sys.name(tar) + " is no longer muted.'); } ",typeno * mcmd[1]);
  657.             sys.saveVal('muted' + sys.ip(tar),1);
  658.             return; }
  659.         if (command == "unmute" || command == "-m" || command == "demute" || command == "removemute") {
  660.             if (tar == undefined)
  661.                 {sys.sendMessage(src, "~~Server~~: Error: Target is undefined");
  662.                 return; }
  663.             if (sys.auth(src) <= 3) {
  664.                 sys.sendAll("~~Server~~: " + sys.name(tar) + " was unmuted by " + sys.name(src) + "!");}
  665.             else
  666.                 { sys.sendAll("~~Server~~: " + sys.name(tar) + " was mysteriously unmuted!"); }
  667.             sys.removeVal('muted' + sys.ip(tar));
  668.             sys.removeVal('mutechk' + sys.ip(tar),rnd);
  669.             return; }
  670.     /** Ban **/
  671.         if (command == "unban" || command == "removeban" || command == "-b" || command == "deban") {
  672.             if (sys.auth(src) <= 3) {
  673.                 sys.sendAll("~~Server~~: " + commandData + " was unbanned by " + sys.name(src) + "!");}
  674.             else
  675.                 { sys.sendAll("~~Server~~: " + commandData + " was mysteriously unbanned!"); }
  676.             sys.removeVal('banned' + commandData);
  677.             sys.removeVal('banchk' + commandData);
  678.             return; }
  679.         if (command == "ban" || command == "b") {
  680.             if (tar == undefined)  {
  681.                 sys.sendMessage(src, "~~Server~~: Error: Target is undefined.");
  682.                 return; }
  683.             if (sys.getVal('protected' + sys.ip(tar)) == 1) {
  684.                 sys.sendMessage(src,"~~Server~~: " + sys.name(tar) + " is protected and can not be banned.");
  685.                 return; }
  686.             if (sys.auth(tar) > 0) {
  687.                 sys.sendMessage(src,"~~Server~~: Moderators and above can not be banned.");
  688.                 return; }
  689.             print((mcmd[1] == 'forever' || mcmd[1] == 'permanent' && sys.auth(src) >= 2 && sys.auth(src) != 4));
  690.             if ((mcmd[1] == 'forever' || mcmd[1] == 'permanent') && sys.auth(src) >= 2 && sys.auth(src) != 4) {
  691.                 if (sys.auth(src) <= 3) {
  692.                     sys.sendAll("~~Server~~: " + sys.name(tar) + " was banned forever by " + sys.name(src) + "!"); }
  693.                 else
  694.                     { sys.sendAll("~~Server~~: " + sys.name(tar) + " was mysteriously banned forever!"); }
  695.                 sys.saveVal('banned' + sys.ip(tar),1);
  696.                 sys.removeVal('banchk' + sys.ip(tar));
  697.                 var cnt = numUsers;
  698.                 var user = 0;
  699.                 while(user < cnt) {
  700.                     if (sys.loggedIn(user) == true) {
  701.                         if (sys.ip(tar) == sys.ip(user) && sys.auth(user) < 1)
  702.                              { sys.kick(user);}
  703.                     } else {
  704.                         cnt += 1;}
  705.                     user += 1;
  706.                     }
  707.                 sys.kick(tar);
  708.                 return; }      
  709.             var typeno = 3600;
  710.             var typestr = 'hour';
  711.             if  ((mcmd[1] == 'forever' || mcmd[1] == 'permanent') && (sys.auth(src) == 1 || sys.auth(src) == 4)) {
  712.                 mcmd[1] = 8;
  713.                 mcmd[2] = 'h';
  714.                 typeno = 3600;
  715.                 typestr = 'hour';
  716.                 sys.sendMessage(src, "~~Server~~: Error: You entered a time above the maximum for moderators, the time was lowered to 8 hours."); }
  717.             if (isNaN (mcmd[1]*1) == true || mcmd[1] == 0) {
  718.                 mcmd[1] = 1;
  719.                 mcmd[2] = 'h';}
  720.             mcmd[2] =(typeof mcmd[2] == 'undefined')?'m':mcmd[2];
  721.             mcmd[2] = mcmd[2].toLowerCase();
  722.             mcmd[1] = Math.round(Math.abs(mcmd[1]));
  723.             if (mcmd[2] == 's' || mcmd[2] == 'second' || mcmd[2] == 'seconds' || mcmd[2] == 'sec') {
  724.                 typeno = 1;
  725.                 typestr = 'second';}
  726.             if (mcmd[2] == 'm' || mcmd[2] == 'minute' || mcmd[2] == 'minutes' || mcmd[2] == 'min') {
  727.                 typeno = 60;
  728.                 typestr = 'minute';}
  729.             if (mcmd[2] == 'd' || mcmd[2] == 'day' || mcmd[2] == 'days' || mcmd[2] == 'dy') {
  730.                 type = 86400;
  731.                 typestr = 'day';}
  732.             if (mcmd[2] == 'w' || mcmd[2] == 'week' || mcmd[2] == 'weeks' || mcmd[2] == 'wk') {
  733.                 typeno = 604800;
  734.                 typestr = 'week';} 
  735.             if ((sys.auth(src) == 1 || sys.auth(src) == 4) && typeno*mcmd[1] > 28800) {
  736.                 mcmd[1] = 8;
  737.                 mcmd[2] = 'h';
  738.                 typeno = 3600;
  739.                 typestr = 'hour';
  740.                 sys.sendMessage(src, "~~Server~~: Error: You entered a time above the maximum for moderators, the time was lowered to 8 hours.");}
  741.             if (mcmd[1] != 1) {
  742.                 typestr = typestr + 's' }
  743.             if (sys.auth(src) <= 3) {
  744.                 sys.sendAll("~~Server~~: " + sys.name(tar) + "("+sys.ip(tar)+ ") was banned for "+mcmd[1]+ ' ' + typestr + " by " + sys.name(src) + "!");}
  745.             else
  746.                 { sys.sendAll("~~Server~~: " + sys.name(tar) + "("+sys.ip(tar)+ ") was mysteriously banned for "+mcmd[1]+ ' ' + typestr + "!"); }
  747.             var rnd = sys.rand(1,9999);
  748.             sys.saveVal('banchk' + sys.ip(tar),rnd);
  749.             sys.callLater("if (sys.getVal('banchk" + sys.ip(tar) +"') == "+ rnd+ " ) { sys.removeVal('banned" + sys.ip(tar) +"'); sys.removeVal('banchk" + sys.ip(tar) +"'); sys.sendAll('~~Server~~: " + sys.name(tar) + " is no longer banned.'); } ",typeno * mcmd[1]);
  750.             sys.saveVal('banned' + sys.ip(tar),1);
  751.             var cnt = numUsers;
  752.             var user = 0;
  753.             while(user < cnt) {
  754.                 if (sys.loggedIn(user) == true) {
  755.                     if (sys.ip(tar) == sys.ip(user) && sys.auth(user) < 1)
  756.                          { sys.kick(user);}
  757.                     }
  758.                 else {
  759.                     cnt += 1;}
  760.                 user += 1;
  761.                 }
  762.             sys.kick(tar);
  763.             return; }
  764.     /** Kick **/
  765.         if (command == "kick" || command == "k") {
  766.             if (tar == undefined)
  767.                 {sys.sendMessage(src, "~~Server~~: Error: Target is undefined");
  768.                 return; }
  769.             if (sys.getVal('protected' + sys.ip(tar)) == 1)
  770.                 {sys.sendMessage(src,"~~Server~~: " + sys.name(tar) + " is protected and can not be kicked.");
  771.                 return; }
  772.             if (sys.auth(tar) > 0)
  773.                 {sys.sendMessage(src,"~~Server~~: Moderators and above can not be kicked.");
  774.                 return; }
  775.             if (sys.auth(src) <= 3) {
  776.             sys.sendAll("~~Server~~: " + sys.name(tar) + " was kicked by " + sys.name(src) + "!"); } else { sys.sendAll("~~Server~~: " + sys.name(tar) + " was mysteriously kicked!"); }
  777.             sys.kick(tar);
  778.             return; }
  779.         if (command == "superkick") {
  780.             if (tar == undefined)
  781.                 {sys.sendMessage(src, "~~Server~~: Error: Target is undefined");
  782.                 return; }
  783.             if (sys.getVal('protected' + sys.ip(tar)) == 1)
  784.                 {sys.sendMessage(src,"~~Server~~: " + sys.name(tar) + " is protected and can not be kicked.");
  785.                 return; }
  786.             if (sys.auth(tar) > 0)
  787.                 {sys.sendMessage(src,"~~Server~~: Moderators and above can not be kicked.");
  788.                 return; }
  789.             if (sys.auth(src) <= 3) {
  790.             sys.sendAll("~~Server~~: " + sys.name(tar) + " was kicked by " + sys.name(src) + "!"); } else { sys.sendAll("~~Server~~: " + sys.name(tar) + " was mysteriously kicked!"); }
  791.             sys.kick(tar);
  792.             var cnt = numUsers;
  793.             var user = 0;
  794.             while(user < cnt)
  795.                 {if (sys.loggedIn(user) == true) {
  796.                     if (sys.ip(tar) == sys.ip(user) && sys.auth(user) < 1)
  797.                          { sys.kick(user);}
  798.                 } else {
  799.                     cnt += 1;}
  800.                 user += 1;
  801.                 }
  802.             return; }
  803.     /** Hush **/
  804.         if (command == "hush" || command == "h") {
  805.             if (typeof restrict != 'undefined') {
  806.             sys.sendMessage(src,'~~Server~~: The server is already restricted, to hush the chat first derestrict the server.');
  807.             return; }
  808.             hush = 1;
  809.             if (sys.auth(src) <= 3) {
  810.             sys.sendAll("~~Server~~: The chat has been hushed by " + sys.name(src) + "!");} else { sys.sendAll("~~Server~~: The chat has been mysteriously hushed!"); }
  811.             return; }
  812.         if (command == "unhush" || command == "-h" || command == "dehush") {
  813.             if (typeof restrict != 'undefined') {
  814.             sys.sendMessage(src,'~~Server~~: The server is already restricted, to hush the chat first derestrict the server.');
  815.             return; }
  816.             hush = undefined;
  817.             if (sys.auth(src) <= 3) {
  818.             sys.sendAll("~~Server~~: The chat has been unhushed by " + sys.name(src) + "!");} else { sys.sendAll("~~Server~~: The chat has been mysteriously unhushed!"); }
  819.             return; }
  820.     /** Stop **/
  821.         if (command == "stop" || command == "s") {
  822.             stop = 1;
  823.             if (sys.auth(src) <= 3) {
  824.             sys.sendAll("~~Server~~: The battles have been stoped by " + sys.name(src) + "!"); } else { sys.sendAll("~~Server~~: The battles have been mysteriously stoped!"); }
  825.             return; }
  826.         if (command == "unstop" || command == "destop" || command == "-s") {
  827.             stop = undefined;
  828.             if (sys.auth(src) <= 3) {
  829.             sys.sendAll("~~Server~~: The battles have been resumed by " + sys.name(src) + "!"); } else { sys.sendAll("~~Server~~: The battles have been mysteriously resumed!"); }
  830.             return; }
  831.     /** Invisibillity **/
  832.         if (command == "invisible" && sys.auth(src) == 1) {
  833.             sys.sendMessage(src,'~~Server~~: You are now in invisible mode!');
  834.             sys.changeAuth(src,4);
  835.             return; }
  836.         if (command == "visible" && sys.auth(src) == 4) {
  837.             sys.sendMessage(src,'~~Server~~: You are no longer in invisible mode!');
  838.             sys.changeAuth(src,1);
  839.             return; }
  840.         if (command == "invisible" && sys.auth(src) == 2) {
  841.             sys.sendMessage(src,'~~Server~~: You are now in invisible mode!');
  842.             sys.changeAuth(src,5);
  843.             return; }
  844.         if (command == "visible" && sys.auth(src) == 5) {
  845.             sys.sendMessage(src,'~~Server~~: You are no longer in invisible mode!');
  846.             sys.changeAuth(src,2);
  847.             return; }
  848.         if (command == "invisible" && sys.auth(src) == 3) {
  849.             sys.sendMessage(src,'~~Server~~: You are now in invisible mode!');
  850.             sys.changeAuth(src,6);
  851.             return; }
  852.         if (command == "visible" && sys.auth(src) == 6) {
  853.             sys.sendMessage(src,'~~Server~~: You are no longer in invisible mode!');
  854.             sys.changeAuth(src,3);
  855.             return; }
  856.     /** Lutra Tournmant Script **/
  857.     if (command == "tour" || command == "newtour" || command == "createtour"){
  858.         if (tourmode != 0){
  859.             sys.sendMessage(src, "~~Server~~: Sorry, you are unable to start a tournament because one is still currently running.");
  860.             return; }
  861.         tourtier = mcmd[0].toLowerCase();
  862.         tourcount = parseInt(mcmd[1]);
  863.         if (isNaN(tourcount) || tourcount <= 2){                       
  864.             sys.sendMessage(src, "~~Server~~ You must specify a tournament size of 3 or more.");
  865.             return; }
  866.         var tier = sys.getTierList().toLowerCase().split('\n');
  867.         if (tier.indexOf(tourtier) == -1){
  868.             sys.sendMessage(src, "~~Server~~: Sorry, the server does not recognise the " + mcmd[0] + " tier.");  
  869.             return; }
  870.         tourmode = 1;
  871.         tournumber = tourcount;
  872.         tourcurrentnumber = tournumber;
  873.         tourmembers = new Array();
  874.         tourbattlers = new Array();
  875.         tourlosers = new Array();
  876.         tourdisplayversion = 1;
  877.         this.tourdisplay();
  878.         return; }
  879.     if (command == "endtour") {
  880.         if (tourmode == 0){
  881.             sys.sendMessage(src, "Sorry, you are unable to end a tournament because one is not currently running.");
  882.             return;}
  883.         tourmode = 0;
  884.         sys.sendAll("~~Server~~: The tournament has been cancelled.");
  885.         return; }
  886. if (command == "dq"){
  887.     if (tourmode == 0){
  888.         sys.sendMessage(src, "You are unable to disqualify players because a tournament is not currently running.");
  889.         return; }
  890.     var dqtrgt = mcmd[0].toLowerCase();
  891.     for (var tourmembersname in tourmembers){
  892.         if(tourmembers[tourmembersname].toLowerCase() === dqtrgt){
  893.             var dqbattler = tourmembers[tourmembersname];}
  894.         }
  895.     if (dqbattler === undefined){
  896.         sys.sendMessage(src, "You are unable to disqualify the targeted player because they are not in the tournament.");
  897.         return; }
  898.     var undqbattler;
  899.     if (tourmembers.indexOf(dqbattler) % 2 == 0){
  900.         undqbattler = tourmembers[tourmembers.indexOf(dqbattler)+1]; }
  901.     if (tourmembers.indexOf(dqbattler) % 2 == 1){
  902.         undqbattler = tourmembers[tourmembers.indexOf(dqbattler)-1]; }
  903.     for (var tourlosersindex in tourlosers){
  904.         if (tourlosers[tourlosersindex] == dqtrgt){
  905.             sys.sendMessage(src, "You are unable to disqualify the targeted player because they have already lost in this round.");
  906.             return; }
  907.         }
  908.     if (tourmode == 1){
  909.         tourcount++;
  910.         tourmembers.splice(tourmembers.indexOf(dqbattler),1)
  911.         sys.sendAll(dqbattler + " was removed from the tournament! " + tourcount + " more spot(s) left!");
  912.         return;}
  913.     sys.sendAll("~~Server~~: " + dqbattler + " has been disqualified!");
  914.     this.roundincrease(undqbattler,dqbattler);
  915.     return;}
  916. /** Admin stuff **/
  917.         if (command == "debug" ) {
  918.         /** Use with caution!! Make sure there are no pending connections! **/
  919.         print('Debug init('+numUsers+')');
  920.         numUsers = sys.numPlayers();
  921.         print('Debug complete('+numUsers+')');
  922.         return; }
  923.         if (sys.auth(src) < 2 || sys.auth(src) == 4)
  924.              {sys.sendMessage(src, "~~Server~~: The command " + command + " can not be used by moderators or does not exist.");
  925.             return; }
  926.     /** Password **/
  927.         if (command == "setpass" || command == "setpassword") {
  928.             password[src] = commandData;
  929.             serverpass = commandData;
  930.             if (sys.auth(src) <= 3) {
  931.                 sys.sendAll('~~Server~~: The password was changed by '+sys.name(src)+', please enter the password using /pass password.'); }
  932.             else
  933.                 { sys.sendAll('~~Server~~: The password was mysteriously changed, please enter the password using /pass password.');  }
  934.             return; }
  935.         if (command == "removepass" || command == "removepassword") {
  936.             sys.removeVal('pass:'+sys.name(src));
  937.             password[src] = '';
  938.             serverpass = '';
  939.             if (sys.auth(src) <= 3) {
  940.                 sys.sendAll('~~Server~~: The password was removed by '+sys.name(src)+'.'); }
  941.             else
  942.                 { sys.sendAll('~~Server~~: The password was mysteriously removed.'); }
  943.  
  944.             return; }
  945.     /** Protects **/
  946.         if (command == "protect" || command == "p") {
  947.             if (tar == undefined)
  948.                 {sys.sendMessage(src, "~~Server~~: Error: Target is undefined.");
  949.                 return; }
  950.             if (sys.auth(tar) > 0)
  951.                 {sys.sendMessage(src,"~~Server~~: Moderators and above do not need protection.");
  952.                 return; }
  953.             if (sys.auth(src) <= 3) {
  954.             sys.sendAll("~~Server~~: " + sys.name(tar) + " was protected by " + sys.name(src) + "!"); } else { sys.sendAll("~~Server~~: " + sys.name(tar) + " was mysteriously protected!"); }
  955.             sys.saveVal('protected' + sys.ip(tar),1);
  956.             sys.removeVal('muted' + sys.ip(tar));
  957.             sys.removeVal('banned' + sys.ip(tar));
  958.             sys.removeVal('mutechk' + sys.ip(tar));
  959.             sys.removeVal('banchk' + sys.ip(tar));
  960.             return; }
  961.         if (command == "deprotect" || command == "unprotect" || command == "-p") {
  962.             if (tar == undefined)
  963.                 {sys.sendMessage(src, "~~Server~~: Error: Target is undefined.");
  964.                 return; }
  965.             if (sys.auth(src) <= 3) {
  966.             sys.sendAll("~~Server~~: " + sys.name(tar) + " was deprotected by " + sys.name(src) + "!"); } else { sys.sendAll("~~Server~~: " + sys.name(tar) + " was mysteriously deprotected!"); }
  967.             sys.removeVal('protected' + sys.ip(tar));
  968.             return; }
  969.     /** Restrict **/
  970.         if (command == "restrict" || command == "r") {
  971.             restrict = 1;
  972.             hush = undefined;
  973.             if (sys.auth(src) <= 3) {
  974.             sys.sendAll("~~Server~~: The server has been restricted by " + sys.name(src) + "!"); } else {sys.sendAll("~~Server~~: The server has been mysteriously restricted!"); }
  975.             var cnt = numUsers;
  976.             var user = 0;
  977.             while(user < cnt)
  978.                 {if (sys.loggedIn(user) == true) {
  979.                     if (sys.auth(user) < 1) {
  980.                         sys.sendMessage(user,'~~Server~~: You are not staff and therefore have been kicked as the server has been restricted.');
  981.                         sys.kick(user); }
  982.                     }
  983.                 else {
  984.                     cnt += 1;}
  985.                 user += 1; }
  986.             return; }
  987.         if (command == "derestrict" || command == "-r" || command == "unrestrict") {
  988.             restrict = undefined;
  989.             if (sys.auth(src) <= 3) {
  990.             sys.sendAll("~~Server~~: The server has been derestricted by " + sys.name(src) + "!"); } else {sys.sendAll("~~Server~~: The server has been mysteriously derestricted!"); }
  991.             return; }
  992.     /** Auth **/
  993.         if (command == "auth" || command == "a") {
  994.             if (tar == undefined)
  995.                 {sys.sendMessage(src, "~~Server~~: Error: Target is undefined.");
  996.                 return; }
  997.             if (sys.auth(tar) >= 2 && sys.auth(tar) != 4)
  998.                 {sys.sendMessage(src,"~~Server~~: You dont have sufficient auth to auth " + sys.name(tar) + ".");
  999.                 return; }
  1000.             if (sys.auth(src) <= 3) {
  1001.                 sys.sendAll("~~Server~~: " + sys.name(tar) + " was given moderator by " + sys.name(src) + "!");}
  1002.             else
  1003.                 { sys.sendAll("~~Server~~: " + sys.name(tar) + " was mysteriously given moderator!"); }
  1004.             sys.changeAuth(tar,1);
  1005.             return; }
  1006.         if (command == "deauth" || command == "-a") {
  1007.             if (tar == undefined)
  1008.                 {sys.sendMessage(src, "~~Server~~: Error: Target is undefined.");
  1009.                 return; }
  1010.             if (sys.auth(tar) >= 2 && sys.auth(tar) != 4)
  1011.                 {sys.sendMessage(src,"~~Server~~: You dont have sufficient auth to auth " + sys.name(tar) + ".");
  1012.                 return; }
  1013.             if (sys.auth(src) <= 3) {
  1014.                 sys.sendAll("~~Server~~: " + sys.name(tar) + " had moderator removed by " + sys.name(src) + "!");}
  1015.             else
  1016.                 {sys.sendAll("~~Server~~: " + sys.name(tar) + " mysterioulsy had moderator removed!");  }
  1017.            
  1018.             sys.changeAuth(tar,0);
  1019.             return; }
  1020. /** Silent Commands(admin) **/
  1021.         if (command == "s-unmute") {
  1022.             if (tar == undefined)
  1023.                 {sys.sendMessage(src, "~~Server~~: Error: Target is undefined.");
  1024.                 return; }
  1025.             if (sys.auth(tar) >= 1)
  1026.             {sys.sendMessage("~~Server~~: You dont have sufficient auth to unmute " + sys.name(tar)+ ".");
  1027.             return; }
  1028.             this.unmute(tar);
  1029.             print(sys.name(tar) + " was silently unmuted by " + sys.name(src) + ".");
  1030.             return; }
  1031.         if (command == "s-unban") {
  1032.             sys.removeVal('banned' + commandData);
  1033.             print(sys.name(tar) + " was silently unbanned by " + sys.name(src) + ".");
  1034.             sys.removeVal('banchk' + commandData);
  1035.             return; }
  1036.         if (command == "s-kick") {
  1037.             if (tar == undefined)
  1038.                 {sys.sendMessage(src, "~~Server~~: Error: Target is undefined.");
  1039.                 return; }
  1040.             if (sys.getVal('protected' + sys.ip(tar)) == 1)
  1041.                 {sys.sendMessage(src,"~~Server~~: " + sys.name(tar) + " is protected and can not be kicked.");
  1042.                 return; }
  1043.             if (sys.auth(tar) >= 1)
  1044.                 {sys.sendMessage(src,"~~Server~~: You dont have sufficient auth to block " + sys.name(tar) + ".");
  1045.                 return; }
  1046.             sys.kick(tar);
  1047.             print(sys.name(tar) + " was silently kicked by " + sys.name(src) + ".");
  1048.             return; }
  1049.         if (command == "s-mute") {
  1050.             if (tar == undefined)
  1051.                 {sys.sendMessage(src, "~~Server~~: Error: Target is undefined.");
  1052.                 return; }
  1053.             if (sys.getVal('protected' + sys.ip(tar)) == 1)
  1054.                 {sys.sendMessage(src,"~~Server~~: " + sys.name(tar) + " is protected and can not be muted.");
  1055.                 return; }
  1056.             if (sys.auth(tar) >= 1)
  1057.                 {sys.sendMessage(src,"~~Server~~: You dont have sufficient auth to mute " + sys.name(tar) + ".");
  1058.                 return; }
  1059.             print(sys.name(tar) + " was silently muted by " + sys.name(src) + ".");
  1060.             sys.saveVal('muted' + sys.ip(tar),1);
  1061.             sys.removeVal('mutechk' + sys.ip(tar));
  1062.             return; }
  1063.         if (command == "s-ban") {
  1064.             if (tar == undefined)
  1065.                 {sys.sendMessage(src, "~~Server~~: Error: Target is undefined");
  1066.                 return; }
  1067.             if (sys.getVal('protected' + sys.ip(tar)) == 1)
  1068.                 {sys.sendMessage(src,"~~Server~~: " + sys.name(tar) + " is protected and can not be banned.");
  1069.                 return; }
  1070.             if (sys.auth(tar) > 0)
  1071.                 {sys.sendMessage(src,"~~Server~~: Moderators and above can not be banned.");
  1072.                 return; }
  1073.             print(sys.name(tar) + " was silently banned by " + sys.name(src) + ".");
  1074.             var rnd = sys.rand(1,99999999);
  1075.             sys.saveVal('banned' + sys.ip(tar),1);
  1076.             sys.saveVal('banchk' + sys.ip(tar),rnd);
  1077.             sys.callLater("if (sys.getVal('banchk" + sys.ip(tar) +"') == "+ rnd+ " ) { sys.removeVal('banned" + sys.ip(tar) +"'); sys.removeVal('banchk" + sys.ip(tar) +"'); sys.sendAll('~~Server~~: " + sys.name(tar) + " is no longer banned.'); }",3600);
  1078.             var cnt = numUsers;
  1079.             var user = 0;
  1080.             while(user < cnt)
  1081.                 {if (sys.loggedIn(user) == true) {
  1082.                     if (sys.ip(tar) == sys.ip(user) && sys.auth(user) < 1)
  1083.                          { sys.kick(user);}
  1084.                 } else {
  1085.                     cnt += 1;}
  1086.                 user += 1;
  1087.                 }
  1088.             sys.kick(tar);
  1089.             return; }
  1090.         if (sys.auth(src) != 3 && sys.auth(src) != 6)
  1091.              {sys.sendMessage(src, "~~Server~~: The command " + command + " can not be used by admins or does not exist.");
  1092.             return; }
  1093.     /** Master Commands **/
  1094.         if (command == "admin" || command == "*") {
  1095.             if (tar == undefined)
  1096.                 {sys.sendMessage(src, "~~Server~~: Error: Target is undefined.");
  1097.                 return; }
  1098.             if (sys.auth(tar) >= 2 && sys.auth(tar) != 4)
  1099.                 {sys.sendMessage(src,"~~Server~~: You dont have sufficient auth to auth " + sys.name(tar) + ".");
  1100.                 return; }
  1101.             if (sys.auth(src) <= 3) {
  1102.                 sys.sendAll("~~Server~~: " + sys.name(tar) + " was given admin by " + sys.name(src) + "!");}
  1103.             else
  1104.                 { sys.sendAll("~~Server~~: " + sys.name(tar) + " was mysteriously given admin!"); }
  1105.             sys.changeAuth(tar,1);
  1106.             return; }
  1107.         if (command == "deadmin" || command == "-*") {
  1108.             if (tar == undefined)
  1109.                 {sys.sendMessage(src, "~~Server~~: Error: Target is undefined.");
  1110.                 return; }
  1111.             if (sys.auth(tar) == 3 || sys.auth(tar) == 6)
  1112.                 {sys.sendMessage(src,"~~Server~~: You dont have sufficient auth to auth " + sys.name(tar) + ".");
  1113.                 return; }
  1114.             if (sys.auth(src) <= 3) {
  1115.                 sys.sendAll("~~Server~~: " + sys.name(tar) + " had admin removed by " + sys.name(src) + "!");}
  1116.             else
  1117.                 {sys.sendAll("~~Server~~: " + sys.name(tar) + " mysterioulsy had admin removed!");  }
  1118.            
  1119.             sys.changeAuth(tar,1);
  1120.             return; }
  1121.         sys.sendMessage(src, "~~Server~~: The command " + command + " does not exist.");
  1122.         return;
  1123.     }
  1124. }
  1125. ,
  1126. /** Lutra Functions **/
  1127. sendmessage: function (str) {
  1128.           return sys.sendMessage(receiver, str); }
  1129. ,
  1130. tourdisplay: function (){
  1131.     var send;
  1132.     tourdisplayversion == 0 ? send = this.sendmessage : send = sys.sendAll;
  1133.     send("~~Server~~: A Tournament has started! Type /join or !join to enter the tournament! ");
  1134.     send("~~Server~~: PLAYERS: " + tournumber);
  1135.     send("~~Server~~: TYPE: SINGLE ELIMINATION");
  1136.     send("~~Server~~: TIER : " + tourtier.toUpperCase());
  1137.     tourdisplayversion = 0; }
  1138. ,
  1139. roundincrease: function (winnername, losername){
  1140.         tourlosers.push(losername);
  1141.         var tourloser = tourbattlers.indexOf(losername);
  1142.         tourbattlers.splice(tourloser,1);
  1143.         var tourwinner = tourbattlers.indexOf(winnername);
  1144.         tourbattlers.splice(tourwinner,1);
  1145.         tourbattles++;
  1146.         if (winnername != "*bye"){
  1147.             sys.sendAll('~~Server~~: '+winnername + " advances to the next round:");
  1148.             }
  1149.         sys.sendAll('~~Server~~: '+losername + " is out of the tournament.");
  1150.         if (Math.floor(tourcurrentnumber/2) != tourbattles){
  1151.             sys.sendAll("~~Server~~:  " + Math.floor(tourcurrentnumber/2 - tourbattles) + " more match(es) to be completed in this round!");}
  1152.         if (tourcurrentnumber == 2){
  1153.             tourmode = 0;
  1154.             sys.sendAll("~~Server~~: THE WINNER OF THE TOURNAMENT IS : " + winnername);
  1155.             sys.sendAll("~~Server~~:  Congratulations, " + winnername + ", on your success!");
  1156.             return;}
  1157.         if (Math.floor(tourcurrentnumber/2) == tourbattles){
  1158.             if (tourmembers[tourcurrentnumber] == "*bye"){
  1159.                 tourmembers.splice(tourcurrentnumber,1); }
  1160.             tourcurrentnumber = Math.ceil(tourcurrentnumber/2);
  1161.             if (tourcurrentnumber == 2 && winnername == "*bye"){
  1162.                 tourbattles--;
  1163.                 return;}
  1164.             this.roundpairing(); }
  1165.     }
  1166. ,
  1167. roundpairing: function(){
  1168.     tourbattles = 0;
  1169.     while (0 in tourlosers){
  1170.         tourmembers.splice(tourmembers.indexOf(tourlosers[0]),1);
  1171.         tourlosers.splice(0,1);}           
  1172.     roundnumber++;
  1173.     rounddisplayversion = 1;
  1174.     this.shufflefunct(tourmembers);
  1175.     this.rounddisplay();
  1176.     if (tourmembers.length % 2 == 1){
  1177.         tourmembers.push("*bye");
  1178.         sys.sendAll("*** " + tourmembers[tourcurrentnumber-1] + " is randomly selected to go through to the next round!");}
  1179. }
  1180. ,
  1181. shufflefunct: function (myarray) {
  1182.     var i = myarray.length;
  1183.     if(i == 0) return false;
  1184.     while(--i){
  1185.         var j = Math.floor(Math.random()*(i + 1));
  1186.         var tempi = myarray[i];
  1187.         var tempj = myarray[j];
  1188.         myarray[i] = tempj;
  1189.         myarray[j] = tempi;}
  1190.     }
  1191. ,
  1192. tourbattleend : function(winnername, losername){
  1193.     if (tourbattlers.indexOf(losername) in tourbattlers && tourlosers.indexOf(losername) == -1 && tourlosers.indexOf(winnername) == -1){
  1194.         sys.sendAll("~~Server~~:  A tournament match has been completed!");
  1195.         this.roundincrease(winnername, losername);}
  1196. }
  1197. ,
  1198. rounddisplay: function(){
  1199.           var send;
  1200.           rounddisplayversion == 0 ? send = this.sendmessage : send = sys.sendAll;
  1201.           var roundstring;
  1202.           tourcurrentnumber == 2 ? roundstring = "~~Server~~: Final Round !" : roundstring = "~~Server~~: Round " + roundnumber + " !"
  1203.           send(roundstring);
  1204.           for (var tourmembersindex = 0 ; tourmembersindex < tourcurrentnumber-rounddisplayversion; tourmembersindex+=2){
  1205.                     var tourspotone;
  1206.                     var tourspottwo;
  1207.                     tourlosers.indexOf(tourmembers[tourmembersindex+1]) in tourlosers ? tourspotone = "(" + tourmembers[tourmembersindex] + ")" : tourspotone = tourmembers[tourmembersindex];
  1208.                     tourlosers.indexOf(tourmembers[tourmembersindex]) in tourlosers ? tourspottwo = "(" + tourmembers[tourmembersindex+1] + ")" : tourspottwo = tourmembers[tourmembersindex+1];
  1209.                     var tourspotspace = 20 - tourspotone.length;
  1210.                     do {
  1211.                               tourspotone = " " + tourspotone;
  1212.                               tourspotspace--;
  1213.                     }
  1214.                     while (tourspotspace > 0);
  1215.                     send(tourspotone + " VS " + tourspottwo);
  1216.           }
  1217.           rounddisplayversion = 0;
  1218. }
  1219. ,
  1220. /** end **/
  1221. })
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement