Block all battles

Discussion in 'Server and Client Scripting' started by EeveeTrainer, Jul 20, 2013.

  1. EeveeTrainer

    EeveeTrainer New Member

    Joined:
    Oct 7, 2012
    Messages:
    8
    Likes Received:
    0
    Does anyone have a script that will block all battles from being started? For use during DDoS attacks. Also, if possible, to have the server display a message to a user when a battle attempts to start>?
     
  2. Crystal Moogle

    Crystal Moogle Ayaya~ Administrator Administrator

    Joined:
    Jul 19, 2010
    Messages:
    3,205
    Likes Received:
    531
    PO Trainer Name:
    Hanako
    Code (JAVASCRIPT):
    1.  
    2.     //declare somewhere at top of script
    3.     var battlesStopped = false;
    4.    
    5.     //place somewhere in your commands
    6.     if (command == "stopbattles") {
    7.         battlesStopped = !battlesStopped;
    8.         if (battlesStopped)  {
    9.             sys.sendAll("");
    10.             sys.sendAll("*** ********************************************************************** ***");
    11.             sys.sendAll("The battles are now stopped. The server will restart soon.");
    12.             sys.sendAll("*** ********************************************************************** ***");
    13.             sys.sendAll("");
    14.         } else {
    15.             sys.sendAll("False alarm, battles may continue.");
    16.         }
    17.         return;
    18.     }
    19.    
    20.     //place in events
    21.     beforeChallengeIssued : function (src, dest, clauses, rated, mode, team, destTier) {
    22.         if (battlesStopped) {
    23.             sys.sendMessage(src, "Battles are now stopped as the server will restart soon.");
    24.             sys.stopEvent();
    25.             return;
    26.         }
    27.     },
    28.     beforeBattleMatchup : function (src,dest,clauses,rated) {
    29.         if (battlesStopped) {
    30.             sys.stopEvent();
    31.             return;
    32.         }
    33.     }
    34.  
    It's adapted from the PO scripts though, so you'll probably want to add your own improvements/touches to it, since this script is like 3 years old :o