Advertisement
Guest User

Untitled

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