update: keyfob anim

This commit is contained in:
Andyyy7666
2023-07-22 21:42:45 +02:00
parent 5fd51f5329
commit 98433908e9
2 changed files with 14 additions and 4 deletions

View File

@@ -74,6 +74,9 @@ end)
local function playKeyFob(veh) local function playKeyFob(veh)
local keyFob local keyFob
local ped = cache.ped local ped = cache.ped
local coords = GetEntityCoords(ped)
if #(coords-GetEntityCoords(veh)) > 25.0 then return end
if GetVehiclePedIsIn(ped) == 0 then if GetVehiclePedIsIn(ped) == 0 then
ClearPedTasks(ped) ClearPedTasks(ped)
lib.requestAnimDict("anim@mp_player_intmenu@key_fob@") lib.requestAnimDict("anim@mp_player_intmenu@key_fob@")
@@ -94,13 +97,13 @@ local function playKeyFob(veh)
return keyFob and DeleteEntity(keyFob) return keyFob and DeleteEntity(keyFob)
end end
RegisterNetEvent("ND_Vehicles:keyFob", function(vehicleNetId)
playKeyFob(NetToVeh(vehicleNetId))
end)
AddStateBagChangeHandler("locked", nil, function(bagName, key, value, reserved, replicated) AddStateBagChangeHandler("locked", nil, function(bagName, key, value, reserved, replicated)
local entity = GetEntityFromStateBagName(bagName) local entity = GetEntityFromStateBagName(bagName)
if entity == 0 then return end if entity == 0 then return end
CreateThread(function()
playKeyFob(entity)
end)
if value then if value then
SetVehicleDoorsLocked(entity, 4) SetVehicleDoorsLocked(entity, 4)
@@ -128,3 +131,9 @@ lib.callback.register("ND_Vehicles:getNearbyVehicleById", function(vehId)
end end
end end
end) end)
lib.callback.register("ND_Vehicles:getVehicleModelMakeLabel", function(model)
local make = GetLabelText(GetMakeNameFromVehicleModel(model))
local name = GetLabelText(GetDisplayNameFromVehicleModel(model))
return ("%s %s"):format(make, name)
end)

View File

@@ -244,6 +244,7 @@ if Config.useInventoryForKeys then
local state = Entity(veh).state local state = Entity(veh).state
local locked = not state.locked local locked = not state.locked
state.locked = locked state.locked = locked
player.triggerEvent("ND_Vehicles:keyFob", NetworkGetNetworkIdFromEntity(veh))
if locked then if locked then
player.notify({ player.notify({
title = "LOCKED", title = "LOCKED",