CTF: group by team name in tab list

This commit is contained in:
UnknownShadow200 2017-07-15 15:48:12 +10:00
parent abddf8ffbe
commit baa337d225
4 changed files with 21 additions and 11 deletions

View File

@ -157,8 +157,8 @@ namespace MCGalaxy.Games {
Player.Message(p, "No CTF maps were found."); return false;
}
Blue = new CtfTeam2("blue", Colors.blue);
Red = new CtfTeam2("red", Colors.red);
Blue = new CtfTeam2("Blue", Colors.blue);
Red = new CtfTeam2("Red", Colors.red);
LoadMap(maps[new Random().Next(maps.Count)]);
Logger.Log(LogType.GameActivity, "[CTF] Running...");

View File

@ -18,6 +18,7 @@
permissions and limitations under the Licenses.
*/
using System;
using MCGalaxy.Events.EntityEvents;
using MCGalaxy.Events.LevelEvents;
using MCGalaxy.Events.PlayerEvents;
using MCGalaxy.Maths;
@ -37,6 +38,7 @@ namespace MCGalaxy.Games {
OnPlayerDisconnectEvent.Register(HandleDisconnect, Priority.High);
OnLevelUnloadEvent.Register(HandleLevelUnload, Priority.High);
OnPlayerSpawningEvent.Register(HandlePlayerSpawning, Priority.High);
OnTabListEntryAddedEvent.Register(HandleTabListEntryAdded, Priority.High);
}
public override void Unload(bool shutdown) {
@ -47,6 +49,7 @@ namespace MCGalaxy.Games {
OnPlayerDisconnectEvent.Unregister(HandleDisconnect);
OnLevelUnloadEvent.Unregister(HandleLevelUnload);
OnPlayerSpawningEvent.Unregister(HandlePlayerSpawning);
OnTabListEntryAddedEvent.Unregister(HandleTabListEntryAdded);
}
@ -133,6 +136,21 @@ namespace MCGalaxy.Games {
CtfTeam2 team = Game.TeamOf(p);
if (team != null) pos = team.SpawnPos;
if (team != null && respawning) Game.DropFlag(p, team);
}
void HandleTabListEntryAdded(Entity entity, ref string tabName, ref string tabGroup, Player dst) {
Player p = entity as Player;
if (p == null || !Game.started || p.level != Game.map) return;
CtfTeam2 team = Game.TeamOf(p);
if (p.Game.Referee) {
tabGroup = "&2Referees";
} else if (team != null) {
tabGroup = team.ColoredName + " &fteam";
} else {
tabGroup = "&7Spectators";
}
}
void HandlePlayerCommand(Player p, string cmd, string args) {

View File

@ -81,7 +81,6 @@ namespace MCGalaxy {
public bool backedup;
public BlockDB BlockDB;
public LevelAccessController VisitAccess, BuildAccess;
public bool ctfmode;
// Physics fields and settings
public int physics {

View File

@ -391,14 +391,7 @@ namespace MCGalaxy {
}
}
if ( Game.team != null && this.level.ctfmode ) {
//if (carryingFlag)
//{
// level.ctfgame.DropFlag(this, hasflag);
//}
Game.team.SpawnPlayer(this);
//this.health = 100;
} else if ( PlayingTntWars ) {
if (PlayingTntWars) {
TntWarsKillStreak = 0;
TntWarsScoreMultiplier = 1f;
} else if ( Server.lava.active && Server.lava.HasPlayer(this) ) {