From f30e9a8ea6722ba09bd5d0fc11d806b0795eb16a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lukas=20F=C3=BClling?= Date: Sat, 9 May 2020 18:18:26 +0200 Subject: [PATCH] add wasted message and sound effect --- README.md | 3 --- client/main.lua | 39 ++++++++++++++++++++++++++++++++++++++- locales/en.lua | 1 + 3 files changed, 39 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 82283b8..8700bf6 100644 --- a/README.md +++ b/README.md @@ -19,6 +19,3 @@ This plugin has the following features: - Old: `if (diedAt and (math.abs(GetTimeDifference(GetGameTimer(), diedAt)) > 2000)) or respawnForced then` - New: `if respawnForced then` 3. Remember to redo this once you update the `server-data` repo! - - - diff --git a/client/main.lua b/client/main.lua index aa3f141..941b7f3 100644 --- a/client/main.lua +++ b/client/main.lua @@ -1,5 +1,6 @@ ESX = nil local isDead = false +local soundPlaying = false --- Thread to get the ESX object Citizen.CreateThread(function() @@ -105,6 +106,39 @@ function formatTimer(seconds) end end +function PlaySoundAndShowMessage() + Citizen.CreateThread(function() + while isDead do + if not soundPlaying then + PlaySoundFrontend(-1, "Bed", "WastedSounds", 1) + soundPlaying = true + end + + local wastedMessage = RequestScaleformMovie("MP_BIG_MESSAGE_FREEMODE") + + if HasScaleformMovieLoaded(wastedMessage) then + Citizen.Wait(0) + + PushScaleformMovieFunction(wastedMessage, "SHOW_SHARD_WASTED_MP_MESSAGE") + BeginTextComponent("STRING") + AddTextComponentString("~r~" .. _U('wasted')) + EndTextComponent() + PopScaleformMovieFunctionVoid() + + Citizen.Wait(500) + + PlaySoundFrontend(-1, "TextHit", "WastedSounds", 1) + while isDead do + DrawScaleformMovieFullscreen(wastedMessage, 255, 255, 255, 255) + Citizen.Wait(0) + end + + soundPlaying = false + end + end + end) +end + --- Respawn event handler AddEventHandler('esx:onPlayerSpawn', function() isDead = false @@ -114,6 +148,9 @@ end) AddEventHandler('esx:onPlayerDeath', function(data) isDead = true ESX.UI.Menu.CloseAll() - StartRespawnTimer() StartScreenEffect('DeathFailOut', 0, false) + ShakeGameplayCam("DEATH_FAIL_IN_EFFECT_SHAKE", 1) + + PlaySoundAndShowMessage() + StartRespawnTimer() end) \ No newline at end of file diff --git a/locales/en.lua b/locales/en.lua index 5b90e01..77b63ad 100644 --- a/locales/en.lua +++ b/locales/en.lua @@ -1,5 +1,6 @@ Locales['en'] = { ['respawn_available_in'] = 'respawn available in ~b~%s minutes %s seconds~s~', ['respawn_prompt'] = 'hold [~b~E~s~] to respawn', + ['wasted'] = 'Wasted', }