bool OnSide(Player p, Base b) { if (b.z < zline && p.pos[2] / 32 < zline) return true; else if (b.z > zline && p.pos[2] / 32 > zline) return true; else return false; }
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 { Chat.GlobalMessageLevel(mainlevel, "The game ended in a tie!"); } Chat.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(); Chat.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); }
internal bool OnSide(ushort z, Base b) { if (b.z < zline && z / 32 < zline) return true; else if (b.z > zline && z / 32 > zline) return true; else return false; }
/// <summary> /// Create a new CTF object /// </summary> public Auto_CTF() { //Load some configs if (!Directory.Exists("CTF")) Directory.CreateDirectory("CTF"); if (!File.Exists("CTF/maps.config")) { Server.s.Log("No maps were found!"); return; } string[] lines = File.ReadAllLines("CTF/maps.config"); foreach (string l in lines) maps.Add(l); if (maps.Count == 0) { Server.s.Log("No maps were found!"); return; } redbase = new Base(); bluebase = new Base(); Start(); //Lets get started Player.PlayerDeath += new Player.OnPlayerDeath(Player_PlayerDeath); Player.PlayerChat += new Player.OnPlayerChat(Player_PlayerChat); Player.PlayerCommand += new Player.OnPlayerCommand(Player_PlayerCommand); Player.PlayerBlockChange += new Player.BlockchangeEventHandler2(Player_PlayerBlockChange); Player.PlayerDisconnect += new Player.OnPlayerDisconnect(Player_PlayerDisconnect); Level.LevelUnload += new Level.OnLevelUnload(mainlevel_LevelUnload); tagging.Elapsed += new System.Timers.ElapsedEventHandler(tagging_Elapsed); tagging.Start(); }