If time allows, I’ll add more configurable visual effects like that. I’m working on a couple other resources at the moment for my own server, but afterwards I’ll revisit this.
Any idea how to set blackout duration depending on speed on impact ?
Not in the current release. In time, I’ll make this an option.
Thanks, i’m working on your script right now, if you want to i can share the realistic effect i get (i can do a video if you wanna take a look).
And for your information with a motorcycle the ped is ejected and do not get any blackout.
Thank you for sharing. We created a script like this one but we preferred to display a blackscreen in CSS rather than using the “blackout” option. Because when the blackout is set, the car stops instantly and the collision effect, seen by a third person, is really unrealistic. The car just stop and freeze on his position. So even if you disable controls or not, it does not change anything. Using a CSS black screen and disabling the controls is the only way we find to stop this freeze of our car, after a collision and a blackout.
Thanks for sharing! i was looking for one so long this is awesome!
Here is a peak on what it looks like on my server =)
I’m making a full video of the effect from the beginning.
Oooh very nice I would love to know how to tweak or get one like this more realalistic
I’ve worked today and it now differentiate the blackout and injured effect depending on the impact speed =)
I can’t get to work a “laying on the wheel” animation while blacking out. Found this one “veh@std@ds@base” but the ped disapears for an unknown reason.
This is super cool man good job!
Unfortunately i can’t share the code unless the owner is ok with it ^^
Go for it, or make a fork on GitHub. Either way is cool with me.
Please credit me if you share any of this =)
-> It is stricly prohibited to LEFR server to use my code as i got kicked away for being away a month or so.
Here is an archive with the script as a ressource and a crash sound in .ogg (works with interactive sound)
Blackout.rar (28.5 KB)
And here is the full code, i commented my modifications, it may be awful, sorry i’m not really a developper, just a newbie.
– No need to modify any of this, but I tried to document what it’s doing
local isBlackedOut = false
local oldBodyDamage = 0
local oldSpeed = 0
local impact = 0local function blackout()
– Only blackout once to prevent an extended blackout if both speed and damage thresholds were met
if not isBlackedOut then
isBlackedOut = true
– This thread will black out the user’s screen for the specified time
Citizen.CreateThread(function()
print("La vitesse d’impacte est ", impact) – Print impact speed for F8 console … in french
TriggerServerEvent(‘InteractSound_SV:PlayWithinDistance’, 50.0, ‘crash01’, 0.5) – Trigger crash sound around yourself, works with InteractiveSound
if impact <= 50 then – Shakycam on impact
ShakeGameplayCam(‘SMALL_EXPLOSION_SHAKE’, 0.4)
elseif impact > 50 and impact <= 60 then
ShakeGameplayCam(‘SMALL_EXPLOSION_SHAKE’, 0.7)
elseif impact > 60 and impact <= 70 then
ShakeGameplayCam(‘MEDIUM_EXPLOSION_SHAKE’, 1.2)
elseif impact > 70 and impact <= 80 then
ShakeGameplayCam(‘MEDIUM_EXPLOSION_SHAKE’, 1.5)
else
ShakeGameplayCam(‘LARGE_EXPLOSION_SHAKE’, 1.5)
end-- Cause death on blackout to have a ragdoll laying on the steering wheel for later revive --SetEntityHealth(GetPlayerPed(-1), 0) Citizen.Wait(200) DoScreenFadeOut(100) -- HERE IS AN ATTEMPT TO PLAY A LAYING ON THE STEERING WHEEL ANIMATION -> Ped disapears, don't know why -- while (not HasAnimDictLoaded("veh@std@ds@base")) do -- RequestAnimDict("veh@std@ds@base") -- Citizen.Wait(5) -- end -- TaskPlayAnim(GetPlayerPed(-1), "veh@std@ds@base", "veh@std@ds@base", 8.0, 1.0, 20000, -1, 0, 0, 0, 0) --veh@std@ds@base StartScreenEffect("DrugsDrivingIn",3000,false) -- Start the injured effect while not IsScreenFadedOut() do Citizen.Wait(0) end if impact <= 50 then -- Blackout duration depending on impact speed, 1000 is 1 sec Citizen.Wait(5000) elseif impact > 50 and impact <= 60 then Citizen.Wait(10000) SetEntityHealth(GetPlayerPed(-1), 160) elseif impact > 60 and impact <= 70 then Citizen.Wait(20000) SetEntityHealth(GetPlayerPed(-1), 150) elseif impact > 70 and impact <= 80 then Citizen.Wait(30000) SetEntityHealth(GetPlayerPed(-1), 125) else Citizen.Wait(30000) SetEntityHealth(GetPlayerPed(-1), 75) -- This setting cause death to passengers, try 100 if you want very low life. end -- HERE WAS THE REVIVE -> Issue is ped is warping out and in the car in a seconde for other players, didn't find a a way to avoid id -- local lastveh = GetVehiclePedIsIn(GetPlayerPed(-1)) -- ResurrectPed(GetPlayerPed(-1)) -- SetEntityHealth(GetPlayerPed(-1), GetEntityMaxHealth(GetPlayerPed(-1))) -- ClearPedTasksImmediately(GetPlayerPed(-1)) -- SetPedIntoVehicle(GetPlayerPed(-1), lastveh, -1) SetFollowVehicleCamViewMode(4) -- Force first person view in the car to increase the blinking wakening and blinking effect if not HasAnimSetLoaded("MOVE_M@DRUNK@VERYDRUNK") then -- move_m@injured or MOVE_M@DRUNK@VERYDRUNK or move_injured_generic RequestAnimSet("MOVE_M@DRUNK@VERYDRUNK") while not HasAnimSetLoaded("MOVE_M@DRUNK@VERYDRUNK") do Citizen.Wait(0) end end SetPedMovementClipset(GetPlayerPed(-1), "MOVE_M@DRUNK@VERYDRUNK", 1.0) -- Set the injured ped move, best one is verydrunk in my opinion. DoScreenFadeIn(1800) -- Blinking effect Citizen.Wait(2000) DoScreenFadeOut(1600) Citizen.Wait(1800) DoScreenFadeIn(1400) Citizen.Wait(1600) DoScreenFadeOut(1100) isBlackedOut = false -- Release controls to the player after 2 blinks (added a disable camera mode to force FPS and a disable multiplayer talking) Citizen.Wait(1100) DoScreenFadeIn(1000) Citizen.Wait(1200) DoScreenFadeOut(900) Citizen.Wait(900) DoScreenFadeIn(800) Citizen.Wait(1000) DoScreenFadeOut(700) Citizen.Wait(700) DoScreenFadeIn(600) if impact <= 50 then -- Injured visual effect duration, depending on impact speed Citizen.Wait(1000) elseif impact > 50 and impact <= 60 then Citizen.Wait(5000) elseif impact > 60 and impact <= 70 then Citizen.Wait(10000) elseif impact > 70 and impact <= 80 then Citizen.Wait(15000) else Citizen.Wait(23000) end StopScreenEffect("DrugsDrivingIn") -- Stop the injured effect to introduce the smooth injured effect exit if impact <= 50 then -- Smooth exit, duration depending on impact speed, again StartScreenEffect("DrugsDrivingOut",1000,false) Citizen.Wait(1200) ResetPedMovementClipset(GetPlayerPed(-1)) ResetPedWeaponMovementClipset(GetPlayerPed(-1)) ResetPedStrafeClipset(GetPlayerPed(-1)) elseif impact > 50 and impact <= 60 then StartScreenEffect("DrugsDrivingOut",4000,false) Citizen.Wait(4200) ResetPedMovementClipset(GetPlayerPed(-1)) ResetPedWeaponMovementClipset(GetPlayerPed(-1)) ResetPedStrafeClipset(GetPlayerPed(-1)) elseif impact > 60 and impact <= 70 then StartScreenEffect("DrugsDrivingOut",8000,false) Citizen.Wait(8200) ResetPedMovementClipset(GetPlayerPed(-1)) ResetPedWeaponMovementClipset(GetPlayerPed(-1)) ResetPedStrafeClipset(GetPlayerPed(-1)) elseif impact > 70 and impact <= 80 then StartScreenEffect("DrugsDrivingOut",10000,false) Citizen.Wait(10200) ResetPedMovementClipset(GetPlayerPed(-1)) ResetPedWeaponMovementClipset(GetPlayerPed(-1)) ResetPedStrafeClipset(GetPlayerPed(-1)) else StartScreenEffect("DrugsDrivingOut",20000,false) Citizen.Wait(20200) ResetPedMovementClipset(GetPlayerPed(-1)) ResetPedWeaponMovementClipset(GetPlayerPed(-1)) ResetPedStrafeClipset(GetPlayerPed(-1)) end end)
end
endCitizen.CreateThread(function()
while true do
Citizen.Wait(0)
HideLoadingOnFadeThisFrame() – Hide loading logo while blackout
– Get the vehicle the player is in, and continue if it exists
local vehicle = GetVehiclePedIsIn(PlayerPedId(), false)
if DoesEntityExist(vehicle) then
– Check if damage blackout is enabled
if Config.BlackoutFromDamage then
local currentDamage = GetVehicleBodyHealth(vehicle)
– If the damage changed, see if it went over the threshold and blackout if necesary
if currentDamage ~= oldBodyDamage then
if not isBlackedOut and (currentDamage < oldBodyDamage) and ((oldBodyDamage - currentDamage) >= Config.BlackoutDamageRequired) then
blackout()
end
oldBodyDamage = currentDamage
end
end-- Check if speed blackout is enabled if Config.BlackoutFromSpeed then --local currentSpeed = GetEntitySpeed(vehicle) * 2.23 local currentSpeed = GetEntitySpeed(vehicle) * 2.23 -- If the speed changed, see if it went over the threshold and blackout if necesary if currentSpeed ~= oldSpeed then if not isBlackedOut and (currentSpeed < oldSpeed) and ((oldSpeed - currentSpeed) >= Config.BlackoutSpeedRequired) then impact = (oldSpeed - currentSpeed) blackout() end oldSpeed = currentSpeed end end else oldBodyDamage = 0 oldSpeed = 0 end if isBlackedOut and Config.DisableControlsOnBlackout then -- Borrowed controls from https://github.com/Sighmir/FiveM-Scripts/blob/master/vrp/vrp_hotkeys/client.lua DisableControlAction(0,71,true) -- veh forward DisableControlAction(0,72,true) -- veh backwards DisableControlAction(0,63,true) -- veh turn left DisableControlAction(0,64,true) -- veh turn right DisableControlAction(0,75,true) -- disable exit vehicle DisableControlAction(0,0,true) -- Disable camera mode to force FPS DisableControlAction(0,249,true) -- disable talking end
end
end)
can i ask where you got the screen effect that adds the colors and the rush to the screen?
From another of our script from our life server.
Cool thanks. i’ve been looking for these for a long time lol
The color change and “rush” effect can also be found in esx_optional needs since its used for the alcohol
Yea i know but im looknig for other effects. not just that one there
Ran into an issue Unsure if its cause I modified the damage, but when the vehicle gets shot and there is a person inside it makes them black out