mirror of
https://github.com/CommunityOx/ox_lib.git
synced 2026-08-17 06:56:03 +01:00
refactor(resource/interface): keymapping and multi-prop support
Prop data should support a single table or an array for multiple props.
This commit is contained in:
@@ -9,6 +9,14 @@ local disableKeys = {
|
|||||||
combat = {25}
|
combat = {25}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
local function createProp(prop)
|
||||||
|
lib.requestModel(prop.model)
|
||||||
|
local coords = GetEntityCoords(cache.ped)
|
||||||
|
local object = CreateObject(prop.model, coords.x, coords.y, coords.z, true, true, true)
|
||||||
|
AttachEntityToEntity(object, cache.ped, GetPedBoneIndex(cache.ped, prop.bone or 60309), prop.pos.x, prop.pos.y, prop.pos.z, prop.rot.x, prop.rot.y, prop.rot.z, true, true, false, true, 0, true)
|
||||||
|
return object
|
||||||
|
end
|
||||||
|
|
||||||
local function startProgress(data)
|
local function startProgress(data)
|
||||||
progress = data
|
progress = data
|
||||||
|
|
||||||
@@ -24,16 +32,15 @@ local function startProgress(data)
|
|||||||
end
|
end
|
||||||
|
|
||||||
if data.prop then
|
if data.prop then
|
||||||
for i = 1, #data.prop do
|
if data.prop.model then
|
||||||
local prop = data.prop[i]
|
data.prop1 = createProp(data.prop)
|
||||||
|
else
|
||||||
|
for i = 1, #data.prop do
|
||||||
|
local prop = data.prop[i]
|
||||||
|
|
||||||
if prop then
|
if prop then
|
||||||
lib.requestModel(prop.model)
|
data['prop'..i] = createProp(prop)
|
||||||
|
end
|
||||||
local coords = GetEntityCoords(cache.ped)
|
|
||||||
local object = CreateObject(prop.model, coords.x, coords.y, coords.z, true, true, true)
|
|
||||||
AttachEntityToEntity(object, cache.ped, GetPedBoneIndex(cache.ped, prop.bone or 60309), prop.pos.x, prop.pos.y, prop.pos.z, prop.rot.x, prop.rot.y, prop.rot.z, true, true, false, true, 0, true)
|
|
||||||
data['prop'..i] = object
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@@ -78,7 +85,8 @@ local function startProgress(data)
|
|||||||
end
|
end
|
||||||
|
|
||||||
if data.prop then
|
if data.prop then
|
||||||
for i = 1, #data.prop do
|
local n = #data.prop
|
||||||
|
for i = 1, n > 0 and n or 1 do
|
||||||
local prop = data['prop'..i]
|
local prop = data['prop'..i]
|
||||||
|
|
||||||
if prop then
|
if prop then
|
||||||
@@ -154,3 +162,5 @@ end)
|
|||||||
RegisterCommand('cancelprogress', function()
|
RegisterCommand('cancelprogress', function()
|
||||||
if progress?.canCancel then progress = false end
|
if progress?.canCancel then progress = false end
|
||||||
end)
|
end)
|
||||||
|
|
||||||
|
RegisterKeyMapping('cancelprogress', 'Cancel current progress bar', 'keyboard', 'x')
|
||||||
|
|||||||
Reference in New Issue
Block a user