Skip to content

Conversation

@MaitreAntho
Copy link

What

  • Fix missing placeholder in deferrals.update so the player identifier is displayed in the deferral UI.
  • Ensure server callbacks (esx:getPlayerData, esx:getOtherPlayerData, esx:getPlayerNames) always invoke cb instead of early-returning, preventing client awaits from hanging.
  • Harden job counters: always initialize and update Core.JobsPlayerCount safely on load/setJob/drop; guard GlobalState.playerCount against nil and underflow.
  • Avoid a potential crash in esx:spawnVehicle by not accessing vehData.coords.w when vehData.coords is nil.

Why

  • Better connection UX, no silent client hangs, stable counters, reliable vehicle spawns.

How

  • Add %s placeholder to deferral message.
  • Return cb(nil) when xPlayer is missing; default to cb(players or {}).
  • Introduce ensureJobCounter(jobName) and use it in playerLoaded, setJob, onPlayerDropped.
  • Clamp GlobalState.playerCount and compute spawnCoords/heading safely.

Backwards compatibility

  • No API changes. Purely defensive fixes.

Tests

  1. Connect with “active” identifier → deferral shows identifier.
  2. Call callbacks while target disconnects → no hang.
  3. Rapid job change + disconnect → counters consistent, no errors.
  4. Spawn vehicle with/without coords → no crash; heading applied when provided.

Kenshiin13 and others added 28 commits August 24, 2025 17:20
Apparently, passing leading nil values via an export breaks it entirely.
…ment-isValid-on-register-command

add a new argument on the register command feature
feat(esx_menu_default) Redesign of the menu.
fix(esx_menu_default): remove debug print
…g nil - Show player identifier in deferral update message. - Ensure server callbacks always invoke cb (avoid client awaits hanging). - Guard JobsPlayerCount and GlobalState.playerCount against nil/underflow. - Prevent nil access to coords.w in esx:spawnVehicle when coords is missing.

## What
- Fix missing placeholder in `deferrals.update` so the player identifier is displayed in the deferral UI.
- Ensure server callbacks (`esx:getPlayerData`, `esx:getOtherPlayerData`, `esx:getPlayerNames`) always invoke `cb` instead of early-returning, preventing client awaits from hanging.
- Harden job counters: always initialize and update `Core.JobsPlayerCount` safely on load/setJob/drop; guard `GlobalState.playerCount` against nil and underflow.
- Avoid a potential crash in `esx:spawnVehicle` by not accessing `vehData.coords.w` when `vehData.coords` is nil.

## Why
- Better UX during connection (deferral message shows real identifier).
- More robust callbacks (no silent hangs when a player object is unavailable).
- Stable job/player counters during fast connect/disconnect and job switches.
- Reliable vehicle spawns whether or not a heading/coords is provided.

## How
- Add `%s` placeholder to the deferral message.
- Return `cb(nil)` when `xPlayer` is missing; default to `cb(players or {})` for names.
- Introduce `ensureJobCounter(jobName)` and use it in `playerLoaded`, `setJob`, and `onPlayerDropped`. Clamp `GlobalState.playerCount` with a safe default and `math.max`.
- In `esx:spawnVehicle`, compute `spawnCoords` and `heading` with safe fallbacks.

## Backwards compatibility
- No API changes. Purely defensive fixes; behavior is backward-compatible.

## Tests
1. **Deferral formatting**: connect with an account already “active” → deferral UI displays the identifier.
2. **Callbacks**: call `esx:getPlayerData`/`esx:getOtherPlayerData` while the target disconnects; clients receive a response (no hang).
3. **Counters**: connect → change job → disconnect quickly; observe no errors and coherent `Core.JobsPlayerCount` and `GlobalState["playerCount"]` (never negative).
4. **Vehicle spawn**: call `esx:spawnVehicle` with and without `vehData.coords`. No crash; if `coords` includes `w`, heading is applied.

## Notes
- Minimal surface change, easy to review, focused on stability and DX quality.
@N0tNvll N0tNvll self-requested a review October 1, 2025 12:51
@N0tNvll N0tNvll added the awaiting review Awaiting review from PR Manager label Oct 1, 2025
- Restored original implementation of esx:spawnVehicle callback to keep this PR focused on job counter improvements. 
  Vehicle spawn fallback handling will be addressed in a separate pull request.
- Moved ensureJobCounter to the top of server/main.lua to ensure it is defined before being used in player/job related events.
@CLAassistant
Copy link

CLAassistant commented Nov 16, 2025

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you all sign our Contributor License Agreement before we can accept your contribution.
1 out of 4 committers have signed the CLA.

✅ Kenshiin13
❌ Kr3mu
❌ github-actions[bot]
❌ MaitreAntho
You have signed the CLA already but the status is still pending? Let us recheck it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

awaiting review Awaiting review from PR Manager

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants