From 2b46b940cc2326d8d2c365ffc89e223c3dbf85c9 Mon Sep 17 00:00:00 2001 From: Fabian Date: Thu, 22 Apr 2021 21:35:26 +0200 Subject: [PATCH] spawnschutz bei login, revive und spawn nach kh --- ReallifeGamemode.Client/Login/main.ts | 1 + ReallifeGamemode.Client/Player/spawnschutz.ts | 12 +++++++----- ReallifeGamemode.Client/util/weapondamage.ts | 8 +++++++- ReallifeGamemode.Server/Commands/FactionCommands.cs | 3 +++ ReallifeGamemode.Server/Events/Death.cs | 3 +++ 5 files changed, 21 insertions(+), 6 deletions(-) diff --git a/ReallifeGamemode.Client/Login/main.ts b/ReallifeGamemode.Client/Login/main.ts index e1ab88b7..5e0775dd 100644 --- a/ReallifeGamemode.Client/Login/main.ts +++ b/ReallifeGamemode.Client/Login/main.ts @@ -71,5 +71,6 @@ export default function (globalData: IGlobalData): void { mp.game.cam.renderScriptCams(false, false, 0, true, false); mp.events.call("toggleSpawnschutz", true); + mp.events.call("triggerSpawnschutzTimer"); }); } \ No newline at end of file diff --git a/ReallifeGamemode.Client/Player/spawnschutz.ts b/ReallifeGamemode.Client/Player/spawnschutz.ts index 8a6bf9bc..1639fc61 100644 --- a/ReallifeGamemode.Client/Player/spawnschutz.ts +++ b/ReallifeGamemode.Client/Player/spawnschutz.ts @@ -2,8 +2,10 @@ export default function spawnschutz() { - setInterval(() => { - mp.events.call("toggleSpawnschutz", false); - spawnschutzEnabled = false; - }, 60000); -} \ No newline at end of file + mp.events.add("triggerSpawnschutzTimer", () => { + var spawnschutzTimer = setTimeout(() => { + mp.events.call("toggleSpawnschutz", false); + spawnschutzEnabled = false; + }, 60000); + }); +} \ No newline at end of file diff --git a/ReallifeGamemode.Client/util/weapondamage.ts b/ReallifeGamemode.Client/util/weapondamage.ts index 18983512..555d4292 100644 --- a/ReallifeGamemode.Client/util/weapondamage.ts +++ b/ReallifeGamemode.Client/util/weapondamage.ts @@ -32,7 +32,13 @@ export default function weapondamageUtil() { return true; } - if (spawnschutzEnabled) { + if (spawnschutzEnabled && getWantedCount() === 0) { + return true; + } + }); + + mp.events.add('outgoingDamage', (sourceEntity, targetEntity, sourcePlayer, weapon, boneIndex, damage) => { + if (spawnschutzEnabled && getWantedCount() === 0) { return true; } }); diff --git a/ReallifeGamemode.Server/Commands/FactionCommands.cs b/ReallifeGamemode.Server/Commands/FactionCommands.cs index bf5b46ae..4abae4e5 100644 --- a/ReallifeGamemode.Server/Commands/FactionCommands.cs +++ b/ReallifeGamemode.Server/Commands/FactionCommands.cs @@ -426,6 +426,9 @@ namespace ReallifeGamemode.Server.Commands deadPlayer.SetData("isDead", false); deadPlayer.SetData("reviveSperre", 5); + deadPlayer.TriggerEvent("toggleSpawnschutz", true); + deadPlayer.TriggerEvent("triggerSpawnschutzTimer"); + dbContext.Factions.Include(f => f.BankAccount).Where(f => f.Id == 2).First().BankAccount.Balance += Medic.ReviveIncome; User u; diff --git a/ReallifeGamemode.Server/Events/Death.cs b/ReallifeGamemode.Server/Events/Death.cs index 90e92c2e..d260ea63 100644 --- a/ReallifeGamemode.Server/Events/Death.cs +++ b/ReallifeGamemode.Server/Events/Death.cs @@ -244,6 +244,9 @@ namespace ReallifeGamemode.Server.Events } player.SafeTeleport(new Vector3(-495.45, -336.33, 34.5), 0, true); + + player.TriggerEvent("toggleSpawnschutz", true); + player.TriggerEvent("triggerSpawnschutzTimer"); } } }