Objects
Create server-side objects, handle interactions, attach particle effects and validate object variables.
Integration notes
Additional functions
Check the GitHub repository and source code for additional class functions.
Create server-side objects
Configuration
Create an object
Create a server-side object with its model, position, variables and dimension.
local Object = Server.ObjectManager:new({
model = "prop_veg_crop_orange",
x = 0.0,
y = 0.0,
z = 0.0,
variables = {
isTree = true
},
dimension = 0
})
Object interactions
Configuration
Add a press function
Assign an interaction callback to the object.
---@type fun(Player: SAquiverPlayer, Object: SAquiverObject)
Object.onPress = function(Player, Object)
Player:freeze(true)
Player:disableMovement(true)
Player:progress("Progess Text...", 5000, function()
Player:disableMovement(false)
Player:freeze(false)
Player:addItem("av_peach", 1)
end)
end
Particle effects
Configuration
Attach a particle effect
Create a particle effect attached to the object.
Server.ParticleManager:new({
toObjectRemoteId = Object.data.remoteId,
offset = vector3(0, 0, 1.15),
particleDict = "cut_family4",
particleName = "cs_fam4_juice_splash",
particleUid = "grind-splash",
rotation = vector3(0, 0, 0),
scale = 8.0,
dimension = Object.data.dimension,
timeMS = 3500
})
Variable validators
Integration notes
Default variables
Validators give created object entities default variable values, avoiding nil values during development.
Configuration
Add a variable validator
Normalize an object's variables when it is created.
Server.ObjectManager:addVariableValidator("avp_wooden_barrel", function(Object)
local v = Object.data.variables
v.woodenBarrelLitre = Shared.Utils:RoundNumber(v.woodenBarrelLitre or 0, 1)
v.woodenBarrelAlcoholPercentage = Shared.Utils:RoundNumber(v.woodenBarrelAlcoholPercentage or 0, 1)
v.woodenBarrelAge = Shared.Utils:RoundNumber(v.woodenBarrelAge or 0, 0)
-- Important
v.cellar_object = true
end)