Skip to content

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 ​

  1. Put the resource in resources/ as np_colshape. The shim calls its exports by that name.
  2. Add it to server.cfg before the resources that use colshapes:
    cfg
    ensure np_admin        # optional
    ensure np_colshape
    # np_fuel, np_banking, np_darts … and every other resource that uses colshapes, after it
  3. In each resource that uses colshapes, copy lib/colshape.lua byte-identical to bridge/np_colshape.lua and load it as a shared script before your own code:
    lua
    shared_scripts {
      'bridge/np_colshape.lua',
      -- your files
    }
  4. Open shared/config.lua if 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 -1 and the shim prints one warning (np_colshape is not started, colshapes are unavailable). npColshape.available() is false, 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.

lua
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 ​

  1. Run colshapes in the server console. It prints the server stats (shapes, entities inside, grid cells, loop times, enters, exits, errors) and the first 50 server shapes.
  2. 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 server adds the server shapes near you in blue.
  3. On Enhanced the server and client consoles show once: GTAV Enhanced colshape natives found: np_colshape stays idle, its exports forward to the natives.