World models ​
server
Hide a map object, or swap it for another model, around a point. The server registers the entry. Each client applies it while the player is near.
lua
-- server
local id = exports.np_prophandler:hideWorldModel({
id = 'np_drugs:bench',
coords = vector3(1380.4, 3600.1, 34.9),
radius = 2.0,
model = 'prop_bench_01a',
})
exports.np_prophandler:swapWorldModel({
id = 'np_drugs:sign',
coords = vector3(1395.0, 3612.7, 34.9),
radius = 3.0,
from = 'prop_sign_road_01a',
to = 'prop_sign_road_02a',
})
exports.np_prophandler:removeWorldModel(id)
Both return the id, or false, reason.
On the client ​
- A hide uses
CreateModelHide(CreateModelHideExcludingScriptObjectswithkeepScriptObjects), a swapCreateModelSwap. - They are applied within
radius + world.applyDistance(150 m) and removed beyond that plusworld.margin(20 m) withRemoveModelHide/RemoveModelSwap. - They follow availability:
enabledandroutingBucket. World entries have no job, gang or hour conditions.
Keeping script objects ​
CreateModelHide hides every object of that model in the area, script objects included. With
keepScriptObjects = true on hideWorldModel, only the map's objects are hidden: objects created by scripts,
np_prophandler's own props of the same model among them, stay. Use it to replace map props with handler props of the
same model, e.g. a map pool table with a registered one:
lua
-- server
exports.np_prophandler:hideWorldModel({ id = 'np_billiards:map_table', coords = c, radius = 2.0,
model = 'prop_pooltable_02', keepScriptObjects = true })
exports.np_prophandler:registerProp({ id = 'np_billiards:table_1', model = 'prop_pooltable_02', coords = c })
swapWorldModel has no such option ('unknown_field'): no model swap native skips script objects. Hide the map
model with keepScriptObjects and register the replacement as a prop instead.
Fields ​
| Field | Hide | Swap | Notes |
|---|---|---|---|
id |
required | required | Letters, digits and . _ : -, up to 64 characters |
coords |
required | required | Centre of the area |
radius |
required | required | 0.1 to 200 |
model |
required | refused | The map model to hide. Not checked against allowedModels |
from |
refused | required | The map model to replace. Not checked against allowedModels |
to |
refused | required | The new model. Checked against allowedModels when set |
keepScriptObjects |
false |
refused | Hide only map objects, not script objects of the model. See above |
routingBucket |
optional | optional | Only players in this bucket |
enabled |
true |
true |
Ownership ​
- Registering an id you already own replaces the entry. An id owned by another resource returns
false, 'id_in_use'. - Only the owner can remove an entry (
'not_owner'). Entries are removed when the owning resource stops. - At most
server.world.maxEntries(512) entries.