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 ​
- Cylinder and cuboid Z.
zis the centre. A cylinder coversz - height / 2toz + height / 2, and a cuboid is centred on all three axes. The documentation says "center Z coordinate" and "total height". - Inside means the entity's
GetEntityCoordsposition is inside, not its bounding box. The boundary counts as inside. - Rectangle heading is in radians and turns counter-clockwise seen from above, like GTA headings.
widthruns along the rotated X axis,depthalong the rotated Y axis. Circles and rectangles have no Z limit. - 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 ​
-
Entities already inside a new shape get
onColshapeEnteron the next pass. -
No events on delete.
DeleteColshapeand the owner stopping are silent. Clean up your own state when you delete a shape (npColshape.deletedrops the helper's tracking for you). -
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.
-
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 ​
- Ownership: shapes die with the resource that created them (
GetInvokingResource()). Any resource may change or delete any shape. - 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 ​
- Client typing:
- peds are
PlayerorPed; - vehicles come from
GetVehicleType(falling back toIsThisModelA*), cached per model; - every
CObjectisObject, so doors and glass panes are not told apart; - every
CPickupisPickup; PickupPlacementnever occurs.
- peds are
- Server typing is
GetNetTypeFromEntity. If that returns something out of range, the pool decides: a player ped isPlayer, other pedsPed, vehiclesAutomobile, objectsObject. 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 ​
- Client dimension: none. A client only streams its own bucket, so client shapes have no dimension and
SetColshapeDimension/GetColshapeDimensionare server only. - Server dimension is the routing bucket,
0by default. An entity counts only for shapes of its own bucket.
Timing ​
-
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). -
Each pass yields a frame after
sliceSize(200) entities. On a busy server a full pass over every OneSync entity can take several frames. -
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 wantsPed, only the player peds are listed (GetPlayers/GetActivePlayers+GetPlayerPed). -
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 thanadaptiveMaxSpeed(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,
GetEntityCoordsof 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,filterandonReadyfunctions and prints them. Afilterthat errors counts asfalse.
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:
GetNetTypeFromEntityon server entities, especially that player peds reportPlayer(11).GetGamePool('CPickup')returning entity handles thatGetEntityCoords/DoesEntityExistaccept.GetVehicleTypeon the client.- Multiple return values and
vector2lists across exports (msgpack). - That the Enhanced runtime fires
onColshapeEnter/onColshapeExitas local events with(entity, shapeId), and that the feature probeDoesColshapeExist(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
pcallaroundGetEntityCoordsrelies on either that or the zero vector). - That
GetPlayers+GetPlayerPed(server) andGetActivePlayers+GetPlayerPed(client) give the same player peds as the ped pool.