From 4761baeea479075482189661b08998413bc26711 Mon Sep 17 00:00:00 2001 From: Lukas Moungos Date: Wed, 22 Jan 2020 21:05:39 +0100 Subject: [PATCH] Gangwar System Complete --- ReallifeGamemode.Client/util/Gangwar.ts | 39 +++++++++++----------- ReallifeGamemode.Server/Gangwar/Gangwar.cs | 2 +- 2 files changed, 21 insertions(+), 20 deletions(-) diff --git a/ReallifeGamemode.Client/util/Gangwar.ts b/ReallifeGamemode.Client/util/Gangwar.ts index debee906..b3428de8 100644 --- a/ReallifeGamemode.Client/util/Gangwar.ts +++ b/ReallifeGamemode.Client/util/Gangwar.ts @@ -211,7 +211,7 @@ } 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.isInsideArea() && self._status != "attack" && dist <= 6) { 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, @@ -226,13 +226,9 @@ } - private delay(ms: number) { - return new Promise(resolve => setTimeout(resolve, ms)); - } - async startGangWar() { + 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) { @@ -285,13 +281,16 @@ setLeaderBlip(bool) { var self = this; + if (this.leaderColShape != null) { + this.leaderColShape.destroy(); + this.leaderColShape = null; + } 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(); @@ -306,7 +305,7 @@ 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], + color: [255, 255, 0, 150], visible: true, dimension: 0 }); @@ -337,13 +336,12 @@ if ((!self._entered)) { if (self.isInsideArea() && (self.isNearGround() == true)) { self._entered = true; - if (self._status === "attack") { + if (self._status == "attack") { mp.game.audio.playSoundFrontend(1, "Enter_Capture_Zone", "DLC_Apartments_Drop_Zone_Sounds", true); mp.game.graphics.stopScreenEffect("MinigameTransitionIn"); mp.game.graphics.startScreenEffect("MinigameTransitionOut", 500, false); - } - + } mp.events.callRemote("Gangarea:Enter", JSON.stringify(self.id)); } } else if (self._entered == true) { @@ -476,9 +474,18 @@ var turfs = JSON.parse(turfsJSON); if (gangturfs.length > 0) { gangturfs[gangturfs.length - 1].edit = false; + gangturfs.forEach(function (turf) { + turf._status = "disabled"; + turf.id = -420; //Due to garbage collecting this value needs to be negative, so that the Server doesn't find multiple Turfs in the Database with same ID's. + if (turf.leaderColShape != null) { + turf.leaderColShape.destroy(); + turf.leaderColShape = null; + } + }); } clearBlips(); if (turfs.length > 0) { + gangturfs = []; turfs.forEach(function (turf) { if (turf.Id != undefined) { @@ -534,19 +541,13 @@ 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; - } + if (turf._entered == true) { turf.setLeaderBlip(true); } }); diff --git a/ReallifeGamemode.Server/Gangwar/Gangwar.cs b/ReallifeGamemode.Server/Gangwar/Gangwar.cs index 47239954..1a7dec4f 100644 --- a/ReallifeGamemode.Server/Gangwar/Gangwar.cs +++ b/ReallifeGamemode.Server/Gangwar/Gangwar.cs @@ -182,7 +182,7 @@ namespace ReallifeGamemode.Server.Gangwar { if (turf.status == "attack") { - client.SendChatMessage("Ein GW läuft grad bruder"); // DEBUG //change to smth more serious + ChatService.ErrorMessage(client,"Du kannst momentan kein Gangwar starten"); return; } }