95 lines
3.2 KiB
Lua
95 lines
3.2 KiB
Lua
local HoldingProp = nil
|
|
|
|
local function spawnProp(model, bone, coords, rotation, attach)
|
|
TLS.Functions.RequestModel(model)
|
|
|
|
local ped = PlayerPedId()
|
|
local tempCoords = GetEntityCoords(ped)
|
|
local object = CreateObject(model, tempCoords.x, tempCoords.y, tempCoords.z, true, true, false)
|
|
|
|
if attach then
|
|
SetEntityCollision(object, false, false)
|
|
AttachEntityToEntity(object, ped, GetPedBoneIndex(ped, bone), coords.x, coords.y, coords.z, rotation.x, rotation.y, rotation.z, true, true, false, true, 1, true)
|
|
|
|
HoldingProp = object
|
|
else
|
|
PlaceObjectOnGroundProperly(object)
|
|
FreezeEntityPosition(object, true)
|
|
end
|
|
|
|
SetModelAsNoLongerNeeded(model)
|
|
|
|
return object
|
|
end
|
|
|
|
if PropConfig.EnableDrop then
|
|
CreateThread(function()
|
|
while true do
|
|
local sleep = 500
|
|
local ped = PlayerPedId()
|
|
|
|
if IsPedOnFoot(ped) then
|
|
local coords = GetEntityCoords(ped)
|
|
|
|
for model, data in pairs(PropConfig.Props) do
|
|
local object = GetClosestObjectOfType(coords.x, coords.y, coords.z, 1.5, model, false, false)
|
|
|
|
if (object ~= 0) and not HoldingProp then
|
|
sleep = 0
|
|
|
|
TLS.Functions.ShowHelpAlert('~INPUT_PICKUP~ Pickup')
|
|
|
|
if IsControlJustPressed(0, 38) then
|
|
local dict, anim = 'weapons@first_person@aim_rng@generic@projectile@sticky_bomb@', 'plant_floor'
|
|
|
|
TLS.Functions.RequestAnimDict(dict)
|
|
|
|
TaskPlayAnim(ped, dict, anim, 8.0, 1.0, 1000, 16, 0.0, false, false, false)
|
|
RemoveAnimDict(dict)
|
|
Wait(1000)
|
|
|
|
TLS.Functions.DeleteEntity(object)
|
|
|
|
spawnProp(model, data.bone, data.coords, data.rotation, true)
|
|
end
|
|
end
|
|
end
|
|
|
|
if HoldingProp ~= nil then
|
|
sleep = 0
|
|
local dict, anim = 'move_weapon@jerrycan@generic', 'idle'
|
|
|
|
TLS.Functions.ShowHelpAlert('~INPUT_PICKUP~ Drop')
|
|
|
|
if not IsEntityPlayingAnim(ped, dict, anim, 3) then
|
|
TLS.Functions.RequestAnimDict(dict)
|
|
|
|
TaskPlayAnim(ped, dict, anim, 1.0, 1.0, -1, 49, 0.0, false, false, false)
|
|
RemoveAnimDict(dict)
|
|
end
|
|
|
|
if IsControlJustPressed(0, 38) then
|
|
spawnProp(GetEntityModel(HoldingProp))
|
|
|
|
TLS.Functions.DeleteEntity(HoldingProp)
|
|
ClearPedTasks(ped)
|
|
|
|
HoldingProp = nil
|
|
end
|
|
end
|
|
end
|
|
|
|
Wait(sleep)
|
|
end
|
|
end)
|
|
end
|
|
|
|
for model, data in pairs(PropConfig.Props) do
|
|
RegisterNetEvent(data.event, function()
|
|
spawnProp(model, data.bone, data.coords, data.rotation, true)
|
|
end)
|
|
|
|
RegisterCommand(data.command, function()
|
|
spawnProp(model, data.bone, data.coords, data.rotation, true)
|
|
end, false)
|
|
end |