void Player_PlayerDeath(Player p, byte deathblock) { if (started) { if (p.level == mainlevel) { if (GetPlayer(p).hasflag) { if (redteam.members.Contains(p)) { Player.GlobalMessageLevel(mainlevel, redteam.color + p.name + " DROPPED THE FLAG!"); GetPlayer(p).points -= caplose; mainlevel.Blockchange(redbase.x, redbase.y, redbase.z, Block.red); } else if (blueteam.members.Contains(p)) { Player.GlobalMessageLevel(mainlevel, blueteam.color + p.name + " DROPPED THE FLAG!"); GetPlayer(p).points -= caplose; mainlevel.Blockchange(bluebase.x, bluebase.y, bluebase.z, Block.blue); } GetPlayer(p).hasflag = false; } } } }
public override void Use(Player p, string message) { if (message == "") { Help(p); return; } int number = message.Split(' ').Length; if (number > 2 || number < 1) { Help(p); return; } if (number == 1) { LevelPermission Perm = Level.PermissionFromName(message); if (Perm == LevelPermission.Null) { Player.SendMessage(p, "Not a valid rank"); return; } if (p.level.permissionvisit > p.group.Permission) { Player.SendMessage(p, "You cannot change the pervisit of a level with a pervisit higher than your rank."); return; } p.level.permissionvisit = Perm; Server.s.Log(p.level.name + " visit permission changed to " + message + "."); Player.GlobalMessageLevel(p.level, "visit permission changed to " + message + "."); } else { int pos = message.IndexOf(' '); string t = message.Substring(0, pos).ToLower(); string s = message.Substring(pos + 1).ToLower(); LevelPermission Perm = Level.PermissionFromName(s); if (Perm == LevelPermission.Null) { Player.SendMessage(p, "Not a valid rank"); return; } Level level = Level.Find(t); if (level != null) { level.permissionvisit = Perm; Server.s.Log(level.name + " visit permission changed to " + s + "."); Player.GlobalMessageLevel(level, "visit permission changed to " + s + "."); if (p != null) { if (p.level != level) { Player.SendMessage(p, "visit permission changed to " + s + " on " + level.name + "."); } } return; } else { Player.SendMessage(p, "There is no level \"" + s + "\" loaded."); } } }
void tagging_Elapsed(object sender, System.Timers.ElapsedEventArgs e) { Player.players.ForEach(delegate(Player p) { if (p.level == mainlevel) { ushort x = p.pos[0]; ushort y = p.pos[1]; ushort z = p.pos[2]; Base b = null; if (redteam.members.Contains(p)) { b = redbase; } else if (blueteam.members.Contains(p)) { b = bluebase; } else { return; } if (GetPlayer(p).tagging) { return; } if (OnSide(p, b)) { List <Player> temp = redteam.members; if (redteam.members.Contains(p)) { temp = blueteam.members; } foreach (Player p1 in temp) { if (Math.Abs((p1.pos[0] / 32) - (x / 32)) < 5 && Math.Abs((p1.pos[1] / 32) - (y / 32)) < 5 && Math.Abs((p1.pos[2] / 32) - (z / 32)) < 5 && !GetPlayer(p).tagging) { GetPlayer(p1).tagging = true; Player.SendMessage(p1, p.color + p.name + Server.DefaultColor + " tagged you!"); b.SendToSpawn(mainlevel, this, p1); Thread.Sleep(300); if (GetPlayer(p1).hasflag) { Player.GlobalMessageLevel(mainlevel, redteam.color + p.name + " DROPPED THE FLAG!"); GetPlayer(p1).points -= caplose; mainlevel.Blockchange(b.x, b.y, b.z, b.block); GetPlayer(p1).hasflag = false; } GetPlayer(p).points += tagpoint; GetPlayer(p1).points -= taglose; GetPlayer(p).tag++; GetPlayer(p1).tagging = false; } } } } Thread.Sleep(100); }); }
//Main Game Finishes Here - support functions after this public void InfectedPlayerDC() { if (Server.gameStatus == 0) { return; } //This is for when the first zombie disconnects Random random = new Random(); if (Server.players == 0 || Server.players == 1) { HandOutRewards(); return; } if ((Server.gameStatus != 0 && Server.zombieRound) && infectd.Count <= 0) { int firstinfect = random.Next(alive.Count) - 1; if (firstinfect < 0) { firstinfect = 0; } while (alive[firstinfect].referee == true || alive[firstinfect].level.name == Server.zombie.currentLevelName) { int tries = 0; if (firstinfect == alive.Count - 1) { firstinfect = 0; tries++; } else { firstinfect++; } if (tries > 3) { HandOutRewards(); return; } } Player.GlobalMessageLevel(Level.Find(currentLevelName), Player.MessageType.Announcement, alive[firstinfect].color + alive[firstinfect].name + Server.DefaultColor + " continued the infection!"); Thread.Sleep(3000); Player.GlobalMessageLevel(Level.Find(currentLevelName), Player.MessageType.Announcement, ""); alive[firstinfect].color = c.red; Player.GlobalDie(alive[firstinfect], false); Player.GlobalSpawn(alive[firstinfect], alive[firstinfect].pos[0], alive[firstinfect].pos[1], alive[firstinfect].pos[2], alive[firstinfect].rot[0], alive[firstinfect].rot[1], false); infectd.Add(alive[firstinfect]); alive[firstinfect].model = "zombie"; alive.Remove(alive[firstinfect]); return; } if ((Server.gameStatus != 0 && Server.zombieRound) && alive.Count == 0) { HandOutRewards(); } }
public void EndRound(object sender, ElapsedEventArgs e) { if (Server.gameStatus == 0) { return; } Player.GlobalMessageLevel(Level.Find(currentLevelName), Player.MessageType.Announcement, "&4Round End:&f 5"); Thread.Sleep(1000); Player.GlobalMessageLevel(Level.Find(currentLevelName), Player.MessageType.Announcement, "&4Round End:&f 4"); Thread.Sleep(1000); Player.GlobalMessageLevel(Level.Find(currentLevelName), Player.MessageType.Announcement, "&4Round End:&f 3"); Thread.Sleep(1000); Player.GlobalMessageLevel(Level.Find(currentLevelName), Player.MessageType.Announcement, "&4Round End:&f 2"); Thread.Sleep(1000); Player.GlobalMessageLevel(Level.Find(currentLevelName), Player.MessageType.Announcement, "&4Round End:&f 1"); Thread.Sleep(1000); HandOutRewards(); }
string Vote() { started = false; vote1 = 0; vote2 = 0; vote3 = 0; Random rand = new Random(); List <string> maps1 = maps; map1 = maps1[rand.Next(maps1.Count)]; maps1.Remove(map1); map2 = maps1[rand.Next(maps1.Count)]; maps1.Remove(map2); map3 = maps1[rand.Next(maps1.Count)]; Player.GlobalMessageLevel(mainlevel, "%2VOTE:"); Player.GlobalMessageLevel(mainlevel, "1. " + map1 + " 2. " + map2 + " 3. " + map3); voting = true; int seconds = rand.Next(15, 61); Player.GlobalMessageLevel(mainlevel, "You have " + seconds + " seconds to vote!"); Thread.Sleep(seconds * 1000); voting = false; Player.GlobalMessageLevel(mainlevel, "VOTING ENDED!"); Thread.Sleep(rand.Next(1, 10) * 1000); if (vote1 > vote2 && vote1 > vote3) { Player.GlobalMessageLevel(mainlevel, map1 + " WON!"); return(map1); } if (vote2 > vote1 && vote2 > vote3) { Player.GlobalMessageLevel(mainlevel, map2 + " WON!"); return(map2); } if (vote3 > vote2 && vote3 > vote1) { Player.GlobalMessageLevel(mainlevel, map3 + " WON!"); return(map3); } else { Player.GlobalMessageLevel(mainlevel, "There was a tie!"); Player.GlobalMessageLevel(mainlevel, "I'll choose!"); return(maps[rand.Next(maps.Count)]); } }
void End() { started = false; string nextmap = ""; string winner = ""; Teams winnerteam = null; if (blueteam.points >= maxpoints || blueteam.points > redteam.points) { winnerteam = blueteam; winner = "blue team"; } else if (redteam.points >= maxpoints || redteam.points > blueteam.points) { winnerteam = redteam; winner = "red team"; } else { Player.GlobalMessageLevel(mainlevel, "The game ended in a tie!"); } Player.GlobalMessageLevel(mainlevel, "The winner was " + winnerteam.color + winner + "!!"); Thread.Sleep(4000); //MYSQL! cache.ForEach(delegate(Data d) { string commandString = "UPDATE CTF SET Points=@Points, Captures=@Captures, tags=@Tags WHERE Name=@Name"; d.hasflag = false; Database.AddParams("@Points", d.points); Database.AddParams("@Captures", d.cap); Database.AddParams("@Tags", d.tag); Database.AddParams("@Name", d.p.name); Database.executeQuery(commandString); }); nextmap = Vote(); Player.GlobalMessageLevel(mainlevel, "Starting a new game!"); redbase = null; redteam = null; bluebase = null; blueteam = null; bluebase = new Base(); redbase = new Base(); Thread.Sleep(2000); LoadMap(nextmap); }
void Player_PlayerDisconnect(Player p, string reason) { if (p.level == mainlevel) { if (blueteam.members.Contains(p)) { //cache.Remove(GetPlayer(p)); blueteam.members.Remove(p); Player.GlobalMessageLevel(mainlevel, p.color + p.name + " " + blueteam.color + "left the ctf game"); } else if (redteam.members.Contains(p)) { //cache.Remove(GetPlayer(p)); redteam.members.Remove(p); Player.GlobalMessageLevel(mainlevel, p.color + p.name + " " + redteam.color + "left the ctf game"); } } }
public void ChangeLevel(string LevelName, bool changeMainLevel) { String next = LevelName; currentLevelName = next; Server.queLevel = false; Server.nextLevel = ""; Command.all.Find("load").Use(null, next.ToLower() + " 4"); Level.Find(next).mapType = MapType.Game; Level.Find(next).unload = false; Level.Find(next).mapType = MapType.Game; Player.GlobalMessageLevel(Level.Find(currentLevelName), Player.MessageType.Status2, "The next map has been chosen - " + c.red + next.ToLower()); Player.GlobalMessageLevel(Level.Find(currentLevelName), Player.MessageType.Status3, "Please wait while you are transfered."); String oldLevel = Server.mainLevel.name; if (changeMainLevel) { Server.mainLevel = Level.Find(next.ToLower()); } { Player.players.ForEach(delegate(Player player) { if (player.level.name != next && player.level.name == currentLevelName) { player.SendMessage("Going to the next map!"); Command.all.Find("goto").Use(player, next); while (player.Loading) { Thread.Sleep(890); } } }); Command.all.Find("unload").Use(null, oldLevel); } Player.GlobalMessageLevel(Level.Find(currentLevelName), Player.MessageType.Status2, "&f"); Player.GlobalMessageLevel(Level.Find(currentLevelName), Player.MessageType.Status3, "&f"); return; }
static void CheckXP() { Player.players.ForEach(delegate(Player pl) { try { EXPLevel nextLevel = EXPLevel.Find(pl.explevel.levelID + 1); if (nextLevel != null && pl.points >= nextLevel.requiredEXP) { pl.explevel = nextLevel; pl.money += nextLevel.reward; Player.GlobalMessageLevel(Level.Find(Server.zombie.currentLevelName), Player.MessageType.Chat, pl.color + pl.name + Server.DefaultColor + " has leveled up to level &a" + nextLevel.levelID + "!"); pl.SendMessage(Player.MessageType.Announcement, "You have just leveled up to level &a" + nextLevel.levelID + "!", true); pl.SendMessage("&6You were rewarded &a" + nextLevel.reward + " " + Server.moneys + ".", true); Thread.Sleep(3000); pl.SendMessage(Player.MessageType.Announcement, "", true); } } catch { // user probably only just connected- so explevel wont have been set yet. } }); }
void Player_PlayerCommand(string cmd, Player p, string message) { if (started) { if (cmd == "teamchat" && p.level == mainlevel) { if (GetPlayer(p) != null) { Data d = GetPlayer(p); if (d.chatting) { Player.SendMessage(d.p, "You are no longer chatting with your team!"); d.chatting = !d.chatting; } else { Player.SendMessage(d.p, "You are now chatting with your team!"); d.chatting = !d.chatting; } Plugin.CancelPlayerEvent(PlayerEvents.PlayerCommand, p); } } if (cmd == "goto") { if (message == "ctf" && p.level != mainlevel) { if (blueteam.members.Count > redteam.members.Count) { if (GetPlayer(p) == null) { cache.Add(new Data(false, p)); } else { GetPlayer(p).hasflag = false; GetPlayer(p).blue = false; } redteam.Add(p); Player.GlobalMessageLevel(mainlevel, p.color + p.name + " " + c.Parse("red") + "joined the RED Team"); Player.SendMessage(p, c.Parse("red") + "You are now on the red team!"); } else if (redteam.members.Count > blueteam.members.Count) { if (GetPlayer(p) == null) { cache.Add(new Data(true, p)); } else { GetPlayer(p).hasflag = false; GetPlayer(p).blue = true; } blueteam.Add(p); Player.GlobalMessageLevel(mainlevel, p.color + p.name + " " + c.Parse("blue") + "joined the BLUE Team"); Player.SendMessage(p, c.Parse("blue") + "You are now on the blue team!"); } else if (new Random().Next(2) == 0) { if (GetPlayer(p) == null) { cache.Add(new Data(false, p)); } else { GetPlayer(p).hasflag = false; GetPlayer(p).blue = false; } redteam.Add(p); Player.GlobalMessageLevel(mainlevel, p.color + p.name + " " + c.Parse("red") + "joined the RED Team"); Player.SendMessage(p, c.Parse("red") + "You are now on the red team!"); } else { if (GetPlayer(p) == null) { cache.Add(new Data(true, p)); } else { GetPlayer(p).hasflag = false; GetPlayer(p).blue = true; } blueteam.Add(p); Player.GlobalMessageLevel(mainlevel, p.color + p.name + " " + c.Parse("blue") + "joined the BLUE Team"); Player.SendMessage(p, c.Parse("blue") + "You are now on the blue team!"); } } else if (message != "ctf" && p.level == mainlevel) { if (blueteam.members.Contains(p)) { //cache.Remove(GetPlayer(p)); blueteam.members.Remove(p); Player.GlobalMessageLevel(mainlevel, p.color + p.name + " " + blueteam.color + "left the ctf game"); } else if (redteam.members.Contains(p)) { //cache.Remove(GetPlayer(p)); redteam.members.Remove(p); Player.GlobalMessageLevel(mainlevel, p.color + p.name + " " + redteam.color + "left the ctf game"); } } } } }
void Player_PlayerBlockChange(Player p, ushort x, ushort y, ushort z, byte type) { if (started) { if (p.level == mainlevel && !blueteam.members.Contains(p) && !redteam.members.Contains(p)) { p.SendBlockchange(x, y, z, p.level.GetTile(x, y, z)); Player.SendMessage(p, "You are not on a team!"); Plugin.CancelPlayerEvent(PlayerEvents.BlockChange, p); } if (p.level == mainlevel && blueteam.members.Contains(p) && x == redbase.x && y == redbase.y && z == redbase.z && mainlevel.GetTile(redbase.x, redbase.y, redbase.z) != Block.air) { Player.GlobalMessageLevel(mainlevel, blueteam.color + p.name + " took the " + redteam.color + " red team's FLAG!"); GetPlayer(p).hasflag = true; } if (p.level == mainlevel && redteam.members.Contains(p) && x == bluebase.x && y == bluebase.y && z == bluebase.z && mainlevel.GetTile(bluebase.x, bluebase.y, bluebase.z) != Block.air) { Player.GlobalMessageLevel(mainlevel, redteam.color + p.name + " took the " + blueteam.color + " blue team's FLAG"); GetPlayer(p).hasflag = true; } if (p.level == mainlevel && blueteam.members.Contains(p) && x == bluebase.x && y == bluebase.y && z == bluebase.z && mainlevel.GetTile(bluebase.x, bluebase.y, bluebase.z) != Block.air) { if (GetPlayer(p).hasflag) { Player.GlobalMessageLevel(mainlevel, blueteam.color + p.name + " RETURNED THE FLAG!"); GetPlayer(p).hasflag = false; GetPlayer(p).cap++; GetPlayer(p).points += cappoint; blueteam.points++; mainlevel.Blockchange(redbase.x, redbase.y, redbase.z, Block.red); p.SendBlockchange(x, y, z, p.level.GetTile(x, y, z)); Plugin.CancelPlayerEvent(PlayerEvents.BlockChange, p); if (blueteam.points >= maxpoints) { End(); return; } } else { Player.SendMessage(p, "You cant take your own flag!"); p.SendBlockchange(x, y, z, p.level.GetTile(x, y, z)); Plugin.CancelPlayerEvent(PlayerEvents.BlockChange, p); } } if (p.level == mainlevel && redteam.members.Contains(p) && x == redbase.x && y == redbase.y && z == redbase.z && mainlevel.GetTile(redbase.x, redbase.y, redbase.z) != Block.air) { if (GetPlayer(p).hasflag) { Player.GlobalMessageLevel(mainlevel, redteam.color + p.name + " RETURNED THE FLAG!"); GetPlayer(p).hasflag = false; GetPlayer(p).points += cappoint; GetPlayer(p).cap++; redteam.points++; mainlevel.Blockchange(bluebase.x, bluebase.y, bluebase.z, Block.blue); p.SendBlockchange(x, y, z, p.level.GetTile(x, y, z)); Plugin.CancelPlayerEvent(PlayerEvents.BlockChange, p); if (redteam.points >= maxpoints) { End(); return; } } else { Player.SendMessage(p, "You cant take your own flag!"); p.SendBlockchange(x, y, z, p.level.GetTile(x, y, z)); Plugin.CancelPlayerEvent(PlayerEvents.BlockChange, p); } } } }
public override void Use(Player p, string message) { if (message == "") { Help(p); return; } if (p == null) { Server.s.Log("'null' or console tried to use /countdown. This command is limited to ingame, sorry!!"); return; } string[] command = message.ToLower().Split(' '); string par0 = String.Empty; string par1 = String.Empty; string par2 = String.Empty; string par3 = String.Empty; try { par0 = command[0]; par1 = command[1]; par2 = command[2]; par3 = command[3]; } catch { } if (par0 == "help") { Command.all.Find("help").Use(p, "countdown"); return; } if (par0 == "goto") { try { Command.all.Find("goto").Use(p, "countdown"); } catch { Player.SendMessage(p, "Countdown level not loaded"); return; } } else if (par0 == "join") { switch (CountdownGame.gamestatus) { case CountdownGameStatus.Disabled: Player.SendMessage(p, "Sorry - Countdown isn't enabled yet"); return; case CountdownGameStatus.Enabled: if (!CountdownGame.players.Contains(p)) { CountdownGame.players.Add(p); Player.SendMessage(p, "You've joined the Countdown game!!"); Player.GlobalMessage(p.name + " has joined Countdown!!"); if (p.level != CountdownGame.mapon) { Player.SendMessage(p, "You can type '/countdown goto' to goto the countdown map!!"); } p.playerofcountdown = true; } else { Player.SendMessage(p, "Sorry, you have already joined!!, to leave please type /countdown leave"); return; } break; case CountdownGameStatus.AboutToStart: Player.SendMessage(p, "Sorry - The game is about to start"); return;; case CountdownGameStatus.InProgress: Player.SendMessage(p, "Sorry - The game is already in progress."); return; case CountdownGameStatus.Finished: Player.SendMessage(p, "Sorry - The game has finished. Get an op to reset it."); return; } } else if (par0 == "leave") { if (CountdownGame.players.Contains(p)) { switch (CountdownGame.gamestatus) { case CountdownGameStatus.Disabled: Player.SendMessage(p, "Sorry - Countdown isn't enabled yet"); return; case CountdownGameStatus.Enabled: CountdownGame.players.Remove(p); CountdownGame.playersleftlist.Remove(p); Player.SendMessage(p, "You've left the game."); p.playerofcountdown = false; break; case CountdownGameStatus.AboutToStart: Player.SendMessage(p, "Sorry - The game is about to start"); return;; case CountdownGameStatus.InProgress: Player.SendMessage(p, "Sorry - you are in a game that is in progress, please wait till its finished or till you've died."); return; case CountdownGameStatus.Finished: CountdownGame.players.Remove(p); if (CountdownGame.playersleftlist.Contains(p)) { CountdownGame.playersleftlist.Remove(p); } p.playerofcountdown = false; Player.SendMessage(p, "You've left the game."); break; } } else if (!(CountdownGame.playersleftlist.Contains(p)) && CountdownGame.players.Contains(p)) { CountdownGame.players.Remove(p); Player.SendMessage(p, "You've left the game."); } else { Player.SendMessage(p, "You haven't joined the game yet!!"); return; } } else if (par0 == "players") { switch (CountdownGame.gamestatus) { case CountdownGameStatus.Disabled: Player.SendMessage(p, "The game has not been enabled yet."); return; case CountdownGameStatus.Enabled: Player.SendMessage(p, "Players who have joined:"); foreach (Player plya in CountdownGame.players) { Player.SendMessage(p, plya.color + plya.name); } break; case CountdownGameStatus.AboutToStart: Player.SendMessage(p, "Players who are about to play:"); foreach (Player plya in CountdownGame.players) { { Player.SendMessage(p, plya.color + plya.name); } } break; case CountdownGameStatus.InProgress: Player.SendMessage(p, "Players left playing:"); foreach (Player plya in CountdownGame.players) { { if (CountdownGame.playersleftlist.Contains(plya)) { Player.SendMessage(p, plya.color + plya.name + Server.DefaultColor + " who is &aIN"); } else { Player.SendMessage(p, plya.color + plya.name + Server.DefaultColor + " who is &cOUT"); } } } break; case CountdownGameStatus.Finished: Player.SendMessage(p, "Players who were playing:"); foreach (Player plya in CountdownGame.players) { Player.SendMessage(p, plya.color + plya.name); } break; } } else if (par0 == "rules") { if (String.IsNullOrEmpty(par1)) { Player.SendMessage(p, "The aim of the game is to stay alive the longest."); Player.SendMessage(p, "Don't fall in the lava!!"); Player.SendMessage(p, "Blocks on the ground will disapear randomly, first going yellow, then orange, then red and finally disappering."); Player.SendMessage(p, "The last person alive will win!!"); } else if (par1 == "send") { if ((int)p.group.Permission >= CommandOtherPerms.GetPerm(this, 1)) { if (par2 == "all") { Player.GlobalMessage("Countdown Rules being sent to everyone by " + p.color + p.name + ":"); Player.GlobalMessage("The aim of the game is to stay alive the longest."); Player.GlobalMessage("Don't fall in the lava!!"); Player.GlobalMessage("Blocks on the ground will disapear randomly, first going yellow, then orange, then red and finally disappering."); Player.GlobalMessage("The last person alive will win!!"); Player.SendMessage(p, "Countdown rules sent to everyone"); } else if (par2 == "map") { Player.GlobalMessageLevel(p.level, "Countdown Rules being sent to " + p.level.name + " by " + p.color + p.name + ":"); Player.GlobalMessageLevel(p.level, "The aim of the game is to stay alive the longest."); Player.GlobalMessageLevel(p.level, "Don't fall in the lava!!"); Player.GlobalMessageLevel(p.level, "Blocks on the ground will disapear randomly, first going yellow, then orange, then red and finally disappering."); Player.GlobalMessageLevel(p.level, "The last person alive will win!!"); Player.SendMessage(p, "Countdown rules sent to: " + p.level.name); } } else if (!String.IsNullOrEmpty(par2)) { Player who = Player.Find(par2); if (who == null) { Player.SendMessage(p, "That wasn't an online player."); return; } else if (who == p) { Player.SendMessage(p, "You can't send rules to yourself, use '/countdown rules' to send it to your self!!"); return; } else if (p.group.Permission < who.group.Permission) { Player.SendMessage(p, "You can't send rules to someone of a higher rank than yourself!!"); return; } else { Player.SendMessage(who, "Countdown rules sent to you by " + p.color + p.name); Player.SendMessage(who, "The aim of the game is to stay alive the longest."); Player.SendMessage(who, "Don't fall in the lava!!"); Player.SendMessage(who, "Blocks on the ground will disapear randomly, first going yellow, then orange, then red and finally disawhowhoering."); Player.SendMessage(who, "The last person alive will win!!"); Player.SendMessage(p, "Countdown rules sent to: " + who.color + who.name); } } else { Player.SendMessage(p, par1 + " wasn't a correct parameter."); return; } } } else if ((int)p.group.Permission >= CommandOtherPerms.GetPerm(this, 2)) { if (par0 == "download") { try { using (WebClient WEB = new WebClient()) { WEB.DownloadFile("http://db.tt/R0x1MFS", "levels/countdown.lvl"); Player.SendMessage(p, "Downloaded map, now loading map and sending you to it."); } } catch { Player.SendMessage(p, "Sorry, Downloading Failed. PLease try again later"); return; } Command.all.Find("load").Use(p, "countdown"); Command.all.Find("goto").Use(p, "countdown"); Thread.Sleep(1000); // Sleep for a bit while they load while (p.Loading) { Thread.Sleep(250); } p.level.permissionbuild = LevelPermission.Nobody; p.level.motd = "Welcome to the Countdown map!!!! -hax"; ushort x = System.Convert.ToUInt16(8); ushort y = System.Convert.ToUInt16(23); ushort z = System.Convert.ToUInt16(17); x *= 32; x += 16; y *= 32; y += 32; z *= 32; z += 16; unchecked { p.SendPos((byte)-1, x, y, z, p.rot[0], p.rot[1]); } } else if (par0 == "enable") { if (CountdownGame.gamestatus == CountdownGameStatus.Disabled) { try { Command.all.Find("load").Use(null, "countdown"); CountdownGame.mapon = Level.Find("countdown"); CountdownGame.gamestatus = CountdownGameStatus.Enabled; Player.GlobalMessage("Countdown has been enabled!!"); } catch { Player.SendMessage(p, "Failed, have you downloaded the map yet??"); } } else { Player.SendMessage(p, "A Game is either already enabled or is already progress"); return; } } else if (par0 == "disable") { if (CountdownGame.gamestatus == CountdownGameStatus.AboutToStart || CountdownGame.gamestatus == CountdownGameStatus.InProgress) { Player.SendMessage(p, "Sorry, a game is currently in progress - please wait till its finished or use '/countdown cancel' to cancel the game"); return; } else if (CountdownGame.gamestatus == CountdownGameStatus.Disabled) { Player.SendMessage(p, "Already disabled!!"); return; } else { foreach (Player pl in CountdownGame.players) { Player.SendMessage(pl, "The countdown game was disabled."); } CountdownGame.gamestatus = CountdownGameStatus.Disabled; CountdownGame.playersleft = 0; CountdownGame.playersleftlist.Clear(); CountdownGame.players.Clear(); CountdownGame.squaresleft.Clear(); CountdownGame.Reset(p, true); Player.SendMessage(p, "Countdown Disabled"); return; } } else if (par0 == "cancel") { if (CountdownGame.gamestatus == CountdownGameStatus.AboutToStart || CountdownGame.gamestatus == CountdownGameStatus.InProgress) { CountdownGame.cancel = true; Thread.Sleep(1500); Player.SendMessage(p, "Countdown has been canceled"); CountdownGame.gamestatus = CountdownGameStatus.Enabled; return; } else { if (CountdownGame.gamestatus == CountdownGameStatus.Disabled) { Player.SendMessage(p, "The game is disabled!!"); return; } else { foreach (Player pl in CountdownGame.players) { Player.SendMessage(pl, "The countdown game was canceled"); } CountdownGame.gamestatus = CountdownGameStatus.Enabled; CountdownGame.playersleft = 0; CountdownGame.playersleftlist.Clear(); CountdownGame.players.Clear(); CountdownGame.squaresleft.Clear(); CountdownGame.Reset(null, true); return; } } } else if (par0 == "start" || par0 == "play") { if (CountdownGame.gamestatus == CountdownGameStatus.Enabled) { if (CountdownGame.players.Count >= 2) { CountdownGame.playersleftlist = CountdownGame.players; CountdownGame.playersleft = CountdownGame.players.Count; switch (par1) { case "slow": CountdownGame.speed = 800; CountdownGame.speedtype = "slow"; break; case "normal": CountdownGame.speed = 650; CountdownGame.speedtype = "normal"; break; case "fast": CountdownGame.speed = 500; CountdownGame.speedtype = "fast"; break; case "extreme": CountdownGame.speed = 300; CountdownGame.speedtype = "extreme"; break; case "ultimate": CountdownGame.speed = 150; CountdownGame.speedtype = "ultimate"; break; default: p.SendMessage("You didn't specify a speed, resorting to 'normal'"); goto case "normal"; //More efficient } if (par2 == null || par2.Trim() == "") { CountdownGame.freezemode = false; } else { if (par2 == "freeze" || par2 == "frozen") { CountdownGame.freezemode = true; } else { CountdownGame.freezemode = false; } } CountdownGame.GameStart(p); } else { Player.SendMessage(p, "Sorry, there aren't enough players to play."); return; } } else { Player.SendMessage(p, "Either a game is already in progress or it hasn't been enabled"); return; } } else if (par0 == "reset") { switch (CountdownGame.gamestatus) { case CountdownGameStatus.Disabled: Player.SendMessage(p, "Please enable countdown first."); return; case CountdownGameStatus.AboutToStart: Player.SendMessage(p, "Sorry - The game is about to start"); return; case CountdownGameStatus.InProgress: Player.SendMessage(p, "Sorry - The game is already in progress."); return; default: Player.SendMessage(p, "Reseting"); if (par1 == "map") { CountdownGame.Reset(p, false); } else if (par1 == "all") { CountdownGame.Reset(p, true); } else { Player.SendMessage(p, "Please specify whether it is 'map' or 'all'"); return; } break; } } else if (par0 == "tutorial") { p.SendMessage("First, download the map using /countdown download"); p.SendMessage("Next, type /countdown enable to enable the game mode"); p.SendMessage("Next, type /countdown join to join the game and tell other players to join aswell"); p.SendMessage("When some people have joined, type /countdown start [speed] to start it"); p.SendMessage("[speed] can be 'ultimate', 'extreme', 'fast', 'normal' or 'slow'"); p.SendMessage("When you are done, type /countdown reset [map/all]"); p.SendMessage("use map to reset only the map and all to reset everything."); return; } } else { p.SendMessage("Sorry, you aren't a high enough rank or that wasn't a correct command addition."); return; } }
void tagging_Elapsed(object sender, System.Timers.ElapsedEventArgs e) { Player.players.ForEach(delegate(Player p) { if (p.level == mainlevel) { ushort x = p.pos[0]; ushort y = p.pos[1]; ushort z = p.pos[2]; Base b = null; if (redteam.members.Contains(p)) { b = redbase; } else if (blueteam.members.Contains(p)) { b = bluebase; } else { return; } if (GetPlayer(p).tagging) { return; } if (OnSide(p, b)) { List <Player> temp = redteam.members; if (redteam.members.Contains(p)) { temp = blueteam.members; } foreach (Player p1 in temp) { if (Math.Abs((p1.pos[0] / 32) - (x / 32)) < 5 && Math.Abs((p1.pos[1] / 32) - (y / 32)) < 5 && Math.Abs((p1.pos[2] / 32) - (z / 32)) < 5 && !GetPlayer(p).tagging) { GetPlayer(p1).tagging = true; Player.SendMessage(p1, p.color + p.name + Server.DefaultColor + " tagged you!"); Random rand = new Random(); ushort xx = (ushort)(rand.Next(0, mainlevel.width)); ushort yy = (ushort)(rand.Next(0, mainlevel.depth)); ushort zz = (ushort)(rand.Next(0, mainlevel.height)); while (mainlevel.GetTile(xx, yy, zz) != Block.air && OnSide((ushort)(zz * 32), b)) { xx = (ushort)(rand.Next(0, mainlevel.width)); yy = (ushort)(rand.Next(0, mainlevel.depth)); zz = (ushort)(rand.Next(0, mainlevel.height)); } unchecked { p1.SendPos((byte)-1, (ushort)(xx * 32), (ushort)(yy * 32), (ushort)(zz * 32), p1.rot[0], p1.rot[1]); } Thread.Sleep(300); if (GetPlayer(p1).hasflag) { Player.GlobalMessageLevel(mainlevel, redteam.color + p.name + " DROPPED THE FLAG!"); GetPlayer(p1).points -= caplose; mainlevel.Blockchange(b.x, b.y, b.z, b.block); GetPlayer(p1).hasflag = false; } GetPlayer(p).points += tagpoint; GetPlayer(p1).points -= taglose; GetPlayer(p).tag++; GetPlayer(p1).tagging = false; } } } } Thread.Sleep(100); }); }
public void HandOutRewards() { Server.zombieRound = false; amountOfMilliseconds = 0; if (Server.gameStatus == 0) { return; } Player.GlobalMessageLevel(Level.Find(currentLevelName), Player.MessageType.Announcement, c.lime + "The game has ended!"); if (aliveCount == 0) { Player.GlobalMessageLevel(Level.Find(currentLevelName), Player.MessageType.Status2, c.maroon + "Zombies have won this round."); } else { Player.GlobalMessageLevel(Level.Find(currentLevelName), Player.MessageType.Status2, c.green + "Congratulations to our survivor(s)"); } timer.Enabled = false; string playersString = ""; if (aliveCount == 0) { foreach (Player winners in Player.players) { if (winners.level.name == currentLevelName) { winners.blockCount = 50; winners.infected = false; winners.infectThisRound = 0; if (winners.level.name == currentLevelName) { winners.color = winners.group.color; playersString += winners.group.color + winners.name + c.white + ", "; } } } } else { alive.ForEach(delegate(Player winners) { winners.blockCount = 50; winners.infected = false; winners.infectThisRound = 0; if (winners.level.name == currentLevelName) { winners.color = winners.group.color; playersString += winners.group.color + winners.name + c.white + ", "; } }); } Player.GlobalMessageLevel(Level.Find(currentLevelName), Player.MessageType.Status3, playersString); foreach (Player winners in Player.players) { if (aliveCount == 0 && winners.level.name == currentLevelName) { Player.GlobalDie(winners, false); Player.GlobalSpawn(winners, winners.pos[0], winners.pos[1], winners.pos[2], winners.rot[0], winners.rot[1], false); Random random2 = new Random(); int randomInt = 0; if (winners.playersInfected > 5) { randomInt = random2.Next(1, winners.playersInfected); } else { randomInt = random2.Next(1, 5); } Player.SendMessage(winners, c.gold + "You gained " + randomInt + " " + Server.moneys); winners.blockCount = 50; winners.playersInfected = 0; winners.money = winners.money + randomInt; winners.points += (100 * winners.playersInfected) + 25; } else if ((aliveCount == 1 && !winners.infected) && winners.level.name == currentLevelName) { Player.GlobalDie(winners, false); Player.GlobalSpawn(winners, winners.pos[0], winners.pos[1], winners.pos[2], winners.rot[0], winners.rot[1], false); Random random2 = new Random(); int randomInt = 0; randomInt = random2.Next(1, 15); Player.SendMessage(winners, c.gold + "You gained " + randomInt + " " + Server.moneys); winners.blockCount = 50; winners.playersInfected = 0; winners.money = winners.money + randomInt; winners.points += 500; } } try { alive.Clear(); infectd.Clear(); foreach (Player pl in Player.players) { if (pl.level == Level.Find(currentLevelName)) { pl.model = "steve"; pl.SendChangeModel(pl.id, "steve"); } } } catch { } foreach (Player player in Player.players) { player.infected = false; player.color = player.group.color; Player.GlobalDie(player, false); Player.GlobalSpawn(player, player.pos[0], player.pos[1], player.pos[2], player.rot[0], player.rot[1], false); if (player.level.name == currentLevelName) { if (player.referee) { player.SendMessage("You gained one " + Server.moneys + " because you're a ref. Would you like a medal as well?"); player.money++; } } } return; }
private void MainGame() { if (Server.gameStatus == 0) { return; } GoBack: Player.GlobalMessageLevel(Level.Find(currentLevelName), Player.MessageType.Announcement, "&4Round Start:&f 1:00"); Thread.Sleep(55000); if (!Server.ZombieModeOn) { return; } Server.s.Log(Convert.ToString(Server.ChangeLevels) + " " + Convert.ToString(Server.ZombieOnlyServer) + " " + Convert.ToString(Server.UseLevelList) + " " + string.Join(",", Server.LevelList.ToArray())); Player.GlobalMessageLevel(Level.Find(currentLevelName), Player.MessageType.Announcement, "&4Round Start:&f 5..."); Thread.Sleep(1000); if (!Server.ZombieModeOn) { return; } Player.GlobalMessageLevel(Level.Find(currentLevelName), Player.MessageType.Announcement, "&4Round Start:&f 4..."); Thread.Sleep(1000); if (!Server.ZombieModeOn) { return; } Player.GlobalMessageLevel(Level.Find(currentLevelName), Player.MessageType.Announcement, "&4Round Start:&f 3..."); Thread.Sleep(1000); if (!Server.ZombieModeOn) { return; } Player.GlobalMessageLevel(Level.Find(currentLevelName), Player.MessageType.Announcement, "&4Round Start:&f 2..."); Thread.Sleep(1000); if (!Server.ZombieModeOn) { return; } Player.GlobalMessageLevel(Level.Find(currentLevelName), Player.MessageType.Announcement, "&4Round Start:&f 1..."); Thread.Sleep(1000); if (!Server.ZombieModeOn) { return; } Server.zombieRound = true; int playerscountminusref = 0; List <Player> players = new List <Player> (); foreach (Player playere in Player.players) { if (playere.referee) { playere.color = playere.group.color; } else { if (playere.level.name == currentLevelName) { playere.color = playere.group.color; players.Add(playere); playerscountminusref++; } } } if (playerscountminusref < 2) { Player.GlobalMessageLevel(Level.Find(currentLevelName), Player.MessageType.Announcement, c.red + "ERROR: Need more than 2 players to play"); goto GoBack; } theEnd: Random random = new Random(); int firstinfect = random.Next(players.Count()); Player player = null; if (Server.queZombie == true) { player = Player.Find(Server.nextZombie); } else { player = players [firstinfect]; } if (player.level.name != currentLevelName) { goto theEnd; } Player.GlobalMessageLevel(Level.Find(currentLevelName), Player.MessageType.Announcement, player.color + player.name + Server.DefaultColor + " started the infection!"); Thread.Sleep(3000); Player.GlobalMessageLevel(Level.Find(currentLevelName), Player.MessageType.Announcement, ""); player.infected = true; player.color = c.red; Player.GlobalDie(player, false); Player.GlobalSpawn(player, player.pos [0], player.pos [1], player.pos [2], player.rot [0], player.rot [1], false); Server.zombieRound = true; int amountOfMinutes = random.Next(4, 8); Player.GlobalMessageLevel(Level.Find(currentLevelName), Player.MessageType.Status1, "The round will last for " + amountOfMinutes + " minutes!"); amountOfMilliseconds = (60000 * amountOfMinutes); timer = new System.Timers.Timer(amountOfMilliseconds); timer.Elapsed += new ElapsedEventHandler(EndRound); timer.Enabled = true; foreach (Player playaboi in Player.players) { if (playaboi != player) { alive.Add(playaboi); } } infectd.Clear(); foreach (Player pl in Player.players) { if (pl.level.name == currentLevelName) { pl.model = "steve"; pl.SendChangeModel(pl.id, "steve"); } } if (Server.queZombie == true) { infectd.Add(Player.Find(Server.nextZombie)); Player.Find(Server.nextZombie).model = "zombie"; Player.Find(Server.nextZombie).SendChangeModel(Player.Find(Server.nextZombie).id, "zombie"); } else { infectd.Add(player); player.model = "zombie"; player.SendChangeModel(player.id, "zombie"); } aliveCount = alive.Count; while (aliveCount > 0) { aliveCount = alive.Count; infectd.ForEach(delegate(Player player1) { if (player1.color != c.red) { player1.color = c.red; Player.GlobalDie(player1, false); Player.GlobalSpawn(player1, player1.pos[0], player1.pos[1], player1.pos[2], player1.rot[0], player1.rot[1], false); } alive.ForEach(delegate(Player player2) { if (player2.color != player2.group.color) { player2.color = player2.group.color; Player.GlobalDie(player2, false); Player.GlobalSpawn(player2, player2.pos[0], player2.pos[1], player2.pos[2], player2.rot[0], player2.rot[1], false); } if (player2.pos[0] / 32 == player1.pos[0] / 32 || player2.pos[0] / 32 == player1.pos[0] / 32 + 1 || player2.pos[0] / 32 == player1.pos[0] / 32 - 1) { if (player2.pos[1] / 32 == player1.pos[1] / 32 || player2.pos[1] / 32 == player1.pos[1] / 32 - 1 || player2.pos[1] / 32 == player1.pos[1] / 32 + 1) { if (player2.pos[2] / 32 == player1.pos[2] / 32 || player2.pos[2] / 32 == player1.pos[2] / 32 + 1 || player2.pos[2] / 32 == player1.pos[2] / 32 - 1) { if (!player2.infected && player1.infected && !player2.referee && !player1.referee && player1 != player2 && player1.level.name == currentLevelName && player2.level.name == currentLevelName) { player2.infected = true; infectd.Add(player2); player2.model = "zombie"; player2.SendChangeModel(player2.id, "zombie"); } alive.Remove(player2); players.Remove(player2); player2.blockCount = 25; if (Server.lastPlayerToInfect == player1.name) { Server.infectCombo++; if (Server.infectCombo >= 2) { player1.SendMessage("You gained " + (4 - Server.infectCombo) + " " + Server.moneys); player1.money = player1.money + 4 - Server.infectCombo; Player.GlobalMessageLevel(Level.Find(currentLevelName), Player.MessageType.Status2, player1.color + player1.name + " is on a rampage! " + (Server.infectCombo + 1) + " infections in a row!"); } } else { Server.infectCombo = 0; } Server.lastPlayerToInfect = player1.name; player1.infectThisRound++; int cazzar = random.Next(0, infectMessages.Length); if (File.Exists("text/infect/" + player1.name + ".txt")) { Player.GlobalMessageLevel(Level.Find(currentLevelName), Player.MessageType.Status2, c.red + player1.Original + c.yellow + " " + File.ReadAllText("text/infect/" + player1.name + ".txt") + " " + c.red + player2.name); } if (infectMessages2[cazzar] == "") { Player.GlobalMessageLevel(Level.Find(currentLevelName), Player.MessageType.Status2, c.red + player1.name + c.yellow + infectMessages[cazzar] + c.red + player2.name); } else if (infectMessages[cazzar] == "") { Player.GlobalMessageLevel(Level.Find(currentLevelName), Player.MessageType.Status2, c.red + player2.name + c.yellow + infectMessages2[cazzar]); } else { Player.GlobalMessageLevel(Level.Find(currentLevelName), Player.MessageType.Status2, c.red + player1.name + c.yellow + infectMessages[cazzar] + c.red + player2.name + c.yellow + infectMessages2[cazzar]); } player2.color = c.red; player1.playersInfected = player1.playersInfected++; Player.GlobalDie(player2, false); Player.GlobalSpawn(player2, player2.pos[0], player2.pos[1], player2.pos[2], player2.rot[0], player2.rot[1], false); Thread.Sleep(500); } } } }); }); Thread.Sleep(500); } if (Server.gameStatus == 0) { Server.gameStatus = 4; return; } else { HandOutRewards(); } }