113 lines
3.5 KiB
Lua
113 lines
3.5 KiB
Lua
Config.TargetSystem = nil
|
|
|
|
if GetResourceState("qb-target") ~= "missing" then
|
|
Config.TargetSystem = "qb-target"
|
|
elseif GetResourceState("qtarget") ~= "missing" then
|
|
Config.TargetSystem = "qtarget"
|
|
elseif GetResourceState("ox_target") ~= "missing" then
|
|
Config.TargetSystem = "qtarget" -- OX_Target have a backward compability to qtarget
|
|
end
|
|
|
|
-- Comenzi utile pentru testare animatii + props
|
|
local testProp = nil
|
|
RegisterCommand("testanim", function()
|
|
local ped = PlayerPedId()
|
|
local dict = "amb@code_human_in_bus_passenger_idles@female@tablet@base"
|
|
RequestAnimDict(dict)
|
|
while not HasAnimDictLoaded(dict) do Wait(10) end
|
|
TaskPlayAnim(ped, dict, "base", 2.0, -2.0, -1, 49, 0, false, false, false)
|
|
local model = GetHashKey("prop_cs_tablet")
|
|
RequestModel(model)
|
|
while not HasModelLoaded(model) do Wait(10) end
|
|
local coords = GetEntityCoords(ped)
|
|
testProp = CreateObject(model, coords.x, coords.y, coords.z, true, true, true)
|
|
AttachEntityToEntity(testProp, ped, GetPedBoneIndex(ped, 60309),
|
|
0.03, 0.002, -0.0, 10.0, 160.0, 0.0, true, true, false, true, 1, true)
|
|
end, false)
|
|
|
|
RegisterCommand("stopanim", function()
|
|
ClearPedTasks(PlayerPedId())
|
|
if testProp and DoesEntityExist(testProp) then DeleteEntity(testProp) testProp = nil end
|
|
end, false)
|
|
|
|
-- Animatie tableta pentru meniul Job Center
|
|
local tabletProp = nil
|
|
local animDict = "amb@code_human_in_bus_passenger_idles@female@tablet@base"
|
|
local animName = "base"
|
|
|
|
Utils.PlayTabletAnim = function()
|
|
local ped = PlayerPedId()
|
|
|
|
-- Incarca animatia
|
|
RequestAnimDict(animDict)
|
|
while not HasAnimDictLoaded(animDict) do
|
|
Wait(10)
|
|
end
|
|
|
|
-- Joaca animatia (flag 49 = loop + upper body + secondary)
|
|
TaskPlayAnim(ped, animDict, animName, 2.0, -2.0, -1, 49, 0, false, false, false)
|
|
|
|
-- Creeaza prop tableta
|
|
local model = GetHashKey("prop_cs_tablet")
|
|
RequestModel(model)
|
|
while not HasModelLoaded(model) do
|
|
Wait(10)
|
|
end
|
|
|
|
local coords = GetEntityCoords(ped)
|
|
tabletProp = CreateObject(model, coords.x, coords.y, coords.z, true, true, true)
|
|
-- Ataseaza la mana dreapta (bone 60309)
|
|
AttachEntityToEntity(tabletProp, ped, GetPedBoneIndex(ped, 60309),
|
|
0.03, 0.002, -0.0, 10.0, 160.0, 0.0, true, true, false, true, 1, true)
|
|
|
|
SetModelAsNoLongerNeeded(model)
|
|
RemoveAnimDict(animDict)
|
|
end
|
|
|
|
Utils.StopTabletAnim = function()
|
|
local ped = PlayerPedId()
|
|
|
|
-- Opreste animatia
|
|
ClearPedTasks(ped)
|
|
|
|
-- Sterge prop-ul
|
|
if tabletProp and DoesEntityExist(tabletProp) then
|
|
DeleteEntity(tabletProp)
|
|
tabletProp = nil
|
|
end
|
|
end
|
|
|
|
Utils.AddEntityToTarget = function(entity)
|
|
exports[Config.TargetSystem]:AddTargetEntity(entity, {
|
|
options = {
|
|
{
|
|
icon = "fas fa-briefcase",
|
|
label = _L("Interaction.Open"),
|
|
action = function()
|
|
Utils.PlayTabletAnim()
|
|
Utils.ToggleNUI(true)
|
|
end,
|
|
},
|
|
},
|
|
distance = 1.5
|
|
})
|
|
end
|
|
|
|
-- Opreste animatia cand se inchide meniul (safety net)
|
|
-- Monitorizeza NUI focus — cand se pierde, opreste animatia
|
|
CreateThread(function()
|
|
local wasOpen = false
|
|
while true do
|
|
Wait(500)
|
|
local nuiFocused = IsNuiFocused()
|
|
if wasOpen and not nuiFocused then
|
|
-- Meniul tocmai s-a inchis
|
|
Utils.StopTabletAnim()
|
|
wasOpen = false
|
|
elseif nuiFocused and tabletProp and DoesEntityExist(tabletProp) then
|
|
wasOpen = true
|
|
end
|
|
end
|
|
end)
|
|
|