Skip to content

RemoveLevelObject

Takes a part of the level out on every player’s game - a house, a wall, a tree, an entity.

kind says what it is: "brush" - a static mesh of the level (a house, a wall, a rock) - or "vegetation" (a tree, a bush), named by opts.mesh and found by the centre of its box at (x, y, z), within 5 cm; or "entity", one of the level’s entities, named by opts.class and opts.name and found at its position, within 5 m. Admins measure both by looking at the thing; a mode takes the values from there - or from a player’s own look: a client script’s GetLookTarget gives a tree’s or a building’s mesh and center, sent up with SendServerEvent (its kind says which: "vegetation" is "vegetation" here, "static" is "brush" - many of the level’s small stones are vegetation). Players walk through where it stood and the server’s collision follows; RestoreLevelObject puts it back. opts.layer and opts.persist as an object’s.

RemoveLevelObject(kind, x, y, z, opts)
Parameter Type
kind string "brush", "vegetation" or "entity"
x number metres
y number metres
z number metres
opts table mesh (a brush or vegetation), class and name (an entity), layer, persist

number - the removal’s id; nil and the reason when the server has no map or something is missing

-- the fallen tree across the road goes for the race
RACE_GAP = RemoveLevelObject("vegetation", 1312.4, 1150.2, 31.7, {mesh = "objects/natural/vegetation/trees/fallen_trees/fallen_tree_a.cgf", persist = false})
-- a woodcutter fells the tree they look at (the client script sends GetLookTarget's mesh and centre as "chop")
function OnClientEvent(pid, name, payload)
if name ~= "chop" then return end
local mesh, x, y, z = payload:match("^(%S+) (%S+) (%S+) (%S+)$")
if mesh and mesh:find("^objects/natural/vegetation/trees/normal_trees/") then
RemoveLevelObject("vegetation", tonumber(x), tonumber(y), tonumber(z), {mesh = mesh, persist = false})
end
end

RestoreLevelObject · GetLevelRemovals · the The server’s map group of the index