Skip to content

Behaviour & assumptions ​

The Enhanced documentation gives the natives' names, arguments and return values, and little else. This page lists the choices np_colshape makes on Legacy where the documentation is silent. On Enhanced the runtime decides, and it may differ in any of these points. Code that depends on one of them should not assume Enhanced does the same.

Geometry ​

  1. Cylinder and cuboid Z. z is the centre. A cylinder covers z - height / 2 to z + height / 2, and a cuboid is centred on all three axes. The documentation says "center Z coordinate" and "total height".
  2. Inside means the entity's GetEntityCoords position is inside, not its bounding box. The boundary counts as inside.
  3. Rectangle heading is in radians and turns counter-clockwise seen from above, like GTA headings. width runs along the rotated X axis, depth along the rotated Y axis. Circles and rectangles have no Z limit.
  4. Polygon: the even-odd rule, so self-intersecting polygons have holes. A closing point equal to the first one is dropped. At most 256 points (maxPolygonPoints).

Events ​

  1. Entities already inside a new shape get onColshapeEnter on the next pass.

  2. No events on delete. DeleteColshape and the owner stopping are silent. Clean up your own state when you delete a shape (npColshape.delete drops the helper's tracking for you).

  3. Exit happens when the entity:

    • leaves the shape;
    • stops existing or streams out;
    • has its type disabled on the shape;
    • (server) is in another routing bucket than the shape's dimension.

    Within one pass every exit fires before every enter.

  4. Event source: the events are local (TriggerEvent). np_colshape never registers them as net events. Don't do it in your resource either, or clients could fake them.

Ownership and ids ​

  1. Ownership: shapes die with the resource that created them (GetInvokingResource()). Any resource may change or delete any shape.
  2. Ids are per side and per np_colshape run: positive integers starting at 1, never reused while np_colshape runs. After a restart they start at 1 again, so don't store ids across a restart. Use npColshape.onReady.

Typing ​

  1. Client typing:
    • peds are Player or Ped;
    • vehicles come from GetVehicleType (falling back to IsThisModelA*), cached per model;
    • every CObject is Object, so doors and glass panes are not told apart;
    • every CPickup is Pickup;
    • PickupPlacement never occurs.
  2. Server typing is GetNetTypeFromEntity. If that returns something out of range, the pool decides: a player ped is Player, other peds Ped, vehicles Automobile, objects Object. Types are cached per handle while it stays in its pool. A handle that is deleted and taken by a new entity of another type before the next pass of the same pool keeps the old type until it misses a pass. Client handles carry a reuse counter, so this needs a server.

Dimension ​

  1. Client dimension: none. A client only streams its own bucket, so client shapes have no dimension and SetColshapeDimension / GetColshapeDimension are server only.
  2. Server dimension is the routing bucket, 0 by default. An entity counts only for shapes of its own bucket.

Timing ​

  1. Checks run every 100 to 500 ms, not every frame:

    Side Peds and vehicles Objects (and client pickups)
    Client 100 ms 500 ms
    Server 200 ms 500 ms

    A fast vehicle can cross a thin shape between two passes without an event. For a finish line or a toll gate, use a deeper shape or lower client.fastIntervalMs / server.fastIntervalMs (Configuration).

  2. Each pass yields a frame after sliceSize (200) entities. On a busy server a full pass over every OneSync entity can take several frames.

  3. With no shape on a side and nobody inside one, the loops wake once a second (idleIntervalMs) and do nothing. An entity pool is not read at all while no shape on that side wants any of its types, so a server with only 'players' shapes never reads the vehicle or object pools. It doesn't read the ped pool either: while no shape wants Ped, only the player peds are listed (GetPlayers / GetActivePlayers + GetPlayerPed).

  4. With adaptive rechecks on (off by default), a non-player entity far from every shape can enter up to adaptiveMaxDelayMs (2000 ms) late if it moves faster than adaptiveMaxSpeed (60 m/s).

Error handling ​

  • An event handler that errors is caught and logged by np_colshape. It never stops the loop.
  • A native that errors on one entity (on the server, GetEntityCoords of an entity OneSync just deleted) is logged and skips that entity only, not the rest of the slice.
  • The shim never throws. A native or export that fails is printed once per name ([your_resource] np_colshape: <Native> failed: …) and returns the values of an invalid id.
  • The helper catches errors in enter, exit, filter and onReady functions and prints them. A filter that errors counts as false.

Not verified in game ​

np_colshape 1.1.0 was written against the documented natives and checked only with stubs. These need a live test:

  • GetNetTypeFromEntity on server entities, especially that player peds report Player (11).
  • GetGamePool('CPickup') returning entity handles that GetEntityCoords / DoesEntityExist accept.
  • GetVehicleType on the client.
  • Multiple return values and vector2 lists across exports (msgpack).
  • That the Enhanced runtime fires onColshapeEnter / onColshapeExit as local events with (entity, shapeId), and that the feature probe DoesColshapeExist(0) returns a boolean there.
  • The cost of the server loop with many OneSync entities and shapes.
  • That server entity natives throw for a deleted entity (the pcall around GetEntityCoords relies on either that or the zero vector).
  • That GetPlayers + GetPlayerPed (server) and GetActivePlayers + GetPlayerPed (client) give the same player peds as the ped pool.