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:
Mr.Crowley committed 2025-07-24 05:03:07 -05:00
1 parent 07b76868f2
commit 2ad1f4669c
4 files changed
+16 -12

No files matched your search

+3 -3
View File
@@ -12,15 +12,15 @@ local function SpawnEntity(entityData)
-- for k, v in pairs(entityData.args) do
-- print(string.format("SpawnEntity %s: %s", k, v))
-- end
local model = entityData.model and type(entityData.model) == 'string' and GetHashKey(entityData.model) or entityData.model
if model and not Utility.LoadModel(model) then
local loaded, model = Utility.GetModel(entityData.model)
if not loaded then
print(string.format("[ClientEntity] Failed to load model %s for entity %s", entityData.model, entityData.id))
return
end
local entity = nil
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
entity = CreateObject(model, coords.x, coords.y, coords.z, false, false, false)
+2 -3
View File
@@ -226,10 +226,9 @@ end
---Load a model into memory
---@param model string|number
---@return boolean
---@return boolean, number
function Utility.LoadModel(model)
local loaded = ensureModelLoaded(model)
return loaded
return ensureModelLoaded(model)
end
---Request an animation dictionary
+10 -6
View File
@@ -22,14 +22,18 @@ Target = Target or {}
Target.FixOptions = function(options)
for k, v in pairs(options) do
local action = v.onSelect or v.action
local select = function(entityOrData)
if type(entityOrData) == 'table' then
return action(entityOrData.entity)
if not action then
print(("Target option (%s) %s is missing an 'onSelect' or 'action' function."):format(k, v.label))
else
local select = function(entityOrData)
if type(entityOrData) == 'table' then
return action(entityOrData.entity)
end
return action(entityOrData)
end
return action(entityOrData)
options[k].onSelect = select
options[k].groups = v.job or v.groups
end
options[k].onSelect = select
options[k].groups = v.job or v.groups
end
return options
end
@@ -28,6 +28,7 @@ Target.FixOptions = function(options)
return action(entityOrData)
end
options[k].onSelect = select
options[k].groups = v.job or v.groups
end
return options
end