Commit Graph

59 Commits

Author SHA1 Message Date
_Not_ 5d14389f8d Merge pull request #1831 from seltonmt012/fix/points-loop-guard
fix(esx_lib/points): keep the points loop alive when a callback errors
2026-08-14 19:45:18 -05:00
_Not_ 569ca0111e Merge pull request #1837 from seltonmt012/fix/esx-lib-helpers
fix(esx_lib): correct the shared table and string helpers
2026-08-14 19:42:19 -05:00
_Not_ 41639c5323 Merge pull request #1845 from seltonmt012/fix/points-loop-once
fix(esx_lib/points): start the points loop only once
2026-08-14 19:37:02 -05:00
_Not_ b9c317c0e5 Merge pull request #1846 from seltonmt012/fix/vehicle-secondary-colour
fix(esx_lib/game): keep the secondary colour when the primary is custom
2026-08-14 19:36:09 -05:00
_Not_ 527a99c851 Merge pull request #1851 from seltonmt012/fix/esx-lib-uint-and-interactions
fix(esx_lib): make the uint check work and remove an unread table
2026-08-07 22:15:05 -05:00
_Not_ cedac84504 Merge pull request #1811 from ASTROWwwW/feat/edition-detection
feat(esx_lib): add isEnhanced game edition detection
2026-08-04 18:26:44 -05:00
_Not_ 85936f0c4d Merge pull request #1803 from rwixy/medal-lib
feat: integrate Medal.tv globally
2026-08-04 18:21:33 -05:00
Selt a890abd110 fix(esx_lib): make table.dump work and drop the shadowed contains
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.
2026-07-30 01:45:05 +02:00
Selt bac379118d fix(esx_lib): match uint against integer and drop the unread interaction list
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.
2026-07-28 00:53:00 +02:00
Selt eb58d4674b fix(esx_lib/game): keep the secondary colour when the primary is custom
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.
2026-07-27 23:04:19 +02:00
Selt 443953b24b fix(esx_lib/points): start the points loop only once
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.
2026-07-27 22:50:24 +02:00
Selt 6cbc408102 fix(esx_lib): correct isArray, toPascal and replace helpers
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.
2026-07-27 20:22:11 +02:00
Selt 9a248406b0 fix(esx_lib/points): keep the points loop alive when a callback errors
Every point from every resource is served by one shared thread, and the enter, leave
and inside callbacks are all invoked bare. A Lua error in any one of them terminates
that coroutine, and nothing restarts it - startLoop only runs once, from the spawn
handler in es_extended.

So a single faulty third party resource takes down point detection for the whole
client. Shops, garages and job markers stop reacting, with no hint beyond one stack
trace, until the player reconnects.

inside is the worst of the three because it runs every frame while the player stands
in the point, so it is also dropped from insidePoints once it errors. Otherwise the
guard would turn a dead thread into a console flood at framerate. enter and leave only
fire on a transition, so they stay registered.

Measured in game on artifact 25770, with a healthy point, a point whose enter raises
and a point whose inside raises, all created while standing on them:

  before: the healthy point fired enter, then the broken one raised at points/client.lua
          and after that nothing happened at all - no leave when walking away, and
          points created afterwards never fired enter either, the thread was gone
  after:  both failures are logged against the owning point and resource, all three
          points fired leave when walking away, and points created afterwards worked
          normally. The inside failure printed once rather than every frame.

The runtime already prints the error and its stack, so the added line only names the
point and the resource it came from.
2026-07-27 17:19:40 +02:00
ASTROWwwW 477b71384f fix(esx_lib): load imports from the correct resource name
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.
2026-07-27 00:25:14 +02:00
ASTROWwwW 94002da05b feat(esx_lib): add isEnhanced game edition detection
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.
2026-07-23 20:51:21 +02:00
Ihsan e7788b2bb4 feat: integrate Medal.tv globally 2026-07-18 14:42:02 +05:30
ASTROWwwW a33913aa41 fix(esx_lib): stop the table module from overwriting the stdlib 2026-07-16 14:51:53 +02:00
_Not_ 48e19810ce Merge remote-tracking branch 'Astro/feat/xlib-waitfor' into 1.14.0 2026-07-15 23:51:13 -05:00
_Not_ 65961a4740 Merge remote-tracking branch 'Astro/feat/esx-lib-pubsub' into 1.14.0 2026-07-15 23:49:28 -05:00
_Not_ 2a303f4e41 Merge remote-tracking branch 'Astro/refactor/move-modules-to-lib' into 1.14.0 2026-07-15 23:48:51 -05:00
_Not_ 51ada6d4f5 Merge remote-tracking branch 'Snail/esx_lib' into 1.14.0 2026-07-15 23:44:49 -05:00
_Not_ 72c13cd08f Merge remote-tracking branch 'Zuntie/esx_lib' into 1.14.0 2026-07-15 23:42:23 -05:00
Astrxw 40139a1a4a Update shared.lua 2026-07-15 17:20:18 +02:00
ASTROWwwW cf61bbd0c3 feat(esx_lib): add xLib.waitFor 2026-07-15 16:23:01 +02:00
ASTROWwwW 2d1facf59d feat(esx_lib): add a pub/sub multicast module
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.
2026-06-25 02:16:43 +02:00
ASTROWwwW 409c2ccc63 refactor(esx_lib): move the player-state cache into the lib
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.
2026-06-24 18:39:07 +02:00
Astrxw 6acaedde1f refactor(esx_lib/game): preserve original networked guard in spawnVehicle move 2026-06-17 15:45:53 +02:00
ASTROWwwW 88a883973a chore(esx_lib/callback): gate callback ownership logs behind xLib:debug 2026-06-16 21:03:41 +02:00
ASTROWwwW c32138eedd feat(esx_lib/onesync): move onesync query helpers to xLib
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.
2026-06-16 21:03:41 +02:00
ASTROWwwW 700b7a646b feat(esx_lib/game): move game spawn/pool/closest/area and vehicle properties to xLib
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)
2026-06-16 21:03:41 +02:00
ASTROWwwW 3fd3bf7877 feat(esx_lib/interactions): move interactions to xLib 2026-06-16 21:03:41 +02:00
ASTROWwwW ca278be1da feat(esx_lib/points): move points and Point class to xLib
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
2026-06-16 21:03:41 +02:00
ASTROWwwW 6a72181992 feat(esx_lib/scaleform): move scaleform helpers to xLib 2026-06-16 21:03:41 +02:00
ASTROWwwW f4af0d90bd feat(esx_lib/streaming): move streaming request helpers to xLib 2026-06-16 21:03:41 +02:00
SNAILX d3868429ed Moved esx.table from the core to esx_lib 2026-06-15 02:08:30 +01:00
Kremu 638a60ce7b Merge branch 'esx_lib' into esx_lib 2026-01-14 16:24:01 +01:00
Arctos. cae0f546bd Merge branch 'esx_lib' into Move-refactor-raycast-functions-esx-lib 2025-11-13 00:04:37 +01:00
Arctos. 26d57c5d85 Merge pull request #1759 from SNAILX808/Move-refactor-entity-functions-esx-lib
(Move/refactor) entity functions esx lib
2025-11-12 14:37:10 +01:00
SNAILX 9b9b4b3fa4 Move-refactor-entity-functions-esx_lib 2025-11-11 05:52:38 +01:00
SNAILX 109a5c6038 small fixes 2025-11-11 03:31:19 +01:00
SNAILX d908418637 Move-refactor-raycast-functions-esx_lib 2025-11-11 00:57:39 +01:00
Zuntie 1a27c365b6 fix(esx_lib): changed runtime texture names; tiny performance optimizaion. Working, Finished. 2025-11-09 17:44:52 +01:00
Zuntie edcfa009fb feat(esx_lib): DUI development guidelines compliant 2025-11-09 02:49:24 +01:00
Zuntie 3c20728860 feat(esx_lib): initial DUI addition 2025-11-09 02:44:10 +01:00
zykem#0643 7ebc92ec0f refactor(lib/keybind) Change args structure 2025-10-30 19:14:08 +01:00
SNAILX fa52482720 Fix keybind command order for proper validation 2025-10-29 01:54:53 +01:00
SNAILX ae19c7cd25 Refactor keybind registration to use xLib.addKeybind 2025-10-28 18:29:36 +01:00
Stane034 5e1445d94a hfix 2025-10-26 21:47:16 +01:00
Stane034 7772bc5277 hotfixes 2025-10-26 21:45:29 +01:00
zykem#0643 f4b951a173 feat(lib/timeout) Type validation for cb function 2025-10-26 15:37:11 +01:00