I have an item called “candy” that I want to be able to give to people and have them consume that immobilizes them.
My code below currently works for making them feel intoxicated, but it doesn’t slow their movement down at all.
I’ve tried both SetPedMoveRateOverride and SetRunSprintMultiplierForPlayer, but it appears neither of these slow the player down at all.
If there’s anybody who knows a suitable replacement, please let me know!
My current code:
RegisterNetEvent('esx_drugeffects:onCandy')
AddEventHandler('esx_drugeffects:onCandy', function()
local playerPed = GetPlayerPed(-1)
RequestAnimSet("MOVE_M@DRUNK@VERYDRUNK")
while not HasAnimSetLoaded("MOVE_M@DRUNK@VERYDRUNK") do
Citizen.Wait(0)
end
Citizen.Wait(10000)
local player = PlayerId()
ClearPedTasksImmediately(playerPed)
SetTimecycleModifier("spectator5")
SetPedMotionBlur(playerPed, true)
SetPedMovementClipset(playerPed, "MOVE_M@DRUNK@VERYDRUNK", true)
SetPedIsDrunk(playerPed, true)
-- Effects
SetPedMoveRateOverride(PlayerPedId(), 0.1)
-- Wait and Reset Effects
Wait(900000)
SetPedMoveRateOverride(PlayerPedId(), 1.0)
end)
local DoEffects = false
Citizen.CreateThread(function()
while true do
Citizen.Wait(16)
if DoEffects then
SetPedMoveRateOverride(PlayerPedId(), 0.1)
end
end
end)
you just have to set the ‘DoEffects’ to true in the client event:
(and get rid of other override calls)
DoEffects in this case is just a bool that is being toggled to determine if the Override should take place, and this is being checked every frame (16 milisecs).
it has to be declared in the client (outside of the thread) to be toggled by a separate Event (the client event being triggered)
every time the event is called it will toggle On, then when the “wait” period is over it will toggle back to false and the override should automatically stop taking place (in other words the gta/fivem server automatically sets the moverate value back to 1.0 if the override was not called at a given interval, so we dont need to set it back to default ourselves)
i am looking for a script like ,
player use item '“cocaine”
then run faster and have unlimited stamina for 1 minute
do you know if there is something like that ?