table.dump called its own table argument as a function, so it threw
"attempt to call a table value" for every table that had at least one
entry. An empty table returned "{ } " and a non-table returned tostring,
which is why it looks fine until you actually dump something.
table.contains was defined twice in the same file. Lua keeps the second
one, so the annotated version further up was unreachable. Removed the
unreachable one; behaviour is unchanged.
math.type only returns 'integer', 'float' or nil, so the 'uint' branch
comparing against 'int' never matched and threw whenever throw_error was set.
pressedInteractions was written on every interaction and read nowhere, so it
grew for the whole session and kept removed interactions reachable.
setVehicleProperties passes props.color1 straight into SetVehicleColours when the
secondary colour comes from the palette. If the primary is a custom RGB colour,
the getter stored it as a table, so a table reaches a native that wants a paint
index and the call does nothing. The secondary colour is silently lost.
Any car sprayed with a custom primary and a palette secondary comes back from
storage with the wrong secondary colour.
Fall back to the vehicle's current primary when props.color1 is not a paint index.
The custom primary was already applied by the block above, so nothing is lost.
Measured in game on artifact 25770, reading properties off a car with a custom red
primary and palette secondary 12, then applying them to a second car:
before: color2 came back 0
after: color2 came back 12
The custom primary survives either way, mods and wheels are untouched.
startLoop is called from the esx:playerLoaded handler in es_extended, which fires
again on every character switch, and the loop it creates runs `while true` with no
exit. Each relog therefore leaves another points thread running: they all scan the
same table, fire the same enter and leave callbacks, and none of them ever stop.
A guard makes a second call a no-op. The loop is meant to live for the resource
lifetime, so starting it twice is never right.
Measured in game on artifact 25770, counting scans over four seconds:
before: 1.0 -> 2.0 -> 3.0 loops across two relogs
after: 1.0 -> 1.0 -> 1.0
Points keep working, the surviving loop is unaffected.
Note this touches the same file as #1831, which guards the callbacks inside the
loop. The two changes are in different places and independent of each other.
Three small logic bugs in the shared helpers, each verified with a standalone Lua
run.
isArray returned true for sparse tables like {[1]=1,[3]=3}: the in-loop
`count > maxIndex` check can never fire (with positive integer keys count is always
<= maxIndex), so it was dead code. Dropped it and return `count == maxIndex`, which
is false for gaps and still true for a dense sequence or an empty table.
toPascal lowercased the letters after an underscore: `[%w_]*` swallowed the
underscore and the next word into the part that gets lowercased, so "hello_world"
became "Helloworld". Excluding the underscore from that class leaves each word to be
capitalised, then the trailing gsub removes the underscores -> "HelloWorld".
replace escaped the pattern but not the replacement, so a "%" in the replacement
raised "invalid use of '%' in replacement string" and "%1" style sequences expanded
captures. Escape "%" in a string replacement; a function or table replacement is
left untouched.
xLib.name was "xLib", which is not a resource, so the import metatable fed it to LoadResourceFile and resolved nothing. It failed silently on Legacy and hard-errored on Enhanced (Resource 'xLib' not found). Point it at the real resource name.
xLib.isEnhanced() returns whether the game runs GTA V Enhanced (server: gamename convar, client: IsGameEnhancedVersion native). es_extended reads it once and requires OneSync Infinity on Legacy only, since Enhanced runs OneSync natively.
Adds xLib.pubsub for server-driven topic multicast: a producer resource
subscribes players to a topic server-side and publishes data that is pushed
only to the subscribed players. Clients listen with xLib.pubsub.on and never
subscribe or publish themselves.
The subscription registry is a single shared instance in the esx_lib server VM,
reached cross-resource through exports; the client side is a per-VM listener
over one net event. Subscriptions are cleaned up on playerDropped, so a reused
serverId never inherits them, and on the owning resource stopping.
Also adds xLib.triggerClientEvent, which packs the payload once when sending to
many players; publish uses it so a broadcast to N subscribers serialises once.
Adds a generic xLib.cache (ped, vehicle, seat, weapon, coords) modelled on
ox_lib cache and framework agnostic, and rewires es_extended to source ped and
weapon from it which removes the per-frame ped poll. The vehicle enter/exit
state machine and every esx: event are kept unchanged through a thin glue.
Moved getPlayersInArea / getClosestPlayer / getPedsInArea / getObjectsInArea /
getVehiclesInArea / getClosestPed / getClosestObject / getClosestVehicle to
xLib; es_extended re-exposes them through server compat shims.
Flagged: getNearbyPlayers iterates ESX.Players (es_extended server state),
which is not portable across the lib boundary - the lib relies on that global
being present at call time.
Integrated fix during the move:
- spawnVehicle uses the computed isNetworked for the network-id/migrate guard,
fixing the original that branched on the raw networked argument
modSmokeEnabled preserved as-is in get/setVehicleProperties (flagged: the set
path toggles mod 20 without applying a smoke color, matching legacy behavior).
Non-portable substitution documented:
- ESX.PlayerData.ped -> PlayerPedId() (ESX.PlayerData is not available in the lib VM)
Integrated fixes during the move:
- monotonic handle counter (handleCount) instead of count+1; no handle
collision after a point is removed
- unified single proximity loop: per-frame inside() plus a 500ms enter/leave
scan, adaptive Wait(next(insidePoints) and 0 or 500), replacing the previous
two separate loops
- emptiness detected via next() instead of # on a sparse-keyed table
Non-portable substitutions documented:
- ESX.PlayerData.ped -> PlayerPedId() (ESX.PlayerData is not available in the
lib VM)
- GetGameTimer() used to gate the 500ms scan within the single loop