Advertisement
Guest User

Untitled

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