Advertisement
vertrex

Level Script

Mar 3rd, 2012
113
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 17.08 KB | None | 0 0
  1. <?php
  2. $Ladder_File = "./var/ladder.txt";
  3. $player_names = null;
  4. $Commands_Selector["bombs"] = null;
  5. $Commands_Selector["rush"] = "true 0 0";
  6. $Game_Time = null;
  7. while (1) {
  8.     $line = rtrim(fgets(STDIN, 1024));
  9.     if (preg_match("/^INVALID_COMMAND/", $line)) {
  10.         $invalid_cmd = explode(" ", $line);
  11.         $command = $invalid_cmd[1];
  12.         $player_calling = $invalid_cmd[2];
  13.         if ($command == "/enemy" || $command == "/enemies") {
  14.             $player_calling_count = 0;
  15.             while ($player_calling_count < count($GLOBALS["player_names"])) {
  16.                 if ($GLOBALS["player_names"][$player_calling_count][$player_calling] != "") {
  17.                     $invalid_command_string = explode(" ".$invalid_cmd[4]." ", $line);
  18.                     if (isset($invalid_command_string[1])) {
  19.                         echo "CONSOLE_MESSAGE 0x00ff00".$GLOBALS["player_names"][$player_calling_count][$player_calling]." 0xffff77--> 0xff0000Enemies0xffff77: ".$invalid_command_string[1]."\n";
  20.                     }
  21.                     else {
  22.                         echo "CONSOLE_MESSAGE 0xffff00".$GLOBALS["player_names"][$player_calling_count][$player_calling]." 0xffff77--> 0xff0000Enemies0xffff77: \n";
  23.                     };
  24.                 };
  25.                 $player_calling_count++;
  26.             };
  27.         }
  28.         elseif ($command == "/stats") {
  29.             $Ladder_File_Load = file_get_contents($Ladder_File);
  30.             $Ladder_File_List_Load = explode("\n", $Ladder_File_Load);
  31.             $Ladder_List_Count = 0;
  32.             $Player_Ladder_Name_Found = false;
  33.             $Player_Ladder_Name = null;
  34.             while ($Ladder_List_Count < count($Ladder_File_List_Load)) {
  35.                 $Player_Ladder_Name = explode(" ", $Ladder_File_List_Load[$Ladder_List_Count]);
  36.                 $Player_Ladder_Name[3] = trim(filter_var(str_replace("\n","",$Player_Ladder_Name[3]), FILTER_SANITIZE_STRING));
  37.                 if ($Player_Ladder_Name[3] != "") {
  38.                     if ($player_calling == $Player_Ladder_Name[3]) {
  39.                         echo "PLAYER_MESSAGE ".$player_calling.' "0xff7700##################################################"'."\n";
  40.                         $Ladder_LEVEL = $Player_Ladder_Name[0];
  41.                         for ($a_count = 0; $a_count < (15 - strlen($Ladder_LEVEL)); $a_count++) {
  42.                             $Ladder_LEVEL .= " ";
  43.                         };
  44.                         echo "PLAYER_MESSAGE ".$player_calling.' "0xff7700####         0xffff00Your current level is: 0x00ffff'.$Ladder_LEVEL.' 0xff7700####"'."\n";
  45.                         $Ladder_EXP = $Player_Ladder_Name[1];
  46.                         for ($a_count = 0; $a_count < (15 - strlen($Ladder_EXP)); $a_count++) {
  47.                             $Ladder_EXP .= " ";
  48.                         };
  49.                         echo "PLAYER_MESSAGE ".$player_calling.' "0xff7700####         0xffff00Your current EXP is  : 0x00ffff'.$Ladder_EXP.' 0xff7700####"'."\n";
  50.                         $Ladder_Remaining_EXP = $Player_Ladder_Name[2] - $Player_Ladder_Name[1];
  51.                         for ($a_count = 0; $a_count < (14 - strlen($Ladder_Remaining_EXP)); $a_count++) {
  52.                             $Ladder_Remaining_EXP .= " ";
  53.                         };
  54.                         echo "PLAYER_MESSAGE ".$player_calling.' "0xff7700####         0xffff00EXP left to level up : 0x00ffff'.$Ladder_Remaining_EXP.' 0xff7700####"'."\n";
  55.                         echo "PLAYER_MESSAGE ".$player_calling.' "0xff7700##################################################"'."\n";
  56.                     };
  57.                 };
  58.                 $Ladder_List_Count++;
  59.             };
  60.         }
  61.         elseif ($command == "/rush") {
  62.             if ($Commands_Extrator[0] == "true") {
  63.                 $Commands_Extrator = explode(" ", $GLOBALS["Commands_Selector"]["rush"]);
  64.                 $Ladder_File_Load = file_get_contents($Ladder_File);
  65.                 $Ladder_File_List_Load = explode("\n", $Ladder_File_Load);
  66.                 $Ladder_List_Count = 0;
  67.                 $Player_Ladder_Name_Found = false;
  68.                 $Player_Ladder_Name = null;
  69.                 while ($Ladder_List_Count < count($Ladder_File_List_Load)) {
  70.                     $Player_Ladder_Name = explode(" ", $Ladder_File_List_Load[$Ladder_List_Count]);
  71.                     $Player_Ladder_Name[3] = trim(filter_var(str_replace("\n","",$Player_Ladder_Name[3]), FILTER_SANITIZE_STRING));
  72.                     echo "CONSOLE_MESSAGE 0x00ffffRush Hour0xffff00: 0x00ff00ACTIVATED!\n";
  73.                     echo "SHOT_THRESH 0.1\n";
  74.                     echo "SHOT_DISCARD_TIME 2\n";
  75.                     echo "MEGA_SHOT_THRESH 0.1\n";
  76.                     echo "MEGA_SHOT_DIR 8\n";
  77.                     echo "SHOT_WALL_BOUNCE 15\n";
  78.                     $GLOBALS["Commands_Selector"]["rush"] = "false 30 0";
  79.                     $Ladder_List_Count++;
  80.                 };
  81.             }
  82.             elseif ($Commands_Extrator[0] == "false") {
  83.                 echo "CONSOLE_MESSAGE 0x00ffffRush Hour is either activated or is still recharging.\n";
  84.             };
  85.         }
  86.         elseif ($command == "/bombs") {
  87.             $Ladder_File_Load = file_get_contents($Ladder_File);
  88.             $Ladder_File_List_Load = explode("\n", $Ladder_File_Load);
  89.             $Ladder_List_Count = 0;
  90.             $Player_Ladder_Name_Found = false;
  91.             $Player_Ladder_Name = null;
  92.             while ($Ladder_List_Count < count($Ladder_File_List_Load)) {
  93.                 $Player_Ladder_Name = explode(" ", $Ladder_File_List_Load[$Ladder_List_Count]);
  94.                 $Player_Ladder_Name[3] = trim(filter_var(str_replace("\n","",$Player_Ladder_Name[3]), FILTER_SANITIZE_STRING));
  95.                 if ($Player_Ladder_Name[3] != "") {
  96.                     if ($player_calling == $Player_Ladder_Name[3]) {
  97.                         if ($Player_Ladder_Name[0] >= 10) {
  98.                             $Commands_Selector_Counter = 0;
  99.                             while ($Commands_Selector_Counter < count($GLOBALS["Commands_Selector"]["bombs"])) {
  100.                                 $Commands_Selector_Spliter = explode(" ", $GLOBALS["Commands_Selector"]["bombs"][$Commands_Selector_Counter]);
  101.                                 $Commands_Selector_Player = $Commands_Selector_Spliter[0];
  102.                                 $Commands_Selector_Option = $Commands_Selector_Spliter[1];
  103.                                 $Commands_Selector_Ticker = $Commands_Selector_Spliter[2];
  104.                                 $Commands_Selector_Ticks = $Commands_Selector_Spliter[3];
  105.                                 if ($player_calling == $Commands_Selector_Player) {
  106.                                     if ($Commands_Selector_Option != "false") {
  107.                                         $bomb_spawn_count = 496;
  108.                                         echo "SPAWN_ZONE deathTeam no_team L ".$bomb_spawn_count." -368 ".$bomb_spawn_count." -624 ".$bomb_spawn_count." -112 ".$bomb_spawn_count." Z 10 -0.5 0 60 false\n";
  109.                                         for ($bomb_count = 0; $bomb_count < 8; $bomb_count++) {
  110.                                             $bomb_spawn_count += 20;
  111.                                             echo "SPAWN_ZONE deathTeam no_team L ".$bomb_spawn_count." -368 ".$bomb_spawn_count." -624 ".$bomb_spawn_count." -112 ".$bomb_spawn_count." Z 10 -0.5 0 60 false\n";
  112.                                         };
  113.                                         $GLOBALS["Commands_Selector"]["bombs"][$Commands_Selector_Counter] = $player_calling." false 40 0";
  114.                                     }
  115.                                     else {
  116.                                         echo "CENTER_MESSAGE 0x50ffff".$player_calling." 0xffff00cannot call the bomber because it is already used. 0xff0000".(20 - $Commands_Selector_Ticks). "0xffff00seconds left to refill.\n";
  117.                                     };
  118.                                 };
  119.                                 $Commands_Selector_Counter++;
  120.                             };
  121.                         };
  122.                     };
  123.                 };
  124.                 $Ladder_List_Count++;
  125.             };
  126.         };
  127.     }
  128.     elseif (preg_match("/^PLAYER_LEFT/", $line)) {
  129.         $playername = explode(" ", $line);
  130.         $playername_sel = $playername[1];
  131.         $playername_mirror = $GLOBALS["player_names"];
  132.         $GLOBALS["player_names"] = null;
  133.         $playersname_sel_num = 0;
  134.         while ($playersname_sel_num < count($playername_mirror)) {
  135.             if ($playername_mirror[$playersname_sel_num][$playername_sel] != "") {
  136.                 $playername_mirror[$playersname_sel_num] = null;
  137.             };
  138.             $playersname_sel_num++;
  139.         };
  140.         $playersname_sel_num = 0;
  141.         $playername_counter_add = 0;
  142.         while ($playersname_sel_num <  count($playername_mirror)) {
  143.             if ($playername_mirror[$playersname_sel_num] != null) {
  144.                 $GLOBALS["player_names"][$playername_counter_add] = $playername_mirror[$playersname_sel_num];
  145.                 $playername_counter_add++;
  146.             };
  147.             $playersname_sel_num++;
  148.         };
  149.         $Commands_Selector_Mirror = $Commands_Selector;
  150.         $Commands_Selector = null;
  151.         $Commands_Selector_Counter = 0;
  152.         while ($Commands_Selector_Counter < count($Commands_Selector_Mirror["bombs"])) {
  153.             $Commands_Selector_Spliter = explode(" ", $Commands_Selector_Mirror["bombs"][$Commands_Selector_Counter]);
  154.             $Commands_Selector_Player = $Commands_Selector_Spliter[0];
  155.             $Commands_Selector_Option = $Commands_Selector_Spliter[1];
  156.             $Commands_Selector_Ticker = $Commands_Selector_Spliter[2];
  157.             $Commands_Selector_Ticks = $Commands_Selector_Spliter[3];
  158.             if ($playername_sel == $Commands_Selector_Player) {
  159.                 $Commands_Selector_Mirror["bombs"][$Commands_Selector_Counter] = null;
  160.             };
  161.             $Commands_Selector_Counter++;
  162.         };
  163.         $playersname_sel_num = 0;
  164.         $playername_counter_add = 0;
  165.         while ($playersname_sel_num <  count($Commands_Selector_Mirror["bombs"])) {
  166.             if ($Commands_Selector_Mirror["bombs"][$playersname_sel_num] != null) {
  167.                 $GLOBALS["Commands_Selector"]["bombs"][$playername_counter_add] = $Commands_Selector_Mirror["bombs"][$playersname_sel_num];
  168.                 $playername_counter_add++;
  169.             };
  170.             $playersname_sel_num++;
  171.         };
  172.     }
  173.     if (preg_match("/^PLAYER_RENAMED/", $line)) {
  174.         $playername = explode(" ", $line);
  175.         $playername_last = explode(" ".$playername[4]." ", $line);
  176.         $playername_select = 0;
  177.         $player_name_found = false;
  178.         while ($playername_select < count($GLOBALS["player_names"])) {
  179.             if ($GLOBALS["player_names"][$playername_select][$playername[2]] != "") {
  180.                 $GLOBALS["player_names"][$playername_select][$playername[2]] = $playername_last[1];
  181.                 $player_name_found = true;
  182.             };
  183.             $playername_select++;
  184.         };
  185.         if ($player_name_found == false) {
  186.             $GLOBALS["player_names"][count($GLOBALS["player_names"])] = array($playername[2] => $playername_last[1]);
  187.             $GLOBALS["Commands_Selector"]["bombs"][count($GLOBALS["Commands_Selector"]["bombs"])] = $playername[2]." true 0 0";
  188.         };
  189.         $Ladder_File_Load = file_get_contents($Ladder_File);
  190.         $Ladder_File_List_Load = explode("\n", $Ladder_File_Load);
  191.         $Ladder_List_Count = 0;
  192.         $Player_Ladder_Name_Found = false;
  193.         $Player_Ladder_Name = null;
  194.         while ($Ladder_List_Count < count($Ladder_File_List_Load)) {
  195.             $Player_Ladder_Name = explode(" ", $Ladder_File_List_Load[$Ladder_List_Count]);
  196.             $Player_Ladder_Name[3] = trim(filter_var(str_replace("\n","",$Player_Ladder_Name[3]), FILTER_SANITIZE_STRING));
  197.             if ($Player_Ladder_Name[3] != "") {
  198.                 if ($playername[2] == $Player_Ladder_Name[3]) {
  199.                     $Player_Ladder_Name_Found = true;
  200.                 };
  201.             };
  202.             $Ladder_List_Count++;
  203.         };
  204.         if ($Player_Ladder_Name_Found == false) {
  205.             $Ladder_File_Write = fopen($Ladder_File, "a+");
  206.             fwrite($Ladder_File_Write, "1 0 50 ".$playername[2]."\n");
  207.             fclose($Ladder_File_Write);
  208.         };
  209.     }
  210.     elseif (preg_match("/^PLAYER_ENTERED/", $line)) {
  211.         $playername = explode(" ", $line);
  212.         $playername_last = explode(" ".$playername[2]." ", $line);
  213.         if (count($GLOBALS["player_names"]) == 0) {
  214.             $GLOBALS["player_names"][0] = array($playername[1] => $playername_last[1]);
  215.             $GLOBALS["Commands_Selector"]["bombs"][0] = $playername[1]." true 0 0";
  216.         }
  217.         else {
  218.             $playername_count = count($GLOBALS["player_names"]);
  219.             $GLOBALS["player_names"][$playername_count] = array($playername[1] =>  $playername_last[1]);
  220.             $GLOBALS["Commands_Selector"]["bombs"][count($GLOBALS["Commands_Selector"]["bombs"])] = $playername[1]." true 0 0";
  221.         };
  222.         $Ladder_File_Load = file_get_contents($Ladder_File);
  223.         $Ladder_File_List_Load = explode("\n", $Ladder_File_Load);
  224.         $Ladder_List_Count = 0;
  225.         $Player_Ladder_Name_Found = false;
  226.         while ($Ladder_List_Count < count($Ladder_File_List_Load)) {
  227.             $Player_Ladder_Name = explode(" ", $Ladder_File_List_Load[$Ladder_List_Count]);
  228.             $Player_Ladder_Name[3] = trim(filter_var(str_replace("\n","",$Player_Ladder_Name[3]), FILTER_SANITIZE_STRING));
  229.             if ($Player_Ladder_Name[3] != "") {
  230.                 if ($playername[1] == $Player_Ladder_Name[3]) {
  231.                     $Player_Ladder_Name_Found = true;
  232.                 };
  233.             };
  234.             $Ladder_List_Count++;
  235.         };
  236.         if ($Player_Ladder_Name_Found == false) {
  237.             $Ladder_File_Write = fopen($Ladder_File, "a+");
  238.             fwrite($Ladder_File_Write, "1 0 50 ".$playername[1]."\n");
  239.             fclose($Ladder_File_Write);
  240.         };
  241.     }
  242.     elseif (preg_match("/^DEATH_SHOT_FRAG/", $line)) {
  243.         $prey = "";
  244.         $preditor = "";
  245.         $playerladdername = explode(" ", $line);
  246.         $prey = $playerladdername[1];
  247.         $preditor = $playerladdername[2];
  248.         $Ladder_File_Load = file_get_contents($Ladder_File);
  249.         $Ladder_File_List_Load = explode("\n", $Ladder_File_Load);
  250.         $Ladder_List_Count = 0;
  251.         $Ladder_Ranks_File = fopen($Ladder_File, "w+");
  252.         while ($Ladder_List_Count < count($Ladder_File_List_Load)) {
  253.             $Player_Ladder_Name = explode(" ", $Ladder_File_List_Load[$Ladder_List_Count]);
  254.             $Player_Ladder_Name[3] = trim(filter_var(str_replace("\n","",$Player_Ladder_Name[3]), FILTER_SANITIZE_STRING));
  255.             if ($Player_Ladder_Name[3] != "") {
  256.                 if ($prey == $Player_Ladder_Name[3]) {
  257.                     if ($Player_Ladder_Name[0] != 1) {
  258.                         $player_calling_count = 0;
  259.                         $Player_Ladder_Name[0] -= 1;
  260.                         $Player_Ladder_Name[2] -= 50;
  261.                         $Player_Ladder_Name[1] = $Player_Ladder_Name[2];
  262.                         while ($player_calling_count < count($GLOBALS["player_names"])) {
  263.                             if ($GLOBALS["player_names"][$player_calling_count][$prey] != "") {
  264.                                 echo "CONSOLE_MESSAGE 0x00ffff".$GLOBALS["player_names"][$player_calling_count][$prey]." 0xffff00has dropped a level and is currently 0xff00ffLevel ".$Player_Ladder_Name[0]."\n";
  265.                             };
  266.                             $player_calling_count++;
  267.                         };
  268.                     }
  269.                     else {
  270.                         if ($Player_Ladder_Name[1] != 0) {
  271.                             $Player_Ladder_Name[1] -= 12.5;
  272.                             $player_calling_count = 0;
  273.                             while ($player_calling_count < count($GLOBALS["player_names"])) {
  274.                                 if ($GLOBALS["player_names"][$player_calling_count][$prey] != "") {
  275.                                     echo "CONSOLE_MESSAGE 0x00ffff".$GLOBALS["player_names"][$player_calling_count][$prey]." 0xffff00has lost 0xff000012.5 0xffff00Exp but stayed at 0xff00ffLevel ".$Player_Ladder_Name[0]."\n";
  276.                                 };
  277.                                 $player_calling_count++;
  278.                             };
  279.                         };
  280.                     };
  281.                 }
  282.                 elseif ($preditor == $Player_Ladder_Name[3]) {
  283.                     if ($Player_Ladder_Name[1] ==  $Player_Ladder_Name[2]) {
  284.                         $player_calling_count = 0;
  285.                         $Player_Ladder_Name[0] += 1;
  286.                         $Player_Ladder_Name[2] += 50;
  287.                         $Player_Ladder_Name[1] = 0;
  288.                         while ($player_calling_count < count($GLOBALS["player_names"])) {
  289.                             if ($GLOBALS["player_names"][$player_calling_count][$preditor] != "") {
  290.                                 echo "CONSOLE_MESSAGE 0x00ffff".$GLOBALS["player_names"][$player_calling_count][$preditor]." 0xffff00has gained a level and is currently 0xff00ffLevel ".$Player_Ladder_Name[0]."\n";
  291.                             };
  292.                             $player_calling_count++;
  293.                         }
  294.                     }
  295.                     else {
  296.                         $Player_Ladder_Name[1] += 25;
  297.                         $player_calling_count = 0;
  298.                         while ($player_calling_count < count($GLOBALS["player_names"])) {
  299.                             if ($GLOBALS["player_names"][$player_calling_count][$preditor] != "") {
  300.                                 echo "CONSOLE_MESSAGE 0x00ffff".$GLOBALS["player_names"][$player_calling_count][$preditor]." 0xffff00has gained 0xff000012.5 0xffff00Exp but stayed at 0xff00ffLevel ".$Player_Ladder_Name[0]."\n";
  301.                             };
  302.                             $player_calling_count++;
  303.                         };
  304.  
  305.                     };
  306.                 };
  307.                 fwrite($Ladder_Ranks_File, $Player_Ladder_Name[0]." ".$Player_Ladder_Name[1]." ".$Player_Ladder_Name[2]." ".$Player_Ladder_Name[3]."\n");
  308.             };
  309.             $Ladder_List_Count++;
  310.         };
  311.         fclose($Ladder_Ranks_File);
  312.     }
  313.     elseif (preg_match("/^ROUND_COMMENCING/", $line)) {
  314.         echo "CONSOLE_MESSAGE 0x00ffffRush Hour0xffff0: 0xff0000DISABLED!\n";
  315.         echo "SHOT_THRESH 0.1\n";
  316.         echo "SHOT_DISCARD_TIME 2\n";
  317.         echo "MEGA_SHOT_THRESH 1.0\n";
  318.         echo "MEGA_SHOT_DIR 2\n";
  319.         echo "SHOT_WALL_BOUNCE 5\n";
  320.         $GLOBALS["Commands_Selector"]["rush"] = "true 30 0";
  321.     }
  322.     elseif (preg_match("/^GAME_TIME/", $line)) {
  323.         $gametime = explode(" ", $line);
  324.         $Game_Time = $gametime[1];
  325.         $Commands_Selector_Counter = 0;
  326.         while ($Commands_Selector_Counter < count($GLOBALS["Commands_Selector"]["bombs"])) {
  327.             $Commands_Selector_Spliter = explode(" ", $GLOBALS["Commands_Selector"]["bombs"][$Commands_Selector_Counter]);
  328.             $Commands_Selector_Player = $Commands_Selector_Spliter[0];
  329.             $Commands_Selector_Option = $Commands_Selector_Spliter[1];
  330.             $Commands_Selector_Ticker = $Commands_Selector_Spliter[2];
  331.             $Commands_Selector_Ticks = $Commands_Selector_Spliter[3];
  332.             if ($Commands_Selector_Option == "false") {
  333.                 if ($Commands_Selector_Ticker != $Commands_Selector_Ticks) {
  334.                     $Commands_Selector_Ticks++;
  335.                     $GLOBALS["Commands_Selector"]["bombs"][$Commands_Selector_Counter] = $Commands_Selector_Player." ".$Commands_Selector_Option." ".$Commands_Selector_Ticker." ".$Commands_Selector_Ticks;
  336.                 }
  337.                 elseif ($Commands_Selector_Ticker == $Commands_Selector_Ticks) {
  338.                     $Commands_Selector_Option = "true";
  339.                     $GLOBALS["Commands_Selector"]["bombs"][$Commands_Selector_Counter] = $Commands_Selector_Player." ".$Commands_Selector_Option." ".$Commands_Selector_Ticker." ".$Commands_Selector_Ticks;
  340.                 };
  341.             };
  342.         };
  343.         $Commands_Extrator = explode(" ", $GLOBALS["Commands_Selector"]["rush"]);
  344.         if ($Commands_Extrator[0] == "false") {
  345.             $Commands_Extrator[2]++;
  346.             if ($Commands_Extrator[2] < 10) {
  347.                 echo "CONSOLE_MESSAGE 0x00ffffRush Hour0xffff0: 0xff0000".(10 - $Commands_Extrator[2])." 0xffff00seconds left!\n";
  348.                 $GLOBALS["Commands_Selector"]["rush"] = "false 30 ".$Commands_Extrator[2];
  349.             }
  350.             elseif ($Commands_Extrator[2] == 10) {
  351.                 echo "CONSOLE_MESSAGE 0x00ffffRush Hour0xffff0: 0xff0000DISABLED!\n";
  352.                 echo "SHOT_THRESH 0.1\n";
  353.                 echo "SHOT_DISCARD_TIME 2\n";
  354.                 echo "MEGA_SHOT_THRESH 1.0\n";
  355.                 echo "MEGA_SHOT_DIR 2\n";
  356.                 echo "SHOT_WALL_BOUNCE 5\n";
  357.                 $GLOBALS["Commands_Selector"]["rush"] = "false 30 ".$Commands_Extrator[2];
  358.             }
  359.             elseif ($Commands_Extrator[2] == 30) {
  360.                 echo "CONSOLE_MESSAGE 0x00ffffRush Hour0xffff0: 0xff00fReload Complete!\n";
  361.                 $GLOBALS["Commands_Selector"]["rush"] = "true 0 0";
  362.             };
  363.         };
  364.     };
  365. };
  366. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement