Skip to content

feat(player): include previous job and gang data in update events#1218

Open
redutzu wants to merge 2 commits intoqbcore-framework:mainfrom
redutzu:pass-last-data
Open

feat(player): include previous job and gang data in update events#1218
redutzu wants to merge 2 commits intoqbcore-framework:mainfrom
redutzu:pass-last-data

Conversation

@redutzu
Copy link
Copy Markdown

@redutzu redutzu commented Apr 23, 2026

Description

Adds previous state tracking to player job and gang updates by passing lastJob and lastGang to server and client events.

This provides downstream resources with access to both the old and new state, improving flexibility for event-driven logic without requiring additional state tracking.

The change is backward compatible, as existing handlers can ignore the extra argument.

Additionally refactors duty handling by moving SetDuty event triggering into SetJobDuty. Previously, these events were only fired when using ToggleDuty; now they are consistently triggered whenever duty is changed via SetJobDuty.

Applies to:

  • QBCore:Server:OnJobUpdate
  • QBCore:Client:OnJobUpdate
  • Gang update equivalents
  • QBCore:Server:SetDuty
  • QBCore:Client:SetDuty

Comment thread server/player.lua
Comment on lines +275 to +276
TriggerEvent('QBCore:Server:SetDuty', self.PlayerData.source, self.PlayerData.job.onduty)
TriggerClientEvent('QBCore:Client:SetDuty', self.PlayerData.source, self.PlayerData.job.onduty)
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This would be slightly breaking for any resources that listened to OnJobUpdate for duty updates, although I'm not sure how many would do so.

Listening to QBCore:ToggleDuty would've also been fragile.

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