Hi!
I’m using this script and I want to add an animation when I lock or unlock the vehicle. Pretty simple but I have no Idea how to do this. I searched a lot but I can’t find something helpfull.
The Animation I’m looking for is this: “anim@mp_player_intmenu@key_fob@”. I’m very thankfull if someone could help me.
Ps. I don’t speak english very well but I hope it’s not a big problem.
1 Like
use this native: TaskPlayAnim - FiveM Natives @ Cfx.re Docs
something like this
TaskPlayAnim(PlayerPedId(), "anim@mp_player_intmenu@key_fob@","fob_click", 8.0, 0.0, -1, 1, 0, 0, 0, 0)
1 Like
in the function that triggers when you lock the car
I added it but it won’t work
function ToggleVehicleLock()
local playerPed = PlayerPedId()
local coords = GetEntityCoords(playerPed)
local vehicle
Citizen.CreateThread(function()
StartWorkaroundTask()
end)
if IsPedInAnyVehicle(playerPed, false) then
vehicle = GetVehiclePedIsIn(playerPed, false)
else
vehicle = GetClosestVehicle(coords, 8.0, 0, 71)
end
if not DoesEntityExist(vehicle) then
return
end
ESX.TriggerServerCallback('esx_vehiclelock:requestPlayerCars', function(isOwnedVehicle)
if isOwnedVehicle then
local lockStatus = GetVehicleDoorLockStatus(vehicle)
if lockStatus == 1 then -- unlocked
SetVehicleDoorsLocked(vehicle, 2)
PlayVehicleDoorCloseSound(vehicle, 1)
TaskPlayAnim(PlayerPedId(), "anim@mp_player_intmenu@key_fob@","fob_click", 8.0, 0.0, -1, 1, 0, 0, 0, 0)
-- TriggerEvent('chat:addMessage', { args = { _U('message_title'), _U('message_locked') } })
elseif lockStatus == 2 then -- locked
SetVehicleDoorsLocked(vehicle, 1)
PlayVehicleDoorOpenSound(vehicle, 0)
TaskPlayAnim(PlayerPedId(), "anim@mp_player_intmenu@key_fob@","fob_click", 8.0, 0.0, -1, 1, 0, 0, 0, 0)
-- TriggerEvent('chat:addMessage', { args = { _U('message_title'), _U('message_unlocked') } })
end
end
end, ESX.Math.Trim(GetVehicleNumberPlateText(vehicle)))
end
I still need help with this script. It would be nice if someone could help me.
Hi,
You have to load animDict before use it
while (not HasAnimDictLoaded("anim@mp_player_intmenu@key_fob@")) do
RequestAnimDict("anim@mp_player_intmenu@key_fob@")
Citizen.Wait(0)
end
TaskPlayAnim(PlayerPedId(), "anim@mp_player_intmenu@key_fob@","fob_click", 8.0, 0.0, -1, 1, 0, 0, 0, 0)
Hi and thank you! It works now but it loops the animation. Any way to fix this?
Derass
May 28, 2022, 10:31am
9
Try this, i just change the blendInSpeed: to 8.0 and flag: to 0
while (not HasAnimDictLoaded("anim@mp_player_intmenu@key_fob@")) do
RequestAnimDict("anim@mp_player_intmenu@key_fob@")
Citizen.Wait(0)
end
TaskPlayAnim(PlayerPedId(), "anim@mp_player_intmenu@key_fob@","fob_click", 8.0, 8.0, -1, 0, 0, 0, 0, 0)
1 Like
Hey!
Would you please help me again? The Animation works fine but the character stands still if I lock the car. Is it possible to allow movement while the animation is playing?