From e8321e3ec3debb4610ecb2d530842dc1f181e388 Mon Sep 17 00:00:00 2001 From: Lukas Moungos Date: Mon, 13 Jan 2020 21:43:55 +0100 Subject: [PATCH] [+] Add Gangwar System (bugs incl.) --- ReallifeGamemode.Client/Gui/infobox.ts | 13 +- ReallifeGamemode.Client/Player/keys.ts | 6 +- ReallifeGamemode.Client/util/Gangwar.ts | 124 +++++++++++++++++- ReallifeGamemode.Database/Entities/Turfs.cs | 1 + .../Migrations/20191129201024_Turfs.cs | 56 ++++---- .../DatabaseContextModelSnapshot.cs | 6 +- .../Commands/AdminCommands.cs | 16 ++- ReallifeGamemode.Server/Events/Login.cs | 4 + ReallifeGamemode.Server/Gangwar/Gangwar.cs | 39 +++++- ReallifeGamemode.Server/Gangwar/Turf.cs | 66 +++++----- 10 files changed, 246 insertions(+), 85 deletions(-) diff --git a/ReallifeGamemode.Client/Gui/infobox.ts b/ReallifeGamemode.Client/Gui/infobox.ts index e1efc7fe..9f2fdc61 100644 --- a/ReallifeGamemode.Client/Gui/infobox.ts +++ b/ReallifeGamemode.Client/Gui/infobox.ts @@ -240,7 +240,7 @@ export default function (globalData: GlobalData): void { }) if (jailTime > 0) { - mp.game.graphics.drawText("~y~Knastzeit: " + jailTime + " Minuten", [0.92, 0.52], + mp.game.graphics.drawText("~y~Knastzeit: ~ " + jailTime + " Minuten", [0.92, 0.52], { font: 4, color: [255, 255, 255, 255], @@ -251,7 +251,7 @@ export default function (globalData: GlobalData): void { } if (att_score > 0 && def_score > 0) { - mp.game.graphics.drawText("~y~" + def + " " + def_score + " : " + att_score + " " + att, [0.1, 0.416], + mp.game.graphics.drawText("~y~" + def + " " + def_score + " : " + att_score + " " + att, [0.07, 0.55], { font: 4, color: [255, 255, 255, 255], @@ -259,6 +259,15 @@ export default function (globalData: GlobalData): void { outline: true, centre: false }) + mp.game.graphics.drawText("~w~Gangwar", [0.07, 0.514], + { + font: 1, + color: [255, 255, 255, 255], + scale: [0.5, 0.5], + outline: true, + centre: false + }) + mp.game.graphics.drawRect(0.0, 0.555, 0.3, 0.08, 0, 0, 0, 70) } } diff --git a/ReallifeGamemode.Client/Player/keys.ts b/ReallifeGamemode.Client/Player/keys.ts index 996954b0..79deaee0 100644 --- a/ReallifeGamemode.Client/Player/keys.ts +++ b/ReallifeGamemode.Client/Player/keys.ts @@ -76,7 +76,7 @@ export default function keys(globalData: GlobalData) { //E mp.keys.bind(0x45, false, function () { - if (!globalData.InChat) { + if (!globalData.InChat && !globalData.InMenu) { mp.events.callRemote("keyPress:E"); } }); @@ -95,8 +95,8 @@ export default function keys(globalData: GlobalData) { }); //O //Spielerliste - mp.keys.bind(0x4F, false, function () { - if (!globalData.InChat && !globalData.InMenu) { + mp.keys.bind(0x4F, true, function () { + if (!globalData.InChat && !globalData.InMenu && !globalData.InTuning && !showInv) { mp.events.callRemote("keyPress:O"); //mp.events.call("showPlayerlist"); } diff --git a/ReallifeGamemode.Client/util/Gangwar.ts b/ReallifeGamemode.Client/util/Gangwar.ts index e4b1e144..debee906 100644 --- a/ReallifeGamemode.Client/util/Gangwar.ts +++ b/ReallifeGamemode.Client/util/Gangwar.ts @@ -56,12 +56,15 @@ _timerCheck; edit: boolean; attackBlip: BlipMp; + leaderBlip: BlipMp; + leaderBlipVector: Vector3Mp; + leaderColShape: MarkerMp; - constructor(name, id, x, y, range, color, rot, owner, edit) { - this._setup(name, id, x, y, range, color, rot, owner, edit); + constructor(name, id, x, y, range, color, rot, owner, edit, vector) { + this._setup(name, id, x, y, range, color, rot, owner, edit, vector); } - _setup(name, id, x, y, range, color, rot, owner, edit) { + _setup(name, id, x, y, range, color, rot, owner, edit, vector) { var self = this; self.name = name; @@ -82,6 +85,14 @@ self.edit = edit; self.loadArea(); self.attackBlip = null; + self.leaderBlip = null; + if (vector != null) { + self.leaderBlipVector = JSON.parse(vector); + } else { + self.leaderBlipVector = null; + } + + self.leaderColShape = null; } setColor(owner) { @@ -133,6 +144,8 @@ } + + if (self._status == "attack" || self.edit == true) { if (self._colshape) { if (mp.game.gameplay.getDistanceBetweenCoords(mp.players.local.position.x, mp.players.local.position.y, 0, self.x, self.y, 0, true) < self.range * 1.5) { @@ -182,6 +195,8 @@ } } + + if (self.isInsideArea()) { mp.game.graphics.drawText(self.name, [self.x, self.y, mp.players.local.position.z + 20], { font: 7, @@ -190,14 +205,49 @@ outline: true, centre: true }); + + } + } + } + if (self.leaderBlipVector != null) { + let dist = mp.game.gameplay.getDistanceBetweenCoords(mp.players.local.position.x, mp.players.local.position.y, mp.players.local.position.z, self.leaderBlipVector.x, self.leaderBlipVector.y, self.leaderBlipVector.z, false); + if (self.isInsideArea() && self._status != "attack" && dist <= 3) { + if (self.leaderBlipVector != null) { + mp.game.graphics.drawText(self.name + "\n~y~Gang: ~s~" + self.owner + "\n~y~Wert: ~s~$~g~187", [self.leaderBlipVector.x, self.leaderBlipVector.y, self.leaderBlipVector.z], { + font: 7, + color: [255, 255, 255, 185], + scale: [0.4, 0.4], + outline: true, + centre: true + }); } } } + + } + + private delay(ms: number) { + return new Promise(resolve => setTimeout(resolve, ms)); + } + + async startGangWar() { + var self = this; + await this.delay(1000); + if (self._status == "normal") { + let dist = mp.game.gameplay.getDistanceBetweenCoords(mp.players.local.position.x, mp.players.local.position.y, 0, self.leaderBlipVector.x, self.leaderBlipVector.y, self.leaderBlipVector.z, false); + if (dist <= 3) { + mp.events.callRemote("SERVER:StartGangwar"); + } + } } updateArea(status, ...args) { var self = this; if (status == "attack") { + if (self.leaderColShape != null) { + self.leaderColShape.destroy(); + self.leaderColShape = null; + } self._status = "attack"; self.attacker = args[1]; mp.game.invoke(Natives.SET_BLIP_FLASHES, self.blip, true); @@ -216,6 +266,7 @@ mp.game.invoke(Natives.SET_BLIP_FLASHES, self.blip, false); self.setColor(self.owner) mp.game.invoke(Natives.SET_BLIP_COLOUR, self.blip, self.color); + self.setLeaderColShape(); return; } } @@ -223,7 +274,7 @@ setAttackBlip(bool) { var self = this; if (bool) { - self.attackBlip = mp.game.ui.addBlipForRadius(self.x, self.y, 1, 60); + self.attackBlip = mp.game.ui.addBlipForCoord(self.x, self.y, 0); mp.game.invoke(Natives.SET_BLIP_SPRITE, self.attackBlip, 378); mp.game.invoke(Natives.SET_BLIP_AS_SHORT_RANGE, self.attackBlip, false); @@ -232,6 +283,36 @@ } } + setLeaderBlip(bool) { + var self = this; + if (bool) { + self.leaderBlipVector = mp.players.local.position; + mp.events.callRemote("SERVER:Turf_SetNewLeaderPoint", JSON.stringify(self.leaderBlipVector), JSON.stringify(self.id)); + self.setLeaderColShape(); + return; + } + + if (self.leaderBlipVector != null) { + self.leaderBlip = mp.game.ui.addBlipForRadius(self.leaderBlipVector.x, self.leaderBlipVector.y, 1, 60); + self.setLeaderColShape(); + mp.game.invoke(Natives.SET_BLIP_SPRITE, self.leaderBlip, 437); + mp.game.invoke(Natives.SET_BLIP_AS_SHORT_RANGE, self.leaderBlip, false); + + } + } + + setLeaderColShape() { + var self = this; + let newVector = new mp.Vector3(self.leaderBlipVector.x, self.leaderBlipVector.y, self.leaderBlipVector.z - 2) + + self.leaderColShape = mp.markers.new(1, newVector, 2, { + color: [255, 255, 255, 150], + visible: true, + dimension: 0 + }); + + } + isTurfArea(shape) { return (shape == this._colshape) } @@ -384,6 +465,11 @@ last_attackBlip = mp.game.invoke(Natives.GET_NEXT_BLIP_INFO_ID, 378); } + let last_leaderBlip = mp.game.invoke(Natives.GET_FIRST_BLIP_INFO_ID, 437); + while (mp.game.invoke(Natives.DOES_BLIP_EXIST, last_leaderBlip)) { + mp.game.ui.removeBlip(last_leaderBlip); + last_leaderBlip = mp.game.invoke(Natives.GET_NEXT_BLIP_INFO_ID, 437); + } } mp.events.add('GangAreas:Create', (turfsJSON) => { @@ -396,7 +482,7 @@ gangturfs = []; turfs.forEach(function (turf) { if (turf.Id != undefined) { - gangturfs[gangturfs.length] = new Gangturf(turf.Name, turf.Id, turf.X, turf.Y, turf.Range, turf.Color, turf.Rotation, turf.Owner, false); + gangturfs[gangturfs.length] = new Gangturf(turf.Name, turf.Id, turf.X, turf.Y, turf.Range, turf.Color, turf.Rotation, turf.Owner, false, turf.Vector); } }); } @@ -404,7 +490,7 @@ mp.events.add('ADMIN:CreateTurf', (rangeJSON) => { var range = JSON.parse(rangeJSON); - gangturfs[gangturfs.length] = new Gangturf("Reload For Name", -1, mp.players.local.position.x, mp.players.local.position.y, range, 0, mp.players.local.getHeading(), "Neutral", true); + gangturfs[gangturfs.length] = new Gangturf("Reload For Name", -1, mp.players.local.position.x, mp.players.local.position.y, range, 0, mp.players.local.getHeading(), "Neutral", true, null); }); mp.events.add('ADMIN:SetTurf', (name) => { @@ -446,5 +532,31 @@ }); }); + mp.events.add('CLIENT:Turf_LoadLeaderBlip', () => { + gangturfs.forEach(function (turf) { + if (turf.Id != undefined) { + turf.setLeaderBlip(false); + } + }); + }); + mp.events.add('ADMIN:Turf_CreateLeaderBlip', () => { + gangturfs.forEach(function (turf) { + if (turf._entered == true) { + if (turf.leaderColShape != null) { + turf.leaderColShape.destroy(); + turf.leaderColShape = null; + } + turf.setLeaderBlip(true); + } + }); + }); + + mp.events.add('CLIENT:StartGangwar', () => { + gangturfs.forEach(function (turf) { + if (turf._entered == true) { + turf.startGangWar(); + } + }); + }); } \ No newline at end of file diff --git a/ReallifeGamemode.Database/Entities/Turfs.cs b/ReallifeGamemode.Database/Entities/Turfs.cs index 99dfc1c2..aa818e48 100644 --- a/ReallifeGamemode.Database/Entities/Turfs.cs +++ b/ReallifeGamemode.Database/Entities/Turfs.cs @@ -21,6 +21,7 @@ namespace ReallifeGamemode.Database.Entities public float Rotation { get; set; } public float Range { get; set; } public int Color { get; set; } + public string Vector { get; set; } = null; } } diff --git a/ReallifeGamemode.Database/Migrations/20191129201024_Turfs.cs b/ReallifeGamemode.Database/Migrations/20191129201024_Turfs.cs index a3c88778..3863a29d 100644 --- a/ReallifeGamemode.Database/Migrations/20191129201024_Turfs.cs +++ b/ReallifeGamemode.Database/Migrations/20191129201024_Turfs.cs @@ -3,35 +3,35 @@ using Microsoft.EntityFrameworkCore.Migrations; namespace ReallifeGamemode.Database.Migrations { - public partial class Turfs : Migration - { - protected override void Up(MigrationBuilder migrationBuilder) + public partial class Turfs : Migration { - migrationBuilder.CreateTable( - name: "Turfs", - columns: table => new - { - Id = table.Column(nullable: false) - .Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn), - FactionId = table.Column(nullable: true), - Owner = table.Column(nullable: true), - Name = table.Column(nullable: true), - X = table.Column(nullable: false), - Y = table.Column(nullable: false), - Rotation = table.Column(nullable: false), - Range = table.Column(nullable: false), - Color = table.Column(nullable: false) - }, - constraints: table => - { - table.PrimaryKey("PK_Turfs", x => x.Id); - }); - } + protected override void Up(MigrationBuilder migrationBuilder) + { + migrationBuilder.CreateTable( + name: "Turfs", + columns: table => new + { + Id = table.Column(nullable: false) + .Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn), + FactionId = table.Column(nullable: true), + Owner = table.Column(nullable: true), + Name = table.Column(nullable: true), + X = table.Column(nullable: false), + Y = table.Column(nullable: false), + Rotation = table.Column(nullable: false), + Range = table.Column(nullable: false), + Color = table.Column(nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_Turfs", x => x.Id); + }); + } - protected override void Down(MigrationBuilder migrationBuilder) - { - migrationBuilder.DropTable( - name: "Turfs"); + protected override void Down(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropTable( + name: "Turfs"); + } } - } } diff --git a/ReallifeGamemode.Database/Migrations/DatabaseContextModelSnapshot.cs b/ReallifeGamemode.Database/Migrations/DatabaseContextModelSnapshot.cs index f5460add..08660f1e 100644 --- a/ReallifeGamemode.Database/Migrations/DatabaseContextModelSnapshot.cs +++ b/ReallifeGamemode.Database/Migrations/DatabaseContextModelSnapshot.cs @@ -907,9 +907,11 @@ namespace ReallifeGamemode.Database.Migrations b.Property("Rotation"); - b.Property("X"); + b.Property("Vector"); - b.Property("Y"); + b.Property("X"); + + b.Property("Y"); b.HasKey("Id"); diff --git a/ReallifeGamemode.Server/Commands/AdminCommands.cs b/ReallifeGamemode.Server/Commands/AdminCommands.cs index 81148bed..b460ceb2 100644 --- a/ReallifeGamemode.Server/Commands/AdminCommands.cs +++ b/ReallifeGamemode.Server/Commands/AdminCommands.cs @@ -1767,7 +1767,6 @@ namespace ReallifeGamemode.Server.Commands ChatService.SendMessage(player, "~b~[ADMIN]~s~ Du hast hast den Spieler ~y~" + target.Name + "~s~ zum Leader der Fraktion ~o~" + f.Name + "~s~ ernannt."); ChatService.SendMessage(target, "~b~[ADMIN]~s~ Du wurdest von ~y~" + player.Name + "~s~ zum Leader der Fraktion ~o~" + f.Name + "~s~ ernannt."); - u.FactionLeader = false; switch (u.FactionId) { case null: @@ -3056,7 +3055,7 @@ namespace ReallifeGamemode.Server.Commands Gangwar.Gangwar.loadClient(player); } - [Command("reloadturfs", "~m~Benutzung:~s~ /reloadturfs")] + [Command("reloadturfs", "~m~Benutzung:~s~ /ReloadTurfs")] public void CmdAdmReloadTurf(Client player) { if (!player.GetUser()?.IsAdmin(AdminLevel.HEADADMIN) ?? true) @@ -3067,7 +3066,7 @@ namespace ReallifeGamemode.Server.Commands Gangwar.Gangwar.loadTurfs(); Gangwar.Gangwar.loadTurfs_ToAllClients(); } - [Command("deleteturf", "~m~Benutzung:~s~ /reloadturfs")] + [Command("deleteturf", "~m~Benutzung:~s~ /DeleteTurfs")] public void CmdAdmDeleteTurf(Client player) { if (!player.GetUser()?.IsAdmin(AdminLevel.HEADADMIN) ?? true) @@ -3077,7 +3076,16 @@ namespace ReallifeGamemode.Server.Commands } player.TriggerEvent("ADMIN:DeleteTurf"); } - + [Command("setturfpoint", "~m~Benutzung:~s~ /setturfpoint")] + public void CmdAdmSetTurfPoint(Client player) + { + if (!player.GetUser()?.IsAdmin(AdminLevel.HEADADMIN) ?? true) + { + ChatService.NotAuthorized(player); + return; + } + player.TriggerEvent("ADMIN:Turf_CreateLeaderBlip"); + } #endregion #region ALevel1338 diff --git a/ReallifeGamemode.Server/Events/Login.cs b/ReallifeGamemode.Server/Events/Login.cs index a1d54194..b22d4362 100644 --- a/ReallifeGamemode.Server/Events/Login.cs +++ b/ReallifeGamemode.Server/Events/Login.cs @@ -53,6 +53,10 @@ namespace ReallifeGamemode.Server.Events player.SetData("duty", false); player.TriggerEvent("SERVER:SET_HANDMONEY", user.Handmoney, 0); Gangwar.Gangwar.loadClient(player); + if (player.GetUser().FactionLeader) + { + player.TriggerEvent("CLIENT:Turf_LoadLeaderBlip"); + } if (user.IsAdmin(AdminLevel.HEADADMIN) == true) { player.SetData("editmode", false); diff --git a/ReallifeGamemode.Server/Gangwar/Gangwar.cs b/ReallifeGamemode.Server/Gangwar/Gangwar.cs index 9782e6c3..47239954 100644 --- a/ReallifeGamemode.Server/Gangwar/Gangwar.cs +++ b/ReallifeGamemode.Server/Gangwar/Gangwar.cs @@ -40,6 +40,14 @@ namespace ReallifeGamemode.Server.Gangwar public static void loadTurfs_ToAllClients() { NAPI.ClientEvent.TriggerClientEventForAll("GangAreas:Create", JsonConvert.SerializeObject(turfs.ToArray())); + foreach(var l in NAPI.Pools.GetAllPlayers()) + { + if (!l.IsLoggedIn() && !l.GetUser().FactionLeader) + return; + + l.TriggerEvent("CLIENT:Turf_LoadLeaderBlip"); + + } } public static void GangwarKill(Client killer, Client victim) @@ -108,7 +116,8 @@ namespace ReallifeGamemode.Server.Gangwar Rotation = Rot, Range = Range, Owner = "Neutral", - Color = 0 + Color = 0, + Vector = null }; using (var dbContext = new DatabaseContext()) { @@ -141,8 +150,30 @@ namespace ReallifeGamemode.Server.Gangwar } } - [Command("/gwstart")] - public void StartGangwar(Client client) + [RemoteEvent("SERVER:Turf_SetNewLeaderPoint")] + public void RmtEvent_SetNewLeaderPoint(Client client, string vector, string jsonId) { + int id = JsonConvert.DeserializeObject(jsonId); + if (id == -1) + { + ChatService.ErrorMessage(client, "Du befindest dich in keinem Gebiet"); + return; + } + using (var dbContext = new DatabaseContext()) + { + Turfs dturf = dbContext.Turfs.Where(t => t.Id == id).FirstOrDefault(); + if (dturf != null) + { + dturf.Vector = vector; + dbContext.SaveChanges(); + loadTurfs(); + loadTurfs_ToAllClients(); + } + } + } + + + [RemoteEvent("SERVER:StartGangwar")] + public void RmtEvent_StartGangwar(Client client) { if (!client.GetUser().FactionLeader) return; @@ -151,7 +182,7 @@ namespace ReallifeGamemode.Server.Gangwar { if (turf.status == "attack") { - client.SendChatMessage("Ein GW läuft grad bruder"); // DEBUG + client.SendChatMessage("Ein GW läuft grad bruder"); // DEBUG //change to smth more serious return; } } diff --git a/ReallifeGamemode.Server/Gangwar/Turf.cs b/ReallifeGamemode.Server/Gangwar/Turf.cs index b38db68d..ff7e0b9c 100644 --- a/ReallifeGamemode.Server/Gangwar/Turf.cs +++ b/ReallifeGamemode.Server/Gangwar/Turf.cs @@ -14,7 +14,7 @@ namespace ReallifeGamemode.Server.Gangwar { public class Turf { - + public int TurfID { get; set; } public string TurfName { get; set; } public int Color { get; set; } @@ -36,8 +36,8 @@ namespace ReallifeGamemode.Server.Gangwar this.Color = color; this.Owner = Owner; this.Attacker = null; - this.Att_Score = 5; - this.Def_Score = 5; + this.Att_Score = 50; + this.Def_Score = 50; this.status = "normal"; this.timer = null; this.playerInside = new List(); @@ -68,7 +68,7 @@ namespace ReallifeGamemode.Server.Gangwar { return this.Attacker; } - + private void TurfTick() { this.timer = new System.Timers.Timer(1000); @@ -81,7 +81,7 @@ namespace ReallifeGamemode.Server.Gangwar private void Tick(object sender, System.Timers.ElapsedEventArgs e) { - if (this.status == "attack") + if(this.status == "attack") { update(); } @@ -91,6 +91,7 @@ namespace ReallifeGamemode.Server.Gangwar private void update() { + #region Ticket system /* try { @@ -113,6 +114,7 @@ namespace ReallifeGamemode.Server.Gangwar if(owners.Length < attackers.Length) this.Def_Score -= attackers.Length - owners.Length; */ + #endregion foreach (Client gangwarPlayer in this.playerInGangwar) { gangwarPlayer.TriggerEvent("GangwarScore", this.Attacker, this.Owner, this.Att_Score, this.Def_Score); @@ -120,43 +122,40 @@ namespace ReallifeGamemode.Server.Gangwar if (this.Def_Score <= 0) { this.takeOver(this.Attacker); - } - else if (this.Att_Score <= 0) + } else if (this.Att_Score <= 0) { this.takeOver(this.Owner); } timerCount += 1; - if (timerCount >= 60) //change to 900 before release + if(timerCount >= 900) //change to 900 (seconds) before release for testing reasons change to whatever you like { - this.timer.Stop(); - this.timer = null; - if (this.Def_Score > this.Att_Score) + if(this.Def_Score > this.Att_Score) { + foreach (Client gangwarPlayer in this.playerInGangwar) + { + gangwarPlayer.TriggerEvent("GangwarScore", this.Attacker, this.Owner, 0, 0); + } this.takeOver(this.Owner); this.Att_Score = 0; + }else if(this.Def_Score < this.Att_Score) + { foreach (Client gangwarPlayer in this.playerInGangwar) { gangwarPlayer.TriggerEvent("GangwarScore", this.Attacker, this.Owner, 0, 0); } - } - else if (this.Def_Score < this.Att_Score) - { this.takeOver(this.Attacker); this.Def_Score = 0; - foreach (Client gangwarPlayer in this.playerInGangwar) - { - gangwarPlayer.TriggerEvent("GangwarScore", this.Attacker, this.Owner, 0, 0); - } return; } - else if (this.Def_Score == this.Att_Score) + else if(this.Def_Score == this.Att_Score) { - this.takeOver(this.Attacker); - this.Def_Score = 0; foreach (Client gangwarPlayer in this.playerInGangwar) { gangwarPlayer.TriggerEvent("GangwarScore", this.Attacker, this.Owner, 0, 0); } + this.takeOver(this.Attacker); + this.Def_Score = 0; + return; } } @@ -179,9 +178,8 @@ namespace ReallifeGamemode.Server.Gangwar return; } } - - if (playerInside.Find(c => c == client) == null) - { + + if(playerInside.Find(c => c == client) == null) { playerInside.Add(client); client.SetData("GotInsideOfTurf", true); } @@ -189,10 +187,10 @@ namespace ReallifeGamemode.Server.Gangwar public void leave(Client client) { - if (playerInside.Find(c => c == client) != null) + if(playerInside.Find(c => c == client) != null) { this.playerInside = this.playerInside.Where(c => c != client).ToList(); - if (this.status != "attack") + if(this.status != "attack") client.ResetData("GotInsideOfTurf"); } } @@ -216,14 +214,10 @@ namespace ReallifeGamemode.Server.Gangwar 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()); + 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) { - 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.IsLoggedIn() && c.GetUser().Faction.Name == this.Owner).ToArray(); Client[] attackers = NAPI.Pools.GetAllPlayers().Where(c => c.IsLoggedIn() && c.GetUser().Faction.Name == this.Attacker).ToArray(); @@ -242,10 +236,10 @@ namespace ReallifeGamemode.Server.Gangwar turf.FactionId = dbContext.Factions.Where(f => f.Name == this.Owner).FirstOrDefault().Id; dbContext.SaveChanges(); } - + } this.Attacker = null; - foreach (var c in playerInGangwar) + foreach(var c in playerInGangwar) { c.TriggerEvent("CLIENT:setAttackBlip", false, TurfID); c.ResetData("inGangWar"); @@ -258,9 +252,9 @@ namespace ReallifeGamemode.Server.Gangwar public void attack(string attacker) { - if (this.status == "normal") + if(this.status == "normal") { - if (this.timer != null) + if(this.timer != null) { this.timer.Stop(); this.timer = null; @@ -277,7 +271,7 @@ namespace ReallifeGamemode.Server.Gangwar 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."); + ChatService.SendMessage(u, "~y~[GANGWAR]~w~ Die " + getAttacker() + " haben das Gebiet ~y~"+ TurfName +"~w~ der "+ getOwner() +" angegriffen."); clientsInGangwar.Add(u); } playerInGangwar = clientsInGangwar.ToArray();