diff --git a/Client/Gui/deathscreen.js b/Client/Gui/deathscreen.js new file mode 100644 index 00000000..6cca290c --- /dev/null +++ b/Client/Gui/deathscreen.js @@ -0,0 +1,49 @@ +/** + * @overview Life of German Reallife - Gui Infobox infobox.js + * @author VegaZ + * @copyright (c) 2008 - 2018 Life of German + */ + +var playerName; +var playerId; +var playerMoney; + +var isDeath = false; +var deathTime; +var respawnTime; +var deathSeconds; + +mp.events.add("startDeathTimer", () => { + if (isDeath === false) { + isDeath = true; + mp.gui.chat.activate(false); + mp.gui.chat.show(false); + deathDate = new Date(); + respawnTime = deathDate.getSeconds() + 120; + secondsToAlpha = 120; + } +}); + +mp.events.add("onPlayerRevived", () => { + isDeath = false; + mp.gui.chat.activate(true); + mp.gui.chat.show(true); +}); + +mp.events.add("render", () => { + + if (isDeath === true) { + currentDate = new Date(); + + deathSeconds = respawnTime - currentDate.getSeconds(); + mp.game.graphics.drawText("~y~" + deathSeconds, [0.5, 0.5], + { + font: 7, + color: [255, 255, 255, 255], + scale: [0.8, 0.8], + outline: true + }) + mp.game.graphics.drawRect(0.5, 0.5, 1, 1, 0, 0, 0, deathSeconds); + + } +}); \ No newline at end of file diff --git a/Client/index.js b/Client/index.js index 75951af2..f5dd4598 100644 --- a/Client/index.js +++ b/Client/index.js @@ -8,7 +8,7 @@ require('./Login/main.js'); require('./Save/main.js'); require('./Save/save.js'); - +require('./Gui/deathscreen.js'); require('./Gui/infobox.js'); require('./Gui/playerlist.js'); require('./Login/main.js'); diff --git a/Main.cs b/Main.cs index 54defe8b..f8405200 100644 --- a/Main.cs +++ b/Main.cs @@ -24,6 +24,7 @@ namespace reallife_gamemode NAPI.Server.SetCommandErrorMessage("~r~[FEHLER]~s~ Dieser Command existiert nicht."); NAPI.Server.SetDefaultSpawnLocation(DEFAULT_SPAWN_POSITION, DEFAULT_SPAWN_HEADING); NAPI.Server.SetAutoSpawnOnConnect(false); + NAPI.Server.SetAutoRespawnAfterDeath(false); using (var context = new DatabaseContext()) { diff --git a/Server/Events/Death.cs b/Server/Events/Death.cs index 222b93f1..c345bedc 100644 --- a/Server/Events/Death.cs +++ b/Server/Events/Death.cs @@ -22,6 +22,9 @@ namespace reallife_gamemode.Server.Events [ServerEvent(Event.PlayerDeath)] public void OnPlayerDeath(Client player, Client killer, uint reason) { + + player.TriggerEvent("startDeathTimer"); + //TODO: Zum Full Release entfernen NAPI.Chat.SendChatMessageToPlayer(player, "Du bist durch " + killer.Name + " gestorben: " + reason.ToString());