diff --git a/resources/[EGRP-CarPacks]/EGRP-Emergency/stream/amrvan/amrvan+hi.ytd b/resources/[EGRP-CarPacks]/EGRP-Emergency/stream/amrvan/amrvan+hi.ytd index 04c2efa31..40eea5b2d 100644 --- a/resources/[EGRP-CarPacks]/EGRP-Emergency/stream/amrvan/amrvan+hi.ytd +++ b/resources/[EGRP-CarPacks]/EGRP-Emergency/stream/amrvan/amrvan+hi.ytd @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:e4b50ddd80936d5545ba8e9c8055d6b8379c4d832fdeb96b004c5ece24eb8983 -size 2361250 +oid sha256:df17ff05ce6e7499991796f5b1f2f7aff866705b975579ff15ca619d917b4d45 +size 2720849 diff --git a/resources/[EGRP-CarPacks]/EGRP-Emergency/stream/amrvan/amrvan.ytd b/resources/[EGRP-CarPacks]/EGRP-Emergency/stream/amrvan/amrvan.ytd index b8b88932f..933a13cf4 100644 --- a/resources/[EGRP-CarPacks]/EGRP-Emergency/stream/amrvan/amrvan.ytd +++ b/resources/[EGRP-CarPacks]/EGRP-Emergency/stream/amrvan/amrvan.ytd @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:3eccee0b6a333a687236390fe453eaeb805af50b0fab83ccc2b43a7172bf393e -size 12768182 +oid sha256:6fe1fed6c18c371ddcf57cc681b6f23ce7a41192a484d9e19983c7ea81c3ec83 +size 13305431 diff --git a/resources/taser_effect-main/.gitattributes b/resources/taser_effect-main/.gitattributes new file mode 100644 index 000000000..dfe077042 --- /dev/null +++ b/resources/taser_effect-main/.gitattributes @@ -0,0 +1,2 @@ +# Auto detect text files and perform LF normalization +* text=auto diff --git a/resources/taser_effect-main/README.md b/resources/taser_effect-main/README.md new file mode 100644 index 000000000..c72bd7f84 --- /dev/null +++ b/resources/taser_effect-main/README.md @@ -0,0 +1,16 @@ +# Taser Effect + +### About +Taser effect is a script that does what it says, adds a taser effect when the player gets stunned. + +Now, I’m aware that there already exists a taser effect script out there, however, this one is different. Instead of looping in a thread to check if the player is stunned every frame, it uses game events. This of course makes the script more optimised (0.0ms at all times). + +It also fades out the visual effect than just turning it off in an instant. + +These are small changes, but I’ve decided to share this as it does provide improvements over the “old one”. + +Update 25.07.2023: + +Added a config file for easier usage, and added options for disabling writhe (Insta death from getting stunned) as well options for NPC's to drop weapons. + Added an experimental option for players laying min/max time laying on the ground after getting stunned. + +FiveM Forum Post: https://forum.cfx.re/t/release-taser-effect/5017860 diff --git a/resources/taser_effect-main/client.lua b/resources/taser_effect-main/client.lua new file mode 100644 index 000000000..d1d6e5411 --- /dev/null +++ b/resources/taser_effect-main/client.lua @@ -0,0 +1,76 @@ +local stunnedCache = {} +local stunnedStack = 0 + +local function DoTaserEffect(effectLength) + stunnedStack = stunnedStack + 1 + SetTimecycleModifierStrength(Config.TimecycleStrength) + SetTimecycleModifier("dont_tazeme_bro") + + if Config.CameraShake then + ShakeGameplayCam(Config.CameraShakeName, Config.CameraShakeIntensity) + end + + Wait(effectLength) + stunnedStack = stunnedStack - 1 + if stunnedStack == 0 then + SetTransitionTimecycleModifier('default', Config.TimecycleTransitionDuration) + if Config.CameraShake then + StopGameplayCamShaking(false) + end + end +end + +local function OnLocalPlayerStunned(playerPed, attacker) + -- This usually won't effect the player ped the first time the get stunned. + local groundTime = Config.MinGroundTime == Config.MaxGroundTime and Config.MinGroundTime or math.random(Config.MinGroundTime, Config.MaxGroundTime) + SetPedMinGroundTimeForStungun(playerPed, groundTime) + + -- Needed as weaponHash does not guarantee that we actually were stunned, and IsPedBeingStunned doesn't return true before a frame after beeing stunned + SetTimeout(50, function() + local gameTimer = GetGameTimer() + -- If the player was stunned by the same source less them 2.8 seconds ago then ignore, this is to not spam the event when taking fall damage while beeing stunned + if stunnedCache[attacker] and stunnedCache[attacker] + 2800 > gameTimer then + return + end + + if IsPedBeingStunned(playerPed, 0) then + stunnedCache[attacker] = gameTimer + DoTaserEffect(groundTime) + end + end) +end + +local function OnNPCStunned(args) + local ped = args[1] + + if Config.DisableNPCWrithe then + SetPedConfigFlag(ped, 281, true) -- Disable Writhe + end + + if Config.NPCDropWeapon then + Wait(400) + local visible, _currentWeapon = GetCurrentPedWeapon(ped, true) + if visible then + SetPedDropsWeapon(ped) + end + end +end + +-- Use game events to avoid unnecessary threads/loops +AddEventHandler('gameEventTriggered', function(event, args) + if event == "CEventNetworkEntityDamage" then + local weaponHash = args[7] + if not Config.ValidWeapons[weaponHash] then + return + end + + local playerPed = PlayerPedId() + local attacker = args[2] + + if playerPed == args[1] and attacker ~= -1 then + OnLocalPlayerStunned(playerPed, attacker) + elseif IsEntityAPed(args[1]) and not IsPedAPlayer(args[1]) and NetworkHasControlOfEntity(args[1]) then + OnNPCStunned(args) + end + end +end) diff --git a/resources/taser_effect-main/config.lua b/resources/taser_effect-main/config.lua new file mode 100644 index 000000000..3167a95e4 --- /dev/null +++ b/resources/taser_effect-main/config.lua @@ -0,0 +1,23 @@ +Config = {} + +Config.ValidWeapons = { + [`WEAPON_STUNGUN`] = true, + [`WEAPON_STUNGUN_MP`] = true, + [`WEAPON_ELECTRIC_FENCE`] = true, + [`WEAPON_STUNROD`] = true +} + +-- Due to how this is set up it usually won't effect the player ped the first time the get stunned. +Config.MinGroundTime = 5000 -- The minimum time in milliseconds that players will lay on the ground after getting tazed +Config.MaxGroundTime = 9000 -- The maximum time in milliseconds that players will lay on the ground after getting tazed + +Config.TimecycleStrength = 0.5 +Config.Timecycle = "dont_tazeme_bro" -- Other timecycles can for example be: hud_def_desat_Trevor, dont_tazeme_bro_b, drug_wobbly etc. +Config.TimecycleTransitionDuration = 5.0 -- How long the transition back to no timecycle should last "Appears to be half-seconds (?)": https://docs.fivem.net/natives/?_0x3BCF567485E1971C + +Config.CameraShake = true -- If we should shake the camera on beeing stunned +Config.CameraShakeName = "FAMILY5_DRUG_TRIP_SHAKE" +Config.CameraShakeIntensity = 0.25 + +Config.DisableNPCWrithe = true -- Disabled writhe for NPC when getting stunned. This will also make it so npc's won't do go into writhe even after they are done beeing stunned. (This ONLY effects stunned peds) +Config.NPCDropWeapon = true -- Makes NPC's drop their weapon when they get stunned diff --git a/resources/taser_effect-main/fxmanifest.lua b/resources/taser_effect-main/fxmanifest.lua new file mode 100644 index 000000000..040bd0bf6 --- /dev/null +++ b/resources/taser_effect-main/fxmanifest.lua @@ -0,0 +1,12 @@ +fx_version 'cerulean' +game 'gta5' +lua54 'yes' + +author 'Mads' +description 'Taser Effect' +version '1.0.2' + +client_scripts { + 'config.lua', + 'client.lua' +} diff --git a/server.cfg b/server.cfg index c41901739..244f19ad5 100644 --- a/server.cfg +++ b/server.cfg @@ -232,8 +232,8 @@ ensure wk_wars2x ensure ulc -ensure -ensure +ensure reverse-hud +ensure taser_effect-main ensure ensure ensure