add new script and liverys

This commit is contained in:
KingMcDonalds
2025-01-31 21:33:12 -08:00
parent 03de184085
commit 577f1ee66a
8 changed files with 135 additions and 6 deletions
@@ -0,0 +1,2 @@
# Auto detect text files and perform LF normalization
* text=auto
+16
View File
@@ -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, Im 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 Ive 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
+76
View File
@@ -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)
+23
View File
@@ -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
@@ -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'
}
+2 -2
View File
@@ -232,8 +232,8 @@ ensure wk_wars2x
ensure ulc
ensure
ensure
ensure reverse-hud
ensure taser_effect-main
ensure
ensure
ensure