Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- $Ladder_File = "/home/vertrex/armagetronad/servers/alpha1/var/ladder.txt";
- $player_names = null;
- $Commands_Selector["bombs"] = null;
- $Commands_Selector["rush"] = "true 0 0";
- $Game_Time = null;
- while (1) {
- $line = rtrim(fgets(STDIN, 1024));
- if (preg_match("/^INVALID_COMMAND/", $line)) {
- $invalid_cmd = explode(" ", $line);
- $command = $invalid_cmd[1];
- $player_calling = $invalid_cmd[2];
- if ($command == "/enemy" || $command == "/enemies") {
- $player_calling_count = 0;
- while ($player_calling_count < count($GLOBALS["player_names"])) {
- if ($GLOBALS["player_names"][$player_calling_count][$player_calling] != "") {
- $invalid_command_string = explode(" ".$invalid_cmd[4]." ", $line);
- if (isset($invalid_command_string[1])) {
- echo "CONSOLE_MESSAGE 0x00ff00".$GLOBALS["player_names"][$player_calling_count][$player_calling]." 0xffff77--> 0xff0000Enemies0xffff77: ".$invalid_command_string[1]."\n";
- }
- else {
- echo "CONSOLE_MESSAGE 0xffff00".$GLOBALS["player_names"][$player_calling_count][$player_calling]." 0xffff77--> 0xff0000Enemies0xffff77: \n";
- };
- };
- $player_calling_count++;
- };
- }
- elseif ($command == "/stats") {
- $Ladder_File_Load = file_get_contents($Ladder_File);
- $Ladder_File_List_Load = explode("\n", $Ladder_File_Load);
- $Ladder_List_Count = 0;
- $Player_Ladder_Name_Found = false;
- $Player_Ladder_Name = null;
- while ($Ladder_List_Count < count($Ladder_File_List_Load)) {
- $Player_Ladder_Name = explode(" ", $Ladder_File_List_Load[$Ladder_List_Count]);
- $Player_Ladder_Name[3] = trim(filter_var(str_replace("\n","",$Player_Ladder_Name[3]), FILTER_SANITIZE_STRING));
- if (array_key_exists(3, $Player_Ladder_Name)) {
- if ($player_calling == $Player_Ladder_Name[3]) {
- echo "PLAYER_MESSAGE ".$player_calling.' "0xff7700##################################################"'."\n";
- $Ladder_LEVEL = $Player_Ladder_Name[0];
- for ($a_count = 0; $a_count < (15 - strlen($Ladder_LEVEL)); $a_count++) {
- $Ladder_LEVEL .= " ";
- };
- echo "PLAYER_MESSAGE ".$player_calling.' "0xff7700#### 0xffff00Your current level is: 0x00ffff'.$Ladder_LEVEL.' 0xff7700####"'."\n";
- $Ladder_EXP = $Player_Ladder_Name[1];
- for ($a_count = 0; $a_count < (15 - strlen($Ladder_EXP)); $a_count++) {
- $Ladder_EXP .= " ";
- };
- echo "PLAYER_MESSAGE ".$player_calling.' "0xff7700#### 0xffff00Your current EXP is : 0x00ffff'.$Ladder_EXP.' 0xff7700####"'."\n";
- $Ladder_Remaining_EXP = $Player_Ladder_Name[2] - $Player_Ladder_Name[1];
- for ($a_count = 0; $a_count < (14 - strlen($Ladder_Remaining_EXP)); $a_count++) {
- $Ladder_Remaining_EXP .= " ";
- };
- echo "PLAYER_MESSAGE ".$player_calling.' "0xff7700#### 0xffff00EXP left to level up : 0x00ffff'.$Ladder_Remaining_EXP.' 0xff7700####"'."\n";
- echo "PLAYER_MESSAGE ".$player_calling.' "0xff7700##################################################"'."\n";
- };
- };
- $Ladder_List_Count++;
- };
- }
- elseif ($command == "/rush") {
- if ($Commands_Extrator[0] == "true") {
- $Commands_Extrator = explode(" ", $GLOBALS["Commands_Selector"]["rush"]);
- $Ladder_File_Load = file_get_contents($Ladder_File);
- $Ladder_File_List_Load = explode("\n", $Ladder_File_Load);
- $Ladder_List_Count = 0;
- $Player_Ladder_Name_Found = false;
- $Player_Ladder_Name = null;
- while ($Ladder_List_Count < count($Ladder_File_List_Load)) {
- $Player_Ladder_Name = explode(" ", $Ladder_File_List_Load[$Ladder_List_Count]);
- $Player_Ladder_Name[3] = trim(filter_var(str_replace("\n","",$Player_Ladder_Name[3]), FILTER_SANITIZE_STRING));
- echo "CONSOLE_MESSAGE 0x00ffffRush Hour0xffff00: 0x00ff00ACTIVATED!\n";
- echo "SHOT_THRESH 0.1\n";
- echo "SHOT_DISCARD_TIME 2\n";
- echo "MEGA_SHOT_THRESH 0.1\n";
- echo "MEGA_SHOT_DIR 8\n";
- echo "SHOT_WALL_BOUNCE 15\n";
- $GLOBALS["Commands_Selector"]["rush"] = "false 30 0";
- $Ladder_List_Count++;
- };
- }
- elseif ($Commands_Extrator[0] == "false") {
- echo "CONSOLE_MESSAGE 0x00ffffRush Hour is either activated or is still recharging.\n";
- };
- }
- elseif ($command == "/bombs") {
- $Ladder_File_Load = file_get_contents($Ladder_File);
- $Ladder_File_List_Load = explode("\n", $Ladder_File_Load);
- $Ladder_List_Count = 0;
- $Player_Ladder_Name_Found = false;
- $Player_Ladder_Name = null;
- while ($Ladder_List_Count < count($Ladder_File_List_Load)) {
- $Player_Ladder_Name = explode(" ", $Ladder_File_List_Load[$Ladder_List_Count]);
- $Player_Ladder_Name[3] = trim(filter_var(str_replace("\n","",$Player_Ladder_Name[3]), FILTER_SANITIZE_STRING));
- if ($Player_Ladder_Name[3] != "") {
- if ($player_calling == $Player_Ladder_Name[3]) {
- if ($Player_Ladder_Name[0] >= 10) {
- $Commands_Selector_Counter = 0;
- while ($Commands_Selector_Counter < count($GLOBALS["Commands_Selector"]["bombs"])) {
- $Commands_Selector_Spliter = explode(" ", $GLOBALS["Commands_Selector"]["bombs"][$Commands_Selector_Counter]);
- $Commands_Selector_Player = $Commands_Selector_Spliter[0];
- $Commands_Selector_Option = $Commands_Selector_Spliter[1];
- $Commands_Selector_Ticker = $Commands_Selector_Spliter[2];
- $Commands_Selector_Ticks = $Commands_Selector_Spliter[3];
- if ($player_calling == $Commands_Selector_Player) {
- if ($Commands_Selector_Option != "false") {
- $bomb_spawn_count = 496;
- 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";
- for ($bomb_count = 0; $bomb_count < 8; $bomb_count++) {
- $bomb_spawn_count += 20;
- 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";
- };
- $GLOBALS["Commands_Selector"]["bombs"][$Commands_Selector_Counter] = $player_calling." false 40 0";
- }
- else {
- 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";
- };
- };
- $Commands_Selector_Counter++;
- };
- };
- };
- };
- $Ladder_List_Count++;
- };
- };
- }
- elseif (preg_match("/^PLAYER_LEFT/", $line)) {
- $playername = explode(" ", $line);
- $playername_sel = $playername[1];
- $playername_mirror = $GLOBALS["player_names"];
- $GLOBALS["player_names"] = null;
- $playersname_sel_num = 0;
- while ($playersname_sel_num < count($playername_mirror)) {
- if ($playername_mirror[$playersname_sel_num][$playername_sel] != "") {
- $playername_mirror[$playersname_sel_num] = null;
- };
- $playersname_sel_num++;
- };
- $playersname_sel_num = 0;
- $playername_counter_add = 0;
- while ($playersname_sel_num < count($playername_mirror)) {
- if ($playername_mirror[$playersname_sel_num] != null) {
- $GLOBALS["player_names"][$playername_counter_add] = $playername_mirror[$playersname_sel_num];
- $playername_counter_add++;
- };
- $playersname_sel_num++;
- };
- $Commands_Selector_Mirror = $Commands_Selector;
- $Commands_Selector = null;
- $Commands_Selector_Counter = 0;
- while ($Commands_Selector_Counter < count($Commands_Selector_Mirror["bombs"])) {
- $Commands_Selector_Spliter = explode(" ", $Commands_Selector_Mirror["bombs"][$Commands_Selector_Counter]);
- $Commands_Selector_Player = $Commands_Selector_Spliter[0];
- $Commands_Selector_Option = $Commands_Selector_Spliter[1];
- $Commands_Selector_Ticker = $Commands_Selector_Spliter[2];
- $Commands_Selector_Ticks = $Commands_Selector_Spliter[3];
- if ($playername_sel == $Commands_Selector_Player) {
- $Commands_Selector_Mirror["bombs"][$Commands_Selector_Counter] = null;
- };
- $Commands_Selector_Counter++;
- };
- $playersname_sel_num = 0;
- $playername_counter_add = 0;
- while ($playersname_sel_num < count($Commands_Selector_Mirror["bombs"])) {
- if ($Commands_Selector_Mirror["bombs"][$playersname_sel_num] != null) {
- $GLOBALS["Commands_Selector"]["bombs"][$playername_counter_add] = $Commands_Selector_Mirror["bombs"][$playersname_sel_num];
- $playername_counter_add++;
- };
- $playersname_sel_num++;
- };
- }
- if (preg_match("/^PLAYER_RENAMED/", $line)) {
- $playername = explode(" ", $line);
- $playername_last = explode(" ".$playername[4]." ", $line);
- $playername_select = 0;
- $player_name_found = false;
- while ($playername_select < count($GLOBALS["player_names"])) {
- if ($GLOBALS["player_names"][$playername_select][$playername[2]] != "") {
- $GLOBALS["player_names"][$playername_select][$playername[2]] = $playername_last[1];
- $player_name_found = true;
- };
- $playername_select++;
- };
- if ($player_name_found == false) {
- $GLOBALS["player_names"][count($GLOBALS["player_names"])] = array($playername[2] => $playername_last[1]);
- $GLOBALS["Commands_Selector"]["bombs"][count($GLOBALS["Commands_Selector"]["bombs"])] = $playername[2]." true 0 0";
- };
- $Ladder_File_Load = file_get_contents($Ladder_File);
- $Ladder_File_List_Load = explode("\n", $Ladder_File_Load);
- $Ladder_List_Count = 0;
- $Player_Ladder_Name_Found = false;
- $Player_Ladder_Name = null;
- while ($Ladder_List_Count < count($Ladder_File_List_Load)) {
- $Player_Ladder_Name = explode(" ", $Ladder_File_List_Load[$Ladder_List_Count]);
- $Player_Ladder_Name[3] = trim(filter_var(str_replace("\n","",$Player_Ladder_Name[3]), FILTER_SANITIZE_STRING));
- if (array_key_exists(3, $Player_Ladder_Name)) {
- if ($playername[2] == $Player_Ladder_Name[3]) {
- $Player_Ladder_Name_Found = true;
- };
- };
- $Ladder_List_Count++;
- };
- if ($Player_Ladder_Name_Found == false) {
- $Ladder_File_Write = fopen($Ladder_File, "a+");
- fwrite($Ladder_File_Write, "1 0 50 ".$playername[2]."\n");
- fclose($Ladder_File_Write);
- };
- }
- elseif (preg_match("/^PLAYER_ENTERED/", $line)) {
- $playername = explode(" ", $line);
- $playername_last = explode(" ".$playername[2]." ", $line);
- if (count($GLOBALS["player_names"]) == 0) {
- $GLOBALS["player_names"][0] = array($playername[1] => $playername_last[1]);
- $GLOBALS["Commands_Selector"]["bombs"][0] = $playername[1]." true 0 0";
- }
- else {
- $playername_count = count($GLOBALS["player_names"]);
- $GLOBALS["player_names"][$playername_count] = array($playername[1] => $playername_last[1]);
- $GLOBALS["Commands_Selector"]["bombs"][count($GLOBALS["Commands_Selector"]["bombs"])] = $playername[1]." true 0 0";
- };
- $Ladder_File_Load = file_get_contents($Ladder_File);
- $Ladder_File_List_Load = explode("\n", $Ladder_File_Load);
- $Ladder_List_Count = 0;
- $Player_Ladder_Name_Found = false;
- while ($Ladder_List_Count < count($Ladder_File_List_Load)) {
- $Player_Ladder_Name = explode(" ", $Ladder_File_List_Load[$Ladder_List_Count]);
- $Player_Ladder_Name[3] = trim(filter_var(str_replace("\n","",$Player_Ladder_Name[3]), FILTER_SANITIZE_STRING));
- if (array_key_exists(3, $Player_Ladder_Name)) {
- if ($playername[1] == $Player_Ladder_Name[3]) {
- $Player_Ladder_Name_Found = true;
- };
- };
- $Ladder_List_Count++;
- };
- if ($Player_Ladder_Name_Found == false) {
- $Ladder_File_Write = fopen($Ladder_File, "a+");
- fwrite($Ladder_File_Write, "1 0 50 ".$playername[1]."\n");
- fclose($Ladder_File_Write);
- };
- }
- elseif (preg_match("/^DEATH_SHOT_FRAG/", $line)) {
- $prey = "";
- $preditor = "";
- $playerladdername = explode(" ", $line);
- $prey = $playerladdername[1];
- $preditor = $playerladdername[2];
- $Ladder_File_Load = file_get_contents($Ladder_File);
- $Ladder_File_List_Load = explode("\n", $Ladder_File_Load);
- $Ladder_List_Count = 0;
- $Ladder_Ranks_File = fopen($Ladder_File, "w+");
- while ($Ladder_List_Count < count($Ladder_File_List_Load)) {
- $Player_Ladder_Name = explode(" ", $Ladder_File_List_Load[$Ladder_List_Count]);
- $Player_Ladder_Name[3] = trim(filter_var(str_replace("\n","",$Player_Ladder_Name[3]), FILTER_SANITIZE_STRING));
- if (array_key_exists(3, $Player_Ladder_Name)) {
- if ($prey == $Player_Ladder_Name[3]) {
- if ($Player_Ladder_Name[0] != 1) {
- $player_calling_count = 0;
- $Player_Ladder_Name[0] -= 1;
- $Player_Ladder_Name[2] -= 50;
- $Player_Ladder_Name[1] = $Player_Ladder_Name[2];
- while ($player_calling_count < count($GLOBALS["player_names"])) {
- if ($GLOBALS["player_names"][$player_calling_count][$prey] != "") {
- echo "CONSOLE_MESSAGE 0x00ffff".$GLOBALS["player_names"][$player_calling_count][$prey]." 0xffff00has dropped a level and is currently 0xff00ffLevel ".$Player_Ladder_Name[0]."\n";
- };
- $player_calling_count++;
- };
- }
- else {
- if ($Player_Ladder_Name[1] != 0) {
- $Player_Ladder_Name[1] -= 12.5;
- $player_calling_count = 0;
- while ($player_calling_count < count($GLOBALS["player_names"])) {
- if ($GLOBALS["player_names"][$player_calling_count][$prey] != "") {
- 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";
- };
- $player_calling_count++;
- };
- };
- };
- }
- elseif ($preditor == $Player_Ladder_Name[3]) {
- if ($Player_Ladder_Name[1] == $Player_Ladder_Name[2]) {
- $player_calling_count = 0;
- $Player_Ladder_Name[0] += 1;
- $Player_Ladder_Name[2] += 50;
- $Player_Ladder_Name[1] = 0;
- while ($player_calling_count < count($GLOBALS["player_names"])) {
- if ($GLOBALS["player_names"][$player_calling_count][$preditor] != "") {
- echo "CONSOLE_MESSAGE 0x00ffff".$GLOBALS["player_names"][$player_calling_count][$preditor]." 0xffff00has gained a level and is currently 0xff00ffLevel ".$Player_Ladder_Name[0]."\n";
- };
- $player_calling_count++;
- }
- }
- else {
- $Player_Ladder_Name[1] += 25;
- $player_calling_count = 0;
- while ($player_calling_count < count($GLOBALS["player_names"])) {
- if ($GLOBALS["player_names"][$player_calling_count][$preditor] != "") {
- 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";
- };
- $player_calling_count++;
- };
- };
- };
- fwrite($Ladder_Ranks_File, $Player_Ladder_Name[0]." ".$Player_Ladder_Name[1]." ".$Player_Ladder_Name[2]." ".$Player_Ladder_Name[3]."\n");
- };
- $Ladder_List_Count++;
- };
- fclose($Ladder_Ranks_File);
- }
- elseif (preg_match("/^ROUND_COMMENCING/", $line)) {
- echo "CONSOLE_MESSAGE 0x00ffffRush Hour0xffff0: 0xff0000DISABLED!\n";
- echo "SHOT_THRESH 0.1\n";
- echo "SHOT_DISCARD_TIME 2\n";
- echo "MEGA_SHOT_THRESH 1.0\n";
- echo "MEGA_SHOT_DIR 2\n";
- echo "SHOT_WALL_BOUNCE 5\n";
- $GLOBALS["Commands_Selector"]["rush"] = "true 30 0";
- }
- elseif (preg_match("/^GAME_TIME/", $line)) {
- $gametime = explode(" ", $line);
- $Game_Time = $gametime[1];
- $Commands_Selector_Counter = 0;
- while ($Commands_Selector_Counter < count($GLOBALS["Commands_Selector"]["bombs"])) {
- $Commands_Selector_Spliter = explode(" ", $GLOBALS["Commands_Selector"]["bombs"][$Commands_Selector_Counter]);
- $Commands_Selector_Player = $Commands_Selector_Spliter[0];
- $Commands_Selector_Option = $Commands_Selector_Spliter[1];
- $Commands_Selector_Ticker = $Commands_Selector_Spliter[2];
- $Commands_Selector_Ticks = $Commands_Selector_Spliter[3];
- if ($Commands_Selector_Option == "false") {
- if ($Commands_Selector_Ticker != $Commands_Selector_Ticks) {
- $Commands_Selector_Ticks++;
- $GLOBALS["Commands_Selector"]["bombs"][$Commands_Selector_Counter] = $Commands_Selector_Player." ".$Commands_Selector_Option." ".$Commands_Selector_Ticker." ".$Commands_Selector_Ticks;
- }
- elseif ($Commands_Selector_Ticker == $Commands_Selector_Ticks) {
- $Commands_Selector_Option = "true";
- $GLOBALS["Commands_Selector"]["bombs"][$Commands_Selector_Counter] = $Commands_Selector_Player." ".$Commands_Selector_Option." ".$Commands_Selector_Ticker." ".$Commands_Selector_Ticks;
- };
- };
- };
- $Commands_Extrator = explode(" ", $GLOBALS["Commands_Selector"]["rush"]);
- if ($Commands_Extrator[0] == "false") {
- $Commands_Extrator[2]++;
- if ($Commands_Extrator[2] < 10) {
- echo "CONSOLE_MESSAGE 0x00ffffRush Hour0xffff0: 0xff0000".(10 - $Commands_Extrator[2])." 0xffff00seconds left!\n";
- $GLOBALS["Commands_Selector"]["rush"] = "false 30 ".$Commands_Extrator[2];
- }
- elseif ($Commands_Extrator[2] == 10) {
- echo "CONSOLE_MESSAGE 0x00ffffRush Hour0xffff0: 0xff0000DISABLED!\n";
- echo "SHOT_THRESH 0.1\n";
- echo "SHOT_DISCARD_TIME 2\n";
- echo "MEGA_SHOT_THRESH 1.0\n";
- echo "MEGA_SHOT_DIR 2\n";
- echo "SHOT_WALL_BOUNCE 5\n";
- $GLOBALS["Commands_Selector"]["rush"] = "false 30 ".$Commands_Extrator[2];
- }
- elseif ($Commands_Extrator[2] == 30) {
- echo "CONSOLE_MESSAGE 0x00ffffRush Hour0xffff0: 0xff00fReload Complete!\n";
- $GLOBALS["Commands_Selector"]["rush"] = "true 0 0";
- };
- };
- };
- };
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement