Skip to content

Commit

Permalink
add wasted message and sound effect
Browse files Browse the repository at this point in the history
  • Loading branch information
lfuelling committed May 9, 2020
1 parent 05b5aed commit f30e9a8
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 4 deletions.
3 changes: 0 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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!



39 changes: 38 additions & 1 deletion client/main.lua
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
ESX = nil
local isDead = false
local soundPlaying = false

--- Thread to get the ESX object
Citizen.CreateThread(function()
Expand Down Expand Up @@ -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
Expand All @@ -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)
1 change: 1 addition & 0 deletions locales/en.lua
Original file line number Diff line number Diff line change
@@ -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',
}

0 comments on commit f30e9a8

Please sign in to comment.