mirror of
https://github.com/jimathy/jim-boarding.git
synced 2026-05-13 03:22:08 -04:00
38 lines
1.6 KiB
Lua
38 lines
1.6 KiB
Lua
local QBCore = exports['qb-core']:GetCoreObject()
|
|
RegisterNetEvent('QBCore:Client:UpdateObject', function() QBCore = exports['qb-core']:GetCoreObject() end)
|
|
|
|
function loadModel(model) if not HasModelLoaded(model) then RequestModel(model) while not HasModelLoaded(model) do Wait(0) end end end
|
|
function unloadModel(model) SetModelAsNoLongerNeeded(model) end
|
|
function loadAnimDict(dict) while not HasAnimDictLoaded(dict) do RequestAnimDict(dict) Wait(5) end end
|
|
function unloadAnimDict(dict) RemoveAnimDict(dict) end
|
|
|
|
function destroyProp(entity)
|
|
SetEntityAsMissionEntity(entity) Wait(5)
|
|
DetachEntity(entity, true, true) Wait(5)
|
|
DeleteObject(entity)
|
|
end
|
|
|
|
function makeProp(data, freeze, synced)
|
|
loadModel(data.prop)
|
|
local prop = CreateObject(data.prop, data.coords.x, data.coords.y, data.coords.z-1.03, synced or 0, synced or 0, 0)
|
|
SetEntityHeading(prop, data.coords.w)
|
|
FreezeEntityPosition(prop, freeze or 0)
|
|
return prop
|
|
end
|
|
|
|
function makePed(model, coords, freeze, collision, scenario, anim)
|
|
loadModel(model)
|
|
local ped = CreatePed(0, model, coords.x, coords.y, coords.z-1.03, coords.w, false, false)
|
|
SetEntityInvincible(ped, true)
|
|
SetBlockingOfNonTemporaryEvents(ped, true)
|
|
FreezeEntityPosition(ped, freeze or true)
|
|
if collision then SetEntityNoCollisionEntity(ped, PlayerPedId(), false) end
|
|
if scenario then TaskStartScenarioInPlace(ped, scenario, 0, true) end
|
|
if anim then
|
|
loadAnimDict(anim[1])
|
|
TaskPlayAnim(ped, anim[1], anim[2], 1.0, 1.0, -1, 1, 0.2, 0, 0, 0)
|
|
end
|
|
return ped
|
|
end
|
|
|
|
function toggleItem(give, item, amount) TriggerServerEvent("jim-skateboard:server:toggleItem", give, item, amount) end |