add Blips and Sounds to Gangwar

This commit is contained in:
Lukas Moungos
2019-12-04 20:21:30 +01:00
parent 37cb9d0e30
commit 4fa3a312f9
2 changed files with 68 additions and 9 deletions

View File

@@ -26,6 +26,7 @@ namespace ReallifeGamemode.Server.Gangwar
public List<Client> playerInside { get; set; }
public Timer timer { get; set; }
public Client[] playerInGangwar { get; set; }
public int timerCount;
public Turf(int TurfID, string TurfName, int color, string Owner)
@@ -40,6 +41,7 @@ namespace ReallifeGamemode.Server.Gangwar
this.status = "normal";
this.timer = null;
this.playerInside = new List<Client>();
this.timerCount = 0;
}
public int getId()
@@ -73,7 +75,8 @@ namespace ReallifeGamemode.Server.Gangwar
this.timer.Elapsed += Tick;
this.timer.AutoReset = true;
this.timer.Enabled = true;
this.timer.Enabled = true;
this.timerCount = 0;
}
private void Tick(object sender, System.Timers.ElapsedEventArgs e)
@@ -84,6 +87,8 @@ namespace ReallifeGamemode.Server.Gangwar
}
}
private void update()
{
/*
@@ -119,6 +124,12 @@ namespace ReallifeGamemode.Server.Gangwar
{
this.takeOver(this.Owner);
}
timerCount += 1;
if(timerCount >= 69)
{
this.timer.Stop();
this.timer = null;
}
}
public void enter(Client client)
@@ -163,23 +174,49 @@ namespace ReallifeGamemode.Server.Gangwar
{
if (getOwner() == FactionName)
{
Client[] owners = NAPI.Pools.GetAllPlayers().Where(c => c.GetUser().Faction.Name == this.Owner).ToArray();
Client[] attackers = NAPI.Pools.GetAllPlayers().Where(c => c.GetUser().Faction.Name == this.Attacker).ToArray();
foreach (var o in owners)
{
o.TriggerEvent("CLIENT:win");
}
foreach (var a in attackers)
{
a.TriggerEvent("CLIENT:loose");
}
ChatService.BroadcastFaction("~y~[GANGWAR] ~w~Deine Fraktion hat erfolgreich das Gebiet ~g~" + getName() + "~w~ verteidigt.", dbContext.Factions.Where(f => f.Name == getOwner()).FirstOrDefault());
ChatService.BroadcastFaction("~y~[GANGWAR] ~w~Deine Fraktion hat den Angrif auf das Gebiet ~r~" + getName() + "~w~ verloren.", dbContext.Factions.Where(f => f.Name == getAttacker()).FirstOrDefault());
}
else if (getOwner() != FactionName)
{
ChatService.BroadcastFaction("~y~[GANGWAR] ~w~Deine Fraktion konnte das Gebiet ~r~" + getName() + "~w~ nicht erobern.", dbContext.Factions.Where(f => f.Name == getAttacker()).FirstOrDefault());
foreach (var c in playerInGangwar)
{
}
ChatService.BroadcastFaction("~y~[GANGWAR] ~w~Deine Fraktion konnte das Gebiet ~r~" + getName() + "~w~ nicht verteidigen.", dbContext.Factions.Where(f => f.Name == getOwner()).FirstOrDefault());
Client[] owners = NAPI.Pools.GetAllPlayers().Where(c => c.GetUser().Faction.Name == this.Owner).ToArray();
Client[] attackers = NAPI.Pools.GetAllPlayers().Where(c => c.GetUser().Faction.Name == this.Attacker).ToArray();
foreach (var o in owners)
{
o.TriggerEvent("CLIENT:loose");
}
foreach (var a in attackers)
{
a.TriggerEvent("CLIENT:win");
}
this.Owner = FactionName;
ChatService.BroadcastFaction("~y~[GANGWAR] ~w~Deine Fraktion konnte erfolgreich das Gebiet ~g~" + getName() + "~w~ verteidigen.", dbContext.Factions.Where(f => f.Name == getOwner()).FirstOrDefault());
Turfs turf = dbContext.Turfs.Where(t => t.Id == getId()).FirstOrDefault();
turf.Owner = this.Owner;
turf.FactionId = dbContext.Factions.Where(f => f.Name == this.Owner).FirstOrDefault().Id;
dbContext.SaveChanges();
}
ChatService.BroadcastFaction("~y~[GANGWAR] ~w~Deine Fraktion konnte erfolgreich das Gebiet ~g~" + getName() + "~w~ verteidigen.", dbContext.Factions.Where(f => f.Name == this.Owner).FirstOrDefault());
}
this.Attacker = null;
foreach(var c in playerInGangwar)
{
c.TriggerEvent("CLIENT:setAttackBlip", false, TurfID);
c.ResetData("inGangWar");
c.ResetData("GotInsideOfTurf");
}
@@ -206,8 +243,10 @@ namespace ReallifeGamemode.Server.Gangwar
Client[] usersInGangwar = NAPI.Pools.GetAllPlayers().Where(c => c.GetUser().Faction.Name == getOwner() || c.GetUser().Faction.Name == getAttacker()).ToArray();
foreach (var u in usersInGangwar)
{
u.TriggerEvent("CLIENT:setAttackBlip", true, TurfID);
u.TriggerEvent("GangwarScore", this.Attacker, this.Owner, this.Att_Score, this.Def_Score);
u.SetData("inGangWar", getId());
ChatService.SendMessage(u, "~y~[GANGWAR]~w~ Die " + getAttacker() + " hat das Gebiet ~y~"+ TurfName +"~w~ der "+ getOwner() +" angegriffen.");
clientsInGangwar.Add(u);
}
playerInGangwar = clientsInGangwar.ToArray();