Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: make calling createSessionId for the same entity return the same id #587

Merged
merged 2 commits into from
Sep 28, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions server/main.lua
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,14 @@ local vehicleClassesPromise
local currentSessionId = 0

---Sets a unique sessionId statebag on the entity.
---If the entity already has a sessionId, this will return it rather than overwrite.
---@param entity number
---@return integer sessionId
local function createSessionId(entity)
local existingSessionId = Entity(entity).state.sessionId
if existingSessionId then
return existingSessionId
end
currentSessionId += 1
local sessionId = currentSessionId
Entity(entity).state:set('sessionId', sessionId, true)
Expand Down