Advertisement
Guest User

Untitled

a guest
May 30th, 2017
143
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 && src != user) {
  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 && user != src) {
  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 == "commands" || command == "command" || command == "cmdlist") {
  426.             sys.sendMessage(src,"~~Server~~: Here are the commands:");
  427.             sys.sendMessage(src,"*** User commands ***");
  428.             sys.sendMessage(src,"~~Server~~: The command '/cmdlist': Lists commands.");
  429.             sys.sendMessage(src,"~~Server~~: The command '/sendmail user:message': Sends mail to another player.");
  430.             sys.sendMessage(src,"~~Server~~: The command '/readmail': Shows your mail.");
  431.             sys.sendMessage(src,"~~Server~~: The command '/deletemail': Deletes all your mail.");
  432.             sys.sendMessage(src,"~~Server~~: The command '/list': Lists online staff members.");
  433.             sys.sendMessage(src,"~~Server~~: The command '/pass password': Allows you to join a password protected server if you know the password.");
  434.             sys.sendMessage(src,"~~Server~~: The command '/join': Allows you to join a tournament.");
  435.             sys.sendMessage(src,"~~Server~~: The command '/viewround': Allows you to view a tournament round pairings.");      
  436.             if (sys.auth(src) >= 1) {
  437.             sys.sendMessage(src,"*** Moderator Commands ***"); 
  438.             sys.sendMessage(src,"~~Server~~: The command '/info': Gives various information about a user.");
  439.             sys.sendMessage(src,"~~Server~~: The command '/writenote user:note': Writes a note to a users account.");
  440.             sys.sendMessage(src,"~~Server~~: The command '/viewnotes user': Reads notes from a users account.");
  441.             sys.sendMessage(src,"~~Server~~: The command '/removenotes user': Removes notes from a users account.");
  442.             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.");
  443.             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.");
  444.             sys.sendMessage(src,"~~Server~~: The command '/mute user:forever': Mutes a user untill they are unmuted.");
  445.             sys.sendMessage(src,"~~Server~~: The command '/unmute user': Allows a user to talk.");
  446.             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.");     
  447.             sys.sendMessage(src,"~~Server~~: Note: You do not have to input a time or unit, it will be 1 hour by deafault.");
  448.             sys.sendMessage(src,"~~Server~~: The command '/unban IP': Removes a ban(IP only).");
  449.             sys.sendMessage(src,"~~Server~~: The command '/kick user': Kicks a user from the chat");
  450.             sys.sendMessage(src,"~~Server~~: The command '/hush': Stops all users from talking.");
  451.             sys.sendMessage(src,"~~Server~~: The command '/unhush': Removes hush.");
  452.             sys.sendMessage(src,"~~Server~~: The command '/stop': Prevents all user from entering battles.");
  453.             sys.sendMessage(src,"~~Server~~: The command '/unstop': Removes stop.");
  454.             sys.sendMessage(src,"~~Server~~: The command '/invisible': Causes rank not to show and commands to become mysterious.");
  455.             sys.sendMessage(src,"~~Server~~: The command '/visible': Removes invisible.");
  456.             sys.sendMessage(src,"~~Server~~: The command '/hyper': Causes your messages to become alerts.");
  457.             sys.sendMessage(src,"~~Server~~: The command '/dehyper': Undoes hyper.");
  458.             sys.sendMessage(src,"~~Server~~: The command '/getpass': Shows you the server password.");
  459.             sys.sendMessage(src,"~~Server~~: The command '/newtour tier:players': Creates a tournament of a tier with a number of players.");
  460.             sys.sendMessage(src,"~~Server~~: The command '/endtour': Allows you to end a tournament.");}
  461.             if (sys.auth(src) >= 2 && sys.auth(src) != 4) {
  462.             sys.sendMessage(src,"*** Admin Commands ***");
  463.             sys.sendMessage(src,"~~Server~~: The command '/ban user:forever': Bans a user untill they are unbanned.");
  464.             sys.sendMessage(src,"~~Server~~: The command '/setpass': Sets a password on the server.");
  465.             sys.sendMessage(src,"~~Server~~: The command '/removepass': Removes the password.");
  466.             sys.sendMessage(src,"~~Server~~: The command '/restrict': Removes non-staff from the server and prevents them from joining.");
  467.             sys.sendMessage(src,"~~Server~~: The command '/derestrict': Removes restriction from the server.");
  468.             sys.sendMessage(src,"~~Server~~: The command '/protect user': Protected user can not be kicked, muted, blocked, or banned.");
  469.             sys.sendMessage(src,"~~Server~~: The command '/deprotect user': Removes protection.");
  470.             sys.sendMessage(src,"~~Server~~: The command '/auth user': Changes a user into a moderator.");
  471.             sys.sendMessage(src,"~~Server~~: The command '/deauth user': Changes a moderator into a user.");
  472.             sys.sendMessage(src,"~~Server~~: The command '/s-kick user': Kicks a user without a message.");
  473.             sys.sendMessage(src,"~~Server~~: The command '/s-mute user': Mutes a user without a message.");
  474.             sys.sendMessage(src,"~~Server~~: The command '/s-ban user': Bans a user without a message.");
  475.             sys.sendMessage(src,"~~Server~~: The command '/s-unmute user': Removes mute without a message.");
  476.             sys.sendMessage(src,"~~Server~~: The command '/s-unban user': Removes ban without a message."); }
  477.             sys.sendMessage(src,"*** End of list ***");
  478.             return; }
  479.     /** Tournament **/
  480.     if (command == "join" || command == "j"){
  481.         if (tourmode == 0){
  482.             sys.sendMessage(src, "~~Server~~: Sorry, you are unable to join because a tournament is not currently running.");
  483.             return; }
  484.         if (inBattle[src] == true){
  485.             sys.sendMessage(src, "~~Server~~: Sorry, you are unable to join because you are in a battle.");
  486.             return; }
  487.         var tourmembername = sys.name(src);
  488.         if (tourmembers.indexOf(tourmembername) in tourmembers){
  489.             sys.sendMessage(src, "~~Server~~: Sorry, you are already in the tournament. You are not able to join more than once.");
  490.             return; }
  491.         if (tourmode == 2){
  492.             sys.sendMessage(src, "~~Server~~: Sorry, you are unable to join because the tournament has passed the sign-up phase.");
  493.             return; }  
  494.         var srctier = sys.tier(src);
  495.         if (tourtier != srctier.toLowerCase()){
  496.             sys.sendMessage(src, "~~Server~~: You are currently not battling in the " + tourtier + " tier. Change your tier to " + tourtier + " to be able to join.");
  497.             return; }
  498.         if (tourcount > 0){
  499.             tourcount--;
  500.             tourmembers.push(tourmembername);
  501.             sys.sendAll('~~Server~~: '+tourmembername + " joined the tournament! " + tourcount + " more spot(s) left!");
  502.             if (tourcount == 0){
  503.                 tourmode = 2;
  504.                 roundnumber = 0;
  505.                 this.roundpairing();}
  506.             return;}
  507.         return; }
  508.     if (command == "viewround" || command == "round") {
  509.         if (tourmode == 0){
  510.             sys.sendMessage(src, "~~Server~~: Sorry, you are unable to view the round because a tournament is not currently running.");
  511.             return;}
  512.         if (tourmode == 1){
  513.             sys.sendMessage(src, "~~Server~~: Sorry, you are unable to view the round because the signing up for the tournament is still in progress.");
  514.             return;}
  515.         receiver = src;
  516.         this.rounddisplay();
  517.         return;}
  518. /** Moderator Commands **/
  519.         if (sys.auth(src) < 1)
  520.              {sys.sendMessage(src, "~~Server~~: The command " + command + " can not be used by normal users or does not exist.");
  521.             return; }
  522.     /**info **/
  523.         if (command == "hyper" || command == "hypermode" || command == "alert" || command == "alertmode" || command == "e") {
  524.             if (hyperMode[src] == true) {
  525.                 sys.sendMessage(src,'~~Server~~: You are already in HyperMode.');
  526.                 return; }
  527.             hyperMode[src] = true;
  528.             sys.sendMessage(src,'~~Server~~: You are now in HyperMode.');
  529.             return; }
  530.         if (command == "dehyper" || command == "dehypermode" || command == "dealert" || command == "dealertmode" || command == "-e") {
  531.             hyperMode[src] = false;
  532.             sys.sendMessage(src,'~~Server~~: You are no longer in HyperMode.');
  533.             return; }
  534.         if (command == "info" || command == "whois" || command == "i") {
  535.             if (tar == undefined)
  536.                 {sys.sendMessage(src, "~~Server~~: Error: Target is undefined");
  537.                 return; }
  538.             var alts = ''
  539.             var cnt = numUsers;
  540.             var user = 0;
  541.             var einfo = '';
  542.             if (sys.getVal('muted'+sys.ip(tar)) != '') {
  543.             einfo = einfo + ' The user is muted.' }
  544.             if (sys.getVal('protected'+sys.ip(tar)) != '') {
  545.             einfo = einfo + ' The user is protected.' }
  546.             if (hyperMode[tar] == true) {
  547.             einfo = einfo + ' The user is in HyperMode.' }
  548.             while(user < cnt)
  549.                 {if (sys.loggedIn(user) == true) {
  550.                     if (sys.ip(tar) == sys.ip(user))
  551.                          { alts = alts +' ('+ sys.name(user) + ')';}
  552.                 } else {
  553.                     cnt += 1; }
  554.                 user += 1;
  555.                 }
  556.             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.');
  557.             var msg = new Array();
  558.             msg = sys.getVal('modnotes' + sys.ip(tar)).split('+');
  559.             var length = (sys.getVal('modnotes' + sys.ip(tar).toLowerCase()).split('+').length - 1);
  560.             sys.sendMessage(src,'~~Server~~: These are the notes on the account:');
  561.             for (i = 1; i <= length; i++)
  562.             {sys.sendMessage(src,msg[i]); }
  563.             sys.sendMessage(src,'~~Server~~: End of notes.');
  564.             return; }
  565.         if (command == "writenote" || command == "wnote") {
  566.             var point = commandData.indexOf(':');
  567.             var note;
  568.             if (point == -1) {
  569.             sys.sendMessage(src, "~~Server~~: Error: No content! Note was not added!");
  570.             return; }
  571.             note = commandData.substr(commandData.indexOf(':')+1);
  572.             if (note.indexOf('+') == -1) {
  573.                 sys.saveVal('modnotes' + sys.ip(sys.id(mcmd[0])),sys.getVal('modnotes' + sys.ip(sys.id(mcmd[0]))) + ' + Note by ' + sys.name(src) + ": " + note);
  574.                 sys.sendMessage(src, "~~Server~~: Note added to user " + mcmd[0] + "!");
  575.                 } else { sys.sendMessage(src, "~~Server~~: Error: The + symbol can not be used in notes! Note was not added!"); }
  576.             return; }
  577.         if (command == "viewnote" || command == "viewnotes" || command == "vnote") {
  578.             if (tar == undefined)
  579.                 {sys.sendMessage(src, "~~Server~~: Error: Target is undefined");
  580.                 return; }
  581.             var msg = new Array();
  582.             msg = sys.getVal('modnotes' + sys.ip(tar)).split('+');
  583.             var length = (sys.getVal('modnotes' + sys.ip(tar).toLowerCase()).split('+').length - 1);
  584.             sys.sendMessage(src,'~~Server~~: These are the notes on the account:');
  585.             for (i = 1; i <= length; i++)
  586.             {sys.sendMessage(src,msg[i]); }
  587.             sys.sendMessage(src,'~~Server~~: End of notes.');
  588.             return; }
  589.         if (command == "removenotes" || command == "removenote") {
  590.             if (tar == undefined)
  591.                 {sys.sendMessage(src, "~~Server~~: Error: Target is undefined");
  592.                 return; }
  593.             sys.removeVal('modnotes' + sys.ip(tar));
  594.             sys.sendMessage(src, "~~Server~~: Notes removed!");
  595.             return; }
  596.         if (command == "getpass" || command == "getpassword") {
  597.             sys.sendMessage(src,'~~Server~~: The password is ('+serverpass+').');
  598.             return; }
  599.     /** Mute **/
  600.         if (command == "mute" || command == "m") {
  601.             if (tar == undefined)
  602.                 {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).");
  603.                 return; }
  604.             if (sys.getVal('protected' + sys.ip(tar)) == 1)
  605.                 {sys.sendMessage(src,"~~Server~~: " + sys.name(tar) + " is protected and can not be muted.");
  606.                 return; }
  607.             if (sys.auth(tar) > 0)
  608.                 {sys.sendMessage(src,"~~Server~~: Moderators and above can not be muted.");
  609.                 return; }
  610.             if (mcmd[1] == 'forever' || mcmd[1] == 'permanent') {
  611.                 if (sys.auth(src) <= 3) {
  612.                     sys.sendAll("~~Server~~: " + sys.name(tar) + " was muted forever by " + sys.name(src) + "!");}
  613.                 else
  614.                     { sys.sendAll("~~Server~~: " + sys.name(tar) + " was mysteriously muted forever!"); }
  615.                 sys.saveVal('muted' + sys.ip(tar),1);
  616.                 sys.removeVal('mutechk' + sys.ip(tar));
  617.                 return; }
  618.             if (mcmd[1] == 0 || mcmd[1] == 'unmute') {
  619.                 sys.removeVal('muted' + sys.ip(tar));
  620.                 sys.removeVal('mutechk' + sys.ip(tar));
  621.                 if (sys.auth(src) <= 3) {
  622.                     sys.sendAll("~~Server~~: " + sys.name(tar) + " was unmuted by " + sys.name(src) + "!");}
  623.                 else
  624.                     { sys.sendAll("~~Server~~: " + sys.name(tar) + " was mysteriously unmuted!"); }
  625.                 return; }              
  626.             var typeno = 60;
  627.             var typestr = 'minute';
  628.             if (isNaN (mcmd[1]*1) == true) {
  629.             mcmd[1] = 5;
  630.             mcmd[2] = 'm';}
  631.             mcmd[2] =(typeof mcmd[2] == 'undefined')?'m':mcmd[2];
  632.             mcmd[2] = mcmd[2].toLowerCase();
  633.             mcmd[1] = Math.round(Math.abs(mcmd[1]));
  634.             if (mcmd[2] == 's' || mcmd[2] == 'second' || mcmd[2] == 'seconds' || mcmd[2] == 'sec') {
  635.             typeno = 1;
  636.             typestr = 'second';}
  637.             if (mcmd[2] == 'h' || mcmd[2] == 'hour' || mcmd[2] == 'hours' || mcmd[2] == 'hr') {
  638.             typeno = 3600;
  639.             typestr = 'hour';}
  640.             if (mcmd[2] == 'd' || mcmd[2] == 'day' || mcmd[2] == 'days' || mcmd[2] == 'dy') {
  641.             typeno = 86400;
  642.             typestr = 'day';}
  643.             if (mcmd[2] == 'w' || mcmd[2] == 'week' || mcmd[2] == 'weeks' || mcmd[2] == 'wk') {
  644.             typeno = 604800;
  645.             typestr = 'week';} 
  646.             if (mcmd[1] != 1) {
  647.             typestr = typestr + 's' }
  648.             if (sys.auth(src) <= 3) {
  649.                 sys.sendAll("~~Server~~: " + sys.name(tar) + " was muted for "+mcmd[1]+ ' ' + typestr + " by " + sys.name(src) + "!");}
  650.             else
  651.                 { sys.sendAll("~~Server~~: " + sys.name(tar) + " was mysteriously muted for "+mcmd[1]+ ' ' + typestr + "!"); }
  652.             var rnd = sys.rand(1,9999);
  653.             sys.saveVal('mutechk' + sys.ip(tar),rnd);
  654.             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]);
  655.             sys.saveVal('muted' + sys.ip(tar),1);
  656.             return; }
  657.         if (command == "unmute" || command == "-m" || command == "demute" || command == "removemute") {
  658.             if (tar == undefined)
  659.                 {sys.sendMessage(src, "~~Server~~: Error: Target is undefined");
  660.                 return; }
  661.             if (sys.auth(src) <= 3) {
  662.                 sys.sendAll("~~Server~~: " + sys.name(tar) + " was unmuted by " + sys.name(src) + "!");}
  663.             else
  664.                 { sys.sendAll("~~Server~~: " + sys.name(tar) + " was mysteriously unmuted!"); }
  665.             sys.removeVal('muted' + sys.ip(tar));
  666.             sys.removeVal('mutechk' + sys.ip(tar),rnd);
  667.             return; }
  668.     /** Ban **/
  669.         if (command == "unban" || command == "removeban" || command == "-b" || command == "deban") {
  670.             if (sys.auth(src) <= 3) {
  671.                 sys.sendAll("~~Server~~: " + commandData + " was unbanned by " + sys.name(src) + "!");}
  672.             else
  673.                 { sys.sendAll("~~Server~~: " + commandData + " was mysteriously unbanned!"); }
  674.             sys.removeVal('banned' + commandData);
  675.             sys.removeVal('banchk' + commandData);
  676.             return; }
  677.         if (command == "ban" || command == "b") {
  678.             if (tar == undefined)  {
  679.                 sys.sendMessage(src, "~~Server~~: Error: Target is undefined.");
  680.                 return; }
  681.             if (sys.getVal('protected' + sys.ip(tar)) == 1) {
  682.                 sys.sendMessage(src,"~~Server~~: " + sys.name(tar) + " is protected and can not be banned.");
  683.                 return; }
  684.             if (sys.auth(tar) > 0) {
  685.                 sys.sendMessage(src,"~~Server~~: Moderators and above can not be banned.");
  686.                 return; }
  687.             print((mcmd[1] == 'forever' || mcmd[1] == 'permanent' && sys.auth(src) >= 2 && sys.auth(src) != 4));
  688.             if ((mcmd[1] == 'forever' || mcmd[1] == 'permanent') && sys.auth(src) >= 2 && sys.auth(src) != 4) {
  689.                 if (sys.auth(src) <= 3) {
  690.                     sys.sendAll("~~Server~~: " + sys.name(tar) + " was banned forever by " + sys.name(src) + "!"); }
  691.                 else
  692.                     { sys.sendAll("~~Server~~: " + sys.name(tar) + " was mysteriously banned forever!"); }
  693.                 sys.saveVal('banned' + sys.ip(tar),1);
  694.                 sys.removeVal('banchk' + sys.ip(tar));
  695.                 var cnt = numUsers;
  696.                 var user = 0;
  697.                 while(user < cnt) {
  698.                     if (sys.loggedIn(user) == true) {
  699.                         if (sys.ip(tar) == sys.ip(user) && sys.auth(user) < 1)
  700.                              { sys.kick(user);}
  701.                     } else {
  702.                         cnt += 1;}
  703.                     user += 1;
  704.                     }
  705.                 sys.kick(tar);
  706.                 return; }      
  707.             var typeno = 3600;
  708.             var typestr = 'hour';
  709.             if  ((mcmd[1] == 'forever' || mcmd[1] == 'permanent') && (sys.auth(src) == 1 || sys.auth(src) == 4)) {
  710.                 mcmd[1] = 8;
  711.                 mcmd[2] = 'h';
  712.                 typeno = 3600;
  713.                 typestr = 'hour';
  714.                 sys.sendMessage(src, "~~Server~~: Error: You entered a time above the maximum for moderators, the time was lowered to 8 hours."); }
  715.             if (isNaN (mcmd[1]*1) == true || mcmd[1] == 0) {
  716.                 mcmd[1] = 1;
  717.                 mcmd[2] = 'h';}
  718.             mcmd[2] =(typeof mcmd[2] == 'undefined')?'m':mcmd[2];
  719.             mcmd[2] = mcmd[2].toLowerCase();
  720.             mcmd[1] = Math.round(Math.abs(mcmd[1]));
  721.             if (mcmd[2] == 's' || mcmd[2] == 'second' || mcmd[2] == 'seconds' || mcmd[2] == 'sec') {
  722.                 typeno = 1;
  723.                 typestr = 'second';}
  724.             if (mcmd[2] == 'm' || mcmd[2] == 'minute' || mcmd[2] == 'minutes' || mcmd[2] == 'min') {
  725.                 typeno = 60;
  726.                 typestr = 'minute';}
  727.             if (mcmd[2] == 'd' || mcmd[2] == 'day' || mcmd[2] == 'days' || mcmd[2] == 'dy') {
  728.                 typeno = 86400;
  729.                 typestr = 'day';}
  730.             if (mcmd[2] == 'w' || mcmd[2] == 'week' || mcmd[2] == 'weeks' || mcmd[2] == 'wk') {
  731.                 typeno = 604800;
  732.                 typestr = 'week';} 
  733.             if ((sys.auth(src) == 1 || sys.auth(src) == 4) && typeno*mcmd[1] > 28800) {
  734.                 mcmd[1] = 8;
  735.                 mcmd[2] = 'h';
  736.                 typeno = 3600;
  737.                 typestr = 'hour';
  738.                 sys.sendMessage(src, "~~Server~~: Error: You entered a time above the maximum for moderators, the time was lowered to 8 hours.");}
  739.             if (mcmd[1] != 1) {
  740.                 typestr = typestr + 's' }
  741.             if (sys.auth(src) <= 3) {
  742.                 sys.sendAll("~~Server~~: " + sys.name(tar) + "("+sys.ip(tar)+ ") was banned for "+mcmd[1]+ ' ' + typestr + " by " + sys.name(src) + "!");}
  743.             else
  744.                 { sys.sendAll("~~Server~~: " + sys.name(tar) + "("+sys.ip(tar)+ ") was mysteriously banned for "+mcmd[1]+ ' ' + typestr + "!"); }
  745.             var rnd = sys.rand(1,9999);
  746.             sys.saveVal('banchk' + sys.ip(tar),rnd);
  747.             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]);
  748.             sys.saveVal('banned' + sys.ip(tar),1);
  749.             var cnt = numUsers;
  750.             var user = 0;
  751.             while(user < cnt) {
  752.                 if (sys.loggedIn(user) == true) {
  753.                     if (sys.ip(tar) == sys.ip(user) && sys.auth(user) < 1)
  754.                          { sys.kick(user);}
  755.                     }
  756.                 else {
  757.                     cnt += 1;}
  758.                 user += 1;
  759.                 }
  760.             sys.kick(tar);
  761.             return; }
  762.     /** Kick **/
  763.         if (command == "kick" || command == "k") {
  764.             if (tar == undefined)
  765.                 {sys.sendMessage(src, "~~Server~~: Error: Target is undefined");
  766.                 return; }
  767.             if (sys.getVal('protected' + sys.ip(tar)) == 1)
  768.                 {sys.sendMessage(src,"~~Server~~: " + sys.name(tar) + " is protected and can not be kicked.");
  769.                 return; }
  770.             if (sys.auth(tar) > 0)
  771.                 {sys.sendMessage(src,"~~Server~~: Moderators and above can not be kicked.");
  772.                 return; }
  773.             if (sys.auth(src) <= 3) {
  774.             sys.sendAll("~~Server~~: " + sys.name(tar) + " was kicked by " + sys.name(src) + "!"); } else { sys.sendAll("~~Server~~: " + sys.name(tar) + " was mysteriously kicked!"); }
  775.             sys.kick(tar);
  776.             return; }
  777.         if (command == "superkick") {
  778.             if (tar == undefined)
  779.                 {sys.sendMessage(src, "~~Server~~: Error: Target is undefined");
  780.                 return; }
  781.             if (sys.getVal('protected' + sys.ip(tar)) == 1)
  782.                 {sys.sendMessage(src,"~~Server~~: " + sys.name(tar) + " is protected and can not be kicked.");
  783.                 return; }
  784.             if (sys.auth(tar) > 0)
  785.                 {sys.sendMessage(src,"~~Server~~: Moderators and above can not be kicked.");
  786.                 return; }
  787.             if (sys.auth(src) <= 3) {
  788.             sys.sendAll("~~Server~~: " + sys.name(tar) + " was kicked by " + sys.name(src) + "!"); } else { sys.sendAll("~~Server~~: " + sys.name(tar) + " was mysteriously kicked!"); }
  789.             sys.kick(tar);
  790.             var cnt = numUsers;
  791.             var user = 0;
  792.             while(user < cnt)
  793.                 {if (sys.loggedIn(user) == true) {
  794.                     if (sys.ip(tar) == sys.ip(user) && sys.auth(user) < 1)
  795.                          { sys.kick(user);}
  796.                 } else {
  797.                     cnt += 1;}
  798.                 user += 1;
  799.                 }
  800.             return; }
  801.     /** Hush **/
  802.         if (command == "hush" || command == "h") {
  803.             if (typeof restrict != 'undefined') {
  804.             sys.sendMessage(src,'~~Server~~: The server is already restricted, to hush the chat first derestrict the server.');
  805.             return; }
  806.             hush = 1;
  807.             if (sys.auth(src) <= 3) {
  808.             sys.sendAll("~~Server~~: The chat has been hushed by " + sys.name(src) + "!");} else { sys.sendAll("~~Server~~: The chat has been mysteriously hushed!"); }
  809.             return; }
  810.         if (command == "unhush" || command == "-h" || command == "dehush") {
  811.             if (typeof restrict != 'undefined') {
  812.             sys.sendMessage(src,'~~Server~~: The server is already restricted, to hush the chat first derestrict the server.');
  813.             return; }
  814.             hush = undefined;
  815.             if (sys.auth(src) <= 3) {
  816.             sys.sendAll("~~Server~~: The chat has been unhushed by " + sys.name(src) + "!");} else { sys.sendAll("~~Server~~: The chat has been mysteriously unhushed!"); }
  817.             return; }
  818.     /** Stop **/
  819.         if (command == "stop" || command == "s") {
  820.             stop = 1;
  821.             if (sys.auth(src) <= 3) {
  822.             sys.sendAll("~~Server~~: The battles have been stoped by " + sys.name(src) + "!"); } else { sys.sendAll("~~Server~~: The battles have been mysteriously stoped!"); }
  823.             return; }
  824.         if (command == "unstop" || command == "destop" || command == "-s") {
  825.             stop = undefined;
  826.             if (sys.auth(src) <= 3) {
  827.             sys.sendAll("~~Server~~: The battles have been resumed by " + sys.name(src) + "!"); } else { sys.sendAll("~~Server~~: The battles have been mysteriously resumed!"); }
  828.             return; }
  829.     /** Invisibillity **/
  830.         if (command == "invisible" && sys.auth(src) == 1) {
  831.             sys.sendMessage(src,'~~Server~~: You are now in invisible mode!');
  832.             sys.changeAuth(src,4);
  833.             return; }
  834.         if (command == "visible" && sys.auth(src) == 4) {
  835.             sys.sendMessage(src,'~~Server~~: You are no longer in invisible mode!');
  836.             sys.changeAuth(src,1);
  837.             return; }
  838.         if (command == "invisible" && sys.auth(src) == 2) {
  839.             sys.sendMessage(src,'~~Server~~: You are now in invisible mode!');
  840.             sys.changeAuth(src,5);
  841.             return; }
  842.         if (command == "visible" && sys.auth(src) == 5) {
  843.             sys.sendMessage(src,'~~Server~~: You are no longer in invisible mode!');
  844.             sys.changeAuth(src,2);
  845.             return; }
  846.         if (command == "invisible" && sys.auth(src) == 3) {
  847.             sys.sendMessage(src,'~~Server~~: You are now in invisible mode!');
  848.             sys.changeAuth(src,6);
  849.             return; }
  850.         if (command == "visible" && sys.auth(src) == 6) {
  851.             sys.sendMessage(src,'~~Server~~: You are no longer in invisible mode!');
  852.             sys.changeAuth(src,3);
  853.             return; }
  854.     /** Lutra Tournmant Script **/
  855.     if (command == "tour" || command == "newtour" || command == "createtour"){
  856.         if (tourmode != 0){
  857.             sys.sendMessage(src, "~~Server~~: Sorry, you are unable to start a tournament because one is still currently running.");
  858.             return; }
  859.         tourtier = mcmd[0].toLowerCase();
  860.         tourcount = parseInt(mcmd[1]);
  861.         if (isNaN(tourcount) || tourcount <= 2){                       
  862.             sys.sendMessage(src, "~~Server~~ You must specify a tournament size of 3 or more.");
  863.             return; }
  864.         var tier = sys.getTierList().toLowerCase().split('\n');
  865.         if (tier.indexOf(tourtier) == -1){
  866.             sys.sendMessage(src, "~~Server~~: Sorry, the server does not recognise the " + mcmd[0] + " tier.");  
  867.             return; }
  868.         tourmode = 1;
  869.         tournumber = tourcount;
  870.         tourcurrentnumber = tournumber;
  871.         tourmembers = new Array();
  872.         tourbattlers = new Array();
  873.         tourlosers = new Array();
  874.         tourdisplayversion = 1;
  875.         this.tourdisplay();
  876.         return; }
  877.     if (command == "endtour") {
  878.         if (tourmode == 0){
  879.             sys.sendMessage(src, "Sorry, you are unable to end a tournament because one is not currently running.");
  880.             return;}
  881.         tourmode = 0;
  882.         sys.sendAll("~~Server~~: The tournament has been cancelled.");
  883.         return; }
  884. if (command == "dq"){
  885.     if (tourmode == 0){
  886.         sys.sendMessage(src, "You are unable to disqualify players because a tournament is not currently running.");
  887.         return; }
  888.     var dqtrgt = mcmd[0].toLowerCase();
  889.     for (var tourmembersname in tourmembers){
  890.         if(tourmembers[tourmembersname].toLowerCase() === dqtrgt){
  891.             var dqbattler = tourmembers[tourmembersname];}
  892.         }
  893.     if (dqbattler === undefined){
  894.         sys.sendMessage(src, "You are unable to disqualify the targeted player because they are not in the tournament.");
  895.         return; }
  896.     var undqbattler;
  897.     if (tourmembers.indexOf(dqbattler) % 2 == 0){
  898.         undqbattler = tourmembers[tourmembers.indexOf(dqbattler)+1]; }
  899.     if (tourmembers.indexOf(dqbattler) % 2 == 1){
  900.         undqbattler = tourmembers[tourmembers.indexOf(dqbattler)-1]; }
  901.     for (var tourlosersindex in tourlosers){
  902.         if (tourlosers[tourlosersindex] == dqtrgt){
  903.             sys.sendMessage(src, "You are unable to disqualify the targeted player because they have already lost in this round.");
  904.             return; }
  905.         }
  906.     if (tourmode == 1){
  907.         tourcount++;
  908.         tourmembers.splice(tourmembers.indexOf(dqbattler),1)
  909.         sys.sendAll(dqbattler + " was removed from the tournament! " + tourcount + " more spot(s) left!");
  910.         return;}
  911.     sys.sendAll("~~Server~~: " + dqbattler + " has been disqualified!");
  912.     this.roundincrease(undqbattler,dqbattler);
  913.     return;}
  914. /** Admin stuff **/
  915.         if (command == "debug" ) {
  916.         /** Use with caution!! Make sure there are no pending connections! **/
  917.         print('Debug init('+numUsers+')');
  918.         numUsers = sys.numPlayers();
  919.         print('Debug complete('+numUsers+')');
  920.         return; }
  921.         if (sys.auth(src) < 2 || sys.auth(src) == 4)
  922.              {sys.sendMessage(src, "~~Server~~: The command " + command + " can not be used by moderators or does not exist.");
  923.             return; }
  924.     /** Password **/
  925.         if (command == "setpass" || command == "setpassword") {
  926.             password[src] = commandData;
  927.             serverpass = commandData;
  928.             if (sys.auth(src) <= 3) {
  929.                 sys.sendAll('~~Server~~: The password was changed by '+sys.name(src)+', please enter the password using /pass password.'); }
  930.             else
  931.                 { sys.sendAll('~~Server~~: The password was mysteriously changed, please enter the password using /pass password.');  }
  932.             return; }
  933.         if (command == "removepass" || command == "removepassword") {
  934.             sys.removeVal('pass:'+sys.name(src));
  935.             password[src] = '';
  936.             serverpass = '';
  937.             if (sys.auth(src) <= 3) {
  938.                 sys.sendAll('~~Server~~: The password was removed by '+sys.name(src)+'.'); }
  939.             else
  940.                 { sys.sendAll('~~Server~~: The password was mysteriously removed.'); }
  941.  
  942.             return; }
  943.     /** Protects **/
  944.         if (command == "protect" || command == "p") {
  945.             if (tar == undefined)
  946.                 {sys.sendMessage(src, "~~Server~~: Error: Target is undefined.");
  947.                 return; }
  948.             if (sys.auth(tar) > 0)
  949.                 {sys.sendMessage(src,"~~Server~~: Moderators and above do not need protection.");
  950.                 return; }
  951.             if (sys.auth(src) <= 3) {
  952.             sys.sendAll("~~Server~~: " + sys.name(tar) + " was protected by " + sys.name(src) + "!"); } else { sys.sendAll("~~Server~~: " + sys.name(tar) + " was mysteriously protected!"); }
  953.             sys.saveVal('protected' + sys.ip(tar),1);
  954.             sys.removeVal('muted' + sys.ip(tar));
  955.             sys.removeVal('banned' + sys.ip(tar));
  956.             sys.removeVal('mutechk' + sys.ip(tar));
  957.             sys.removeVal('banchk' + sys.ip(tar));
  958.             return; }
  959.         if (command == "deprotect" || command == "unprotect" || command == "-p") {
  960.             if (tar == undefined)
  961.                 {sys.sendMessage(src, "~~Server~~: Error: Target is undefined.");
  962.                 return; }
  963.             if (sys.auth(src) <= 3) {
  964.             sys.sendAll("~~Server~~: " + sys.name(tar) + " was deprotected by " + sys.name(src) + "!"); } else { sys.sendAll("~~Server~~: " + sys.name(tar) + " was mysteriously deprotected!"); }
  965.             sys.removeVal('protected' + sys.ip(tar));
  966.             return; }
  967.     /** Restrict **/
  968.         if (command == "restrict" || command == "r") {
  969.             restrict = 1;
  970.             hush = undefined;
  971.             if (sys.auth(src) <= 3) {
  972.             sys.sendAll("~~Server~~: The server has been restricted by " + sys.name(src) + "!"); } else {sys.sendAll("~~Server~~: The server has been mysteriously restricted!"); }
  973.             var cnt = numUsers;
  974.             var user = 0;
  975.             while(user < cnt)
  976.                 {if (sys.loggedIn(user) == true) {
  977.                     if (sys.auth(user) < 1) {
  978.                         sys.sendMessage(user,'~~Server~~: You are not staff and therefore have been kicked as the server has been restricted.');
  979.                         sys.kick(user); }
  980.                     }
  981.                 else {
  982.                     cnt += 1;}
  983.                 user += 1; }
  984.             return; }
  985.         if (command == "derestrict" || command == "-r" || command == "unrestrict") {
  986.             restrict = undefined;
  987.             if (sys.auth(src) <= 3) {
  988.             sys.sendAll("~~Server~~: The server has been derestricted by " + sys.name(src) + "!"); } else {sys.sendAll("~~Server~~: The server has been mysteriously derestricted!"); }
  989.             return; }
  990.     /** Auth **/
  991.         if (command == "auth" || command == "a") {
  992.             if (tar == undefined)
  993.                 {sys.sendMessage(src, "~~Server~~: Error: Target is undefined.");
  994.                 return; }
  995.             if (sys.auth(tar) >= 2 && sys.auth(tar) != 4)
  996.                 {sys.sendMessage(src,"~~Server~~: You dont have sufficient auth to auth " + sys.name(tar) + ".");
  997.                 return; }
  998.             if (sys.auth(src) <= 3) {
  999.                 sys.sendAll("~~Server~~: " + sys.name(tar) + " was given moderator by " + sys.name(src) + "!");}
  1000.             else
  1001.                 { sys.sendAll("~~Server~~: " + sys.name(tar) + " was mysteriously given moderator!"); }
  1002.             sys.changeAuth(tar,1);
  1003.             return; }
  1004.         if (command == "deauth" || command == "-a") {
  1005.             if (tar == undefined)
  1006.                 {sys.sendMessage(src, "~~Server~~: Error: Target is undefined.");
  1007.                 return; }
  1008.             if (sys.auth(tar) >= 2 && sys.auth(tar) != 4)
  1009.                 {sys.sendMessage(src,"~~Server~~: You dont have sufficient auth to auth " + sys.name(tar) + ".");
  1010.                 return; }
  1011.             if (sys.auth(src) <= 3) {
  1012.                 sys.sendAll("~~Server~~: " + sys.name(tar) + " had moderator removed by " + sys.name(src) + "!");}
  1013.             else
  1014.                 {sys.sendAll("~~Server~~: " + sys.name(tar) + " mysterioulsy had moderator removed!");  }
  1015.            
  1016.             sys.changeAuth(tar,0);
  1017.             return; }
  1018. /** Silent Commands(admin) **/
  1019.         if (command == "s-unmute") {
  1020.             if (tar == undefined)
  1021.                 {sys.sendMessage(src, "~~Server~~: Error: Target is undefined.");
  1022.                 return; }
  1023.             if (sys.auth(tar) >= 1)
  1024.             {sys.sendMessage("~~Server~~: You dont have sufficient auth to unmute " + sys.name(tar)+ ".");
  1025.             return; }
  1026.             this.unmute(tar);
  1027.             print(sys.name(tar) + " was silently unmuted by " + sys.name(src) + ".");
  1028.             return; }
  1029.         if (command == "s-unban") {
  1030.             sys.removeVal('banned' + commandData);
  1031.             print(sys.name(tar) + " was silently unbanned by " + sys.name(src) + ".");
  1032.             sys.removeVal('banchk' + commandData);
  1033.             return; }
  1034.         if (command == "s-kick") {
  1035.             if (tar == undefined)
  1036.                 {sys.sendMessage(src, "~~Server~~: Error: Target is undefined.");
  1037.                 return; }
  1038.             if (sys.getVal('protected' + sys.ip(tar)) == 1)
  1039.                 {sys.sendMessage(src,"~~Server~~: " + sys.name(tar) + " is protected and can not be kicked.");
  1040.                 return; }
  1041.             if (sys.auth(tar) >= 1)
  1042.                 {sys.sendMessage(src,"~~Server~~: You dont have sufficient auth to block " + sys.name(tar) + ".");
  1043.                 return; }
  1044.             sys.kick(tar);
  1045.             print(sys.name(tar) + " was silently kicked by " + sys.name(src) + ".");
  1046.             return; }
  1047.         if (command == "s-mute") {
  1048.             if (tar == undefined)
  1049.                 {sys.sendMessage(src, "~~Server~~: Error: Target is undefined.");
  1050.                 return; }
  1051.             if (sys.getVal('protected' + sys.ip(tar)) == 1)
  1052.                 {sys.sendMessage(src,"~~Server~~: " + sys.name(tar) + " is protected and can not be muted.");
  1053.                 return; }
  1054.             if (sys.auth(tar) >= 1)
  1055.                 {sys.sendMessage(src,"~~Server~~: You dont have sufficient auth to mute " + sys.name(tar) + ".");
  1056.                 return; }
  1057.             print(sys.name(tar) + " was silently muted by " + sys.name(src) + ".");
  1058.             sys.saveVal('muted' + sys.ip(tar),1);
  1059.             sys.removeVal('mutechk' + sys.ip(tar));
  1060.             return; }
  1061.         if (command == "s-ban") {
  1062.             if (tar == undefined)
  1063.                 {sys.sendMessage(src, "~~Server~~: Error: Target is undefined");
  1064.                 return; }
  1065.             if (sys.getVal('protected' + sys.ip(tar)) == 1)
  1066.                 {sys.sendMessage(src,"~~Server~~: " + sys.name(tar) + " is protected and can not be banned.");
  1067.                 return; }
  1068.             if (sys.auth(tar) > 0)
  1069.                 {sys.sendMessage(src,"~~Server~~: Moderators and above can not be banned.");
  1070.                 return; }
  1071.             print(sys.name(tar) + " was silently banned by " + sys.name(src) + ".");
  1072.             var rnd = sys.rand(1,99999999);
  1073.             sys.saveVal('banned' + sys.ip(tar),1);
  1074.             sys.saveVal('banchk' + sys.ip(tar),rnd);
  1075.             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);
  1076.             var cnt = numUsers;
  1077.             var user = 0;
  1078.             while(user < cnt)
  1079.                 {if (sys.loggedIn(user) == true) {
  1080.                     if (sys.ip(tar) == sys.ip(user) && sys.auth(user) < 1)
  1081.                          { sys.kick(user);}
  1082.                 } else {
  1083.                     cnt += 1;}
  1084.                 user += 1;
  1085.                 }
  1086.             sys.kick(tar);
  1087.             return; }
  1088.         if (sys.auth(src) != 3 && sys.auth(src) != 6)
  1089.              {sys.sendMessage(src, "~~Server~~: The command " + command + " can not be used by admins or does not exist.");
  1090.             return; }
  1091.     /** Master Commands **/
  1092.         if (command == "admin" || command == "*") {
  1093.             if (tar == undefined)
  1094.                 {sys.sendMessage(src, "~~Server~~: Error: Target is undefined.");
  1095.                 return; }
  1096.             if (sys.auth(tar) >= 2 && sys.auth(tar) != 4)
  1097.                 {sys.sendMessage(src,"~~Server~~: You dont have sufficient auth to auth " + sys.name(tar) + ".");
  1098.                 return; }
  1099.             if (sys.auth(src) <= 3) {
  1100.                 sys.sendAll("~~Server~~: " + sys.name(tar) + " was given admin by " + sys.name(src) + "!");}
  1101.             else
  1102.                 { sys.sendAll("~~Server~~: " + sys.name(tar) + " was mysteriously given admin!"); }
  1103.             sys.changeAuth(tar,1);
  1104.             return; }
  1105.         if (command == "deadmin" || command == "-*") {
  1106.             if (tar == undefined)
  1107.                 {sys.sendMessage(src, "~~Server~~: Error: Target is undefined.");
  1108.                 return; }
  1109.             if (sys.auth(tar) == 3 || sys.auth(tar) == 6)
  1110.                 {sys.sendMessage(src,"~~Server~~: You dont have sufficient auth to auth " + sys.name(tar) + ".");
  1111.                 return; }
  1112.             if (sys.auth(src) <= 3) {
  1113.                 sys.sendAll("~~Server~~: " + sys.name(tar) + " had admin removed by " + sys.name(src) + "!");}
  1114.             else
  1115.                 {sys.sendAll("~~Server~~: " + sys.name(tar) + " mysterioulsy had admin removed!");  }
  1116.            
  1117.             sys.changeAuth(tar,1);
  1118.             return; }
  1119.         sys.sendMessage(src, "~~Server~~: The command " + command + " does not exist.");
  1120.         return;
  1121.     }
  1122. }
  1123. ,
  1124. /** Lutra Functions **/
  1125. sendmessage: function (str) {
  1126.           return sys.sendMessage(receiver, str); }
  1127. ,
  1128. tourdisplay: function (){
  1129.     var send;
  1130.     tourdisplayversion == 0 ? send = this.sendmessage : send = sys.sendAll;
  1131.     send("~~Server~~: A Tournament has started! Type /join or !join to enter the tournament! ");
  1132.     send("~~Server~~: PLAYERS: " + tournumber);
  1133.     send("~~Server~~: TYPE: SINGLE ELIMINATION");
  1134.     send("~~Server~~: TIER : " + tourtier.toUpperCase());
  1135.     tourdisplayversion = 0; }
  1136. ,
  1137. roundincrease: function (winnername, losername){
  1138.         tourlosers.push(losername);
  1139.         var tourloser = tourbattlers.indexOf(losername);
  1140.         tourbattlers.splice(tourloser,1);
  1141.         var tourwinner = tourbattlers.indexOf(winnername);
  1142.         tourbattlers.splice(tourwinner,1);
  1143.         tourbattles++;
  1144.         if (winnername != "*bye"){
  1145.             sys.sendAll('~~Server~~: '+winnername + " advances to the next round:");
  1146.             }
  1147.         sys.sendAll('~~Server~~: '+losername + " is out of the tournament.");
  1148.         if (Math.floor(tourcurrentnumber/2) != tourbattles){
  1149.             sys.sendAll("~~Server~~:  " + Math.floor(tourcurrentnumber/2 - tourbattles) + " more match(es) to be completed in this round!");}
  1150.         if (tourcurrentnumber == 2){
  1151.             tourmode = 0;
  1152.             sys.sendAll("~~Server~~: THE WINNER OF THE TOURNAMENT IS : " + winnername);
  1153.             sys.sendAll("~~Server~~:  Congratulations, " + winnername + ", on your success!");
  1154.             return;}
  1155.         if (Math.floor(tourcurrentnumber/2) == tourbattles){
  1156.             if (tourmembers[tourcurrentnumber] == "*bye"){
  1157.                 tourmembers.splice(tourcurrentnumber,1); }
  1158.             tourcurrentnumber = Math.ceil(tourcurrentnumber/2);
  1159.             if (tourcurrentnumber == 2 && winnername == "*bye"){
  1160.                 tourbattles--;
  1161.                 return;}
  1162.             this.roundpairing(); }
  1163.     }
  1164. ,
  1165. roundpairing: function(){
  1166.     tourbattles = 0;
  1167.     while (0 in tourlosers){
  1168.         tourmembers.splice(tourmembers.indexOf(tourlosers[0]),1);
  1169.         tourlosers.splice(0,1);}           
  1170.     roundnumber++;
  1171.     rounddisplayversion = 1;
  1172.     this.shufflefunct(tourmembers);
  1173.     this.rounddisplay();
  1174.     if (tourmembers.length % 2 == 1){
  1175.         tourmembers.push("*bye");
  1176.         sys.sendAll("*** " + tourmembers[tourcurrentnumber-1] + " is randomly selected to go through to the next round!");}
  1177. }
  1178. ,
  1179. shufflefunct: function (myarray) {
  1180.     var i = myarray.length;
  1181.     if(i == 0) return false;
  1182.     while(--i){
  1183.         var j = Math.floor(Math.random()*(i + 1));
  1184.         var tempi = myarray[i];
  1185.         var tempj = myarray[j];
  1186.         myarray[i] = tempj;
  1187.         myarray[j] = tempi;}
  1188.     }
  1189. ,
  1190. tourbattleend : function(winnername, losername){
  1191.     if (tourbattlers.indexOf(losername) in tourbattlers && tourlosers.indexOf(losername) == -1 && tourlosers.indexOf(winnername) == -1){
  1192.         sys.sendAll("~~Server~~:  A tournament match has been completed!");
  1193.         this.roundincrease(winnername, losername);}
  1194. }
  1195. ,
  1196. rounddisplay: function(){
  1197.           var send;
  1198.           rounddisplayversion == 0 ? send = this.sendmessage : send = sys.sendAll;
  1199.           var roundstring;
  1200.           tourcurrentnumber == 2 ? roundstring = "~~Server~~: Final Round !" : roundstring = "~~Server~~: Round " + roundnumber + " !"
  1201.           send(roundstring);
  1202.           for (var tourmembersindex = 0 ; tourmembersindex < tourcurrentnumber-rounddisplayversion; tourmembersindex+=2){
  1203.                     var tourspotone;
  1204.                     var tourspottwo;
  1205.                     tourlosers.indexOf(tourmembers[tourmembersindex+1]) in tourlosers ? tourspotone = "(" + tourmembers[tourmembersindex] + ")" : tourspotone = tourmembers[tourmembersindex];
  1206.                     tourlosers.indexOf(tourmembers[tourmembersindex]) in tourlosers ? tourspottwo = "(" + tourmembers[tourmembersindex+1] + ")" : tourspottwo = tourmembers[tourmembersindex+1];
  1207.                     var tourspotspace = 20 - tourspotone.length;
  1208.                     do {
  1209.                               tourspotone = " " + tourspotone;
  1210.                               tourspotspace--;
  1211.                     }
  1212.                     while (tourspotspace > 0);
  1213.                     send(tourspotone + " VS " + tourspottwo);
  1214.           }
  1215.           rounddisplayversion = 0;
  1216. }
  1217. ,
  1218. /** end **/
  1219. })
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement