Skip to content

refactor(esx_lib): move streaming/scaleform/points/interactions/game/onesync helpers into the lib#1789

Open
ASTROWwwW wants to merge 9 commits into
esx-framework:esx_libfrom
ASTROWwwW:refactor/move-modules-to-lib
Open

refactor(esx_lib): move streaming/scaleform/points/interactions/game/onesync helpers into the lib#1789
ASTROWwwW wants to merge 9 commits into
esx-framework:esx_libfrom
ASTROWwwW:refactor/move-modules-to-lib

Conversation

@ASTROWwwW

Copy link
Copy Markdown

Description

Moves seven client/server helper modules out of es_extended into the shared lib (esx_lib / xLib), and re-exposes every moved API through compat shims so existing resources keep working unchanged. Continues the lib refactor already merged on this branch (raycast, entity).

Modules moved (one commit each, conventional commits):

  1. streaming — request helpers (model, texture dict, ptfx, anim set/dict, weapon asset)
  2. scaleform — freemode message / breaking news / popup warning / traffic movie + utils
  3. points + Point class
  4. interactions
  5. game — spawn / pool / closest / area helpers + vehicle properties get/set
  6. onesync — area/closest query helpers (server)
  7. callback — gate ownership logs behind a debug convar

Motivation

Centralize reusable runtime helpers in the lib so they are available to every resource without depending on es_extended internals, cut duplication, and keep es_extended focused on framework logic. Aligns with the ongoing effort to consolidate on the lib.


Implementation Details

Each module follows the same pattern: a new file under esx_lib/imports/<module>/, the old es_extended source removed (for game, the inline ESX.Game.* definitions are removed from client/functions.lua), and a compat shim added so the existing ESX.* API still resolves.

Back-compat (no consumer-facing breakage):

  • Client compat.lua re-maps ESX.Streaming.*, ESX.Scaleform.*, ESX.Game.* (spawn/pool/closest/area + vehicle properties), ESX.CreatePointInternal / ESX.RemovePointInternal / ESX.HidePointInternal / StartPointsLoop / ESX.Point, and ESX.RegisterInteraction / ESX.RemoveInteraction / ESX.GetInteractKey to their xLib.* equivalents.
  • Server compat.lua re-maps ESX.OneSync.GetPlayersInArea / GetClosestPlayer / GetPedsInArea / GetObjectsInArea / GetVehiclesInArea / GetClosestPed / GetClosestObject / GetClosestVehicle.
  • ESX.OneSync.Spawn* and ESX.Game.Utils.DrawText3D intentionally stay in es_extended (not moved).
  • fxmanifest.lua no longer loads the removed client modules; imports.lua no longer loads the Point class import. Compat files load after the lib import, so the shims resolve at load time and all internal call-sites remain covered.

Fixes integrated during the move:

  • points: monotonic handle counter (no handle collision after a point is removed); unified single proximity loop — per-frame inside() plus a 500ms enter/leave scan via Wait(next(insidePoints) and 0 or 500), replacing the previous two separate loops; emptiness detected via next() instead of # on a sparse-keyed table.
  • game: spawnVehicle uses the computed isNetworked for the network-id/migrate guard, fixing the original that branched on the raw networked argument.

Flagged (kept as-is / out of scope):

  • modSmokeEnabled is preserved as-is in get/setVehicleProperties (legacy behavior kept, not changed).
  • onesync getNearbyPlayers still reads ESX.Players (es_extended server state); it relies on that global being present at call time — portability across the lib boundary is flagged for review.
  • A pre-existing validateModel issue in the verify path was noticed but left untouched here (out of scope for this PR).

Coordination: these points / interactions / onesync changes supersede the corresponding fixes that were removed from #1787 (agreed). #1787 now carries only the security/robustness fixes; the module moves and their integrated fixes live here.


Usage Example

-- Back-compat: existing ESX.* calls keep working unchanged via shims
ESX.Streaming.RequestModel(`adder`)
local veh = ESX.Game.SpawnVehicle(`adder`, coords, heading)

-- New: the same helpers are available directly on the lib
xLib.streaming.requestModel(`adder`)
xLib.points.create(coords, distance, hidden, onEnter, onLeave, onInside)

PR Checklist

  • My commit messages and PR title follow the Conventional Commits standard.
  • My changes have been tested locally and function as expected. (xtest, client + server runtime)
  • My PR does not introduce any breaking changes. (compat shims for every moved API)
  • I have provided a clear explanation of what my PR does, including the reasoning behind the changes and any relevant context.

@CLAassistant

CLAassistant commented Jun 16, 2026

Copy link
Copy Markdown

CLA assistant check
All committers have signed the CLA.

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
…perties 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)
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.
ASTROWwwW and others added 2 commits June 17, 2026 15:45
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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants