small update
target got a print if onSelect or action are nil also added groups in fixoptions for sleepless client entities using return for loadmodel
This commit is contained in:
1 parent
07b76868f2
commit
2ad1f4669c
4 files changed
+16
-12
No files matched your search
@@ -12,15 +12,15 @@ local function SpawnEntity(entityData)
|
|||||||
-- for k, v in pairs(entityData.args) do
|
-- for k, v in pairs(entityData.args) do
|
||||||
-- print(string.format("SpawnEntity %s: %s", k, v))
|
-- print(string.format("SpawnEntity %s: %s", k, v))
|
||||||
-- end
|
-- end
|
||||||
local model = entityData.model and type(entityData.model) == 'string' and GetHashKey(entityData.model) or entityData.model
|
local loaded, model = Utility.GetModel(entityData.model)
|
||||||
if model and not Utility.LoadModel(model) then
|
if not loaded then
|
||||||
print(string.format("[ClientEntity] Failed to load model %s for entity %s", entityData.model, entityData.id))
|
print(string.format("[ClientEntity] Failed to load model %s for entity %s", entityData.model, entityData.id))
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
local entity = nil
|
local entity = nil
|
||||||
local coords = entityData.coords
|
local coords = entityData.coords
|
||||||
local rotation = entityData.rotation or vector3(0.0, 0.0, 0.0) -- Default rotation if not provided
|
local rotation = entityData.rotation or vector3(0.0, 0.0, entityData.heading or 0.0) -- Default rotation if not provided
|
||||||
|
|
||||||
if entityData.entityType == 'object' then
|
if entityData.entityType == 'object' then
|
||||||
entity = CreateObject(model, coords.x, coords.y, coords.z, false, false, false)
|
entity = CreateObject(model, coords.x, coords.y, coords.z, false, false, false)
|
||||||
|
|||||||
@@ -226,10 +226,9 @@ end
|
|||||||
|
|
||||||
---Load a model into memory
|
---Load a model into memory
|
||||||
---@param model string|number
|
---@param model string|number
|
||||||
---@return boolean
|
---@return boolean, number
|
||||||
function Utility.LoadModel(model)
|
function Utility.LoadModel(model)
|
||||||
local loaded = ensureModelLoaded(model)
|
return ensureModelLoaded(model)
|
||||||
return loaded
|
|
||||||
end
|
end
|
||||||
|
|
||||||
---Request an animation dictionary
|
---Request an animation dictionary
|
||||||
|
|||||||
@@ -22,14 +22,18 @@ Target = Target or {}
|
|||||||
Target.FixOptions = function(options)
|
Target.FixOptions = function(options)
|
||||||
for k, v in pairs(options) do
|
for k, v in pairs(options) do
|
||||||
local action = v.onSelect or v.action
|
local action = v.onSelect or v.action
|
||||||
local select = function(entityOrData)
|
if not action then
|
||||||
if type(entityOrData) == 'table' then
|
print(("Target option (%s) %s is missing an 'onSelect' or 'action' function."):format(k, v.label))
|
||||||
return action(entityOrData.entity)
|
else
|
||||||
|
local select = function(entityOrData)
|
||||||
|
if type(entityOrData) == 'table' then
|
||||||
|
return action(entityOrData.entity)
|
||||||
|
end
|
||||||
|
return action(entityOrData)
|
||||||
end
|
end
|
||||||
return action(entityOrData)
|
options[k].onSelect = select
|
||||||
|
options[k].groups = v.job or v.groups
|
||||||
end
|
end
|
||||||
options[k].onSelect = select
|
|
||||||
options[k].groups = v.job or v.groups
|
|
||||||
end
|
end
|
||||||
return options
|
return options
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -28,6 +28,7 @@ Target.FixOptions = function(options)
|
|||||||
return action(entityOrData)
|
return action(entityOrData)
|
||||||
end
|
end
|
||||||
options[k].onSelect = select
|
options[k].onSelect = select
|
||||||
|
options[k].groups = v.job or v.groups
|
||||||
end
|
end
|
||||||
return options
|
return options
|
||||||
end
|
end
|
||||||
|
|||||||
Reference in new issue
Block a user