Installation ​
Requirements ​
- FiveM Legacy: a recent server artifact (Lua 5.4). The server side checks OneSync entities (
GetAllPeds,GetAllVehicles,GetAllObjects), so server shapes need OneSync. Client shapes work without it. - FiveM for GTAV Enhanced: nothing. The colshape natives are built in. np_colshape can stay in
server.cfg; it goes idle.
There is no database, no NUI and nothing to build.
Optional integrations ​
| Kind | Resources | What it adds |
|---|---|---|
| Staff | np_admin | The np_colshape.debug permission node for /colshapes, live settings and the audit log. See Debug & np_admin |
Without np_admin, /colshapes is allowed for the console, identifiers in the convar np_admin_fallback and ESX groups
in np_admin_fallback_groups (default admin,superadmin). No ACE is used.
Steps ​
- Put the resource in
resources/asnp_colshape. The shim calls its exports by that name. - Add it to
server.cfgbefore the resources that use colshapes:cfgensure np_admin # optional ensure np_colshape # np_fuel, np_banking, np_darts … and every other resource that uses colshapes, after it - In each resource that uses colshapes, copy
lib/colshape.luabyte-identical tobridge/np_colshape.luaand load it as a shared script before your own code:luashared_scripts { 'bridge/np_colshape.lua', -- your files } - Open
shared/config.luaif you want to tune it. The defaults are a working setup. See Configuration.
Not a dependency ​
Do not add dependencies { 'np_colshape' } and do not include @np_colshape/lib/colshape.lua:
- On Enhanced the resource is not needed at all.
- On Legacy without np_colshape, every
Create*returns-1and the shim prints one warning (np_colshape is not started, colshapes are unavailable).npColshape.available()isfalse, so your resource can keep its own fallback. See Adopting it in a resource.
The shim never throws. A native or export that fails is logged once per name and returns the same values as an
invalid id (-1, false, zeros).
Restarts ​
On Legacy every shape lives in np_colshape. When it stops, every shape on that side is gone and ids start at 1 again.
Create your shapes in npColshape.onReady: it runs at once when colshapes are available, and again
after every start of np_colshape (np_colshape:ready). On Enhanced it runs once.
npColshape.onReady(function()
stash = npColshape.create({
type = 'sphere', coords = vector3(441.0, -982.0, 30.7), radius = 2.0,
entityTypes = 'players', enter = function(ped) end,
})
end)
Check it works ​
- Run
colshapesin the server console. It prints the server stats (shapes, entities inside, grid cells, loop times, enters, exits, errors) and the first 50 server shapes. - As a player allowed
np_colshape.debug, run/colshapes. Client shapes within 150 m are drawn as green outlines, with a list of the nearest ones./colshapes serveradds the server shapes near you in blue. - On Enhanced the server and client consoles show once:
GTAV Enhanced colshape natives found: np_colshape stays idle, its exports forward to the natives.