mirror of
https://github.com/esx-framework/esx_core.git
synced 2026-08-29 06:01:25 +00:00
feat(es_extended): dd isNew state to Player stateBag on playerLoaded
Stores the isNew flag in the player's stateBag on server. On the client, you can get it like this: ``` print(Player(source).state.isNew) ``` - [x] My commit messages and PR title follow the [Conventional Commits](https://www.conventionalcommits.org/en/v1.0.0/) standard. - [x] My changes have been tested locally and function as expected. - [x] My PR does not introduce any breaking changes. - [x] I have provided a clear explanation of what my PR does, including the reasoning behind the changes and any relevant context.
This commit is contained in:
@@ -331,12 +331,13 @@ AddEventHandler("playerDropped", function(reason)
|
||||
end
|
||||
end)
|
||||
|
||||
AddEventHandler("esx:playerLoaded", function(_, xPlayer)
|
||||
AddEventHandler("esx:playerLoaded", function(_, xPlayer, isNew)
|
||||
local job = xPlayer.getJob().name
|
||||
local jobKey = ("%s:count"):format(job)
|
||||
|
||||
Core.JobsPlayerCount[job] = (Core.JobsPlayerCount[job] or 0) + 1
|
||||
GlobalState[jobKey] = Core.JobsPlayerCount[job]
|
||||
Player(xPlayer.source).state:set('isNew', isNew, true)
|
||||
end)
|
||||
|
||||
AddEventHandler("esx:setJob", function(_, job, lastJob)
|
||||
|
||||
Reference in New Issue
Block a user