Example #1
0
 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);
 }
Example #2
0
 public Base(ushort x, ushort y, ushort z, Teams team)
 {
     this.x = x; this.y = y; this.z = z;
 }
Example #3
0
 /// <summary>
 /// Start the CTF game
 /// </summary>
 public void Start()
 {
     if (Level.Find("ctf") != null)
     {
         Command.all.Find("unload").Use(null, "ctf");
         Thread.Sleep(1000);
     }
     if (started)
         return;
     blueteam = new Teams("blue");
     redteam = new Teams("red");
     LoadMap(maps[new Random().Next(maps.Count)]);
     if (look)
     {
         for (ushort x = 0; x < mainlevel.width; x++)
         {
             for (ushort y = 0; y < mainlevel.depth; y++)
             {
                 for (ushort z = 0; z < mainlevel.height; z++)
                 {
                     if (mainlevel.GetTile(x, y, z) == Block.red)
                     {
                         redbase.x = x; redbase.y = y; redbase.z = z;
                     }
                     else if (mainlevel.GetTile(x, y, z) == Block.blue || mainlevel.GetTile(x, y, z) == Block.cyan)
                     {
                         bluebase.x = x; bluebase.y = y; bluebase.z = z;
                     }
                 }
             }
         }
         zline = mainlevel.height / 2;
     }
     redbase.block = Block.red;
     bluebase.block = Block.blue;
     Server.s.Log("[Auto_CTF] Running...");
     started = true;
     Database.executeQuery("CREATE TABLE if not exists CTF (ID INTEGER " + (Server.useMySQL ? "" : "PRIMARY KEY ") + "AUTO" + (Server.useMySQL ? "_" : "") + "INCREMENT NOT NULL, Name VARCHAR(20), Points MEDIUMINT UNSIGNED, Captures MEDIUMINT UNSIGNED, tags MEDIUMINT UNSIGNED" + (Server.useMySQL ? ", PRIMARY KEY (ID)" : "") + ");");
 }