diff --git a/server/main.lua b/server/main.lua index f9679946a..12b80190b 100644 --- a/server/main.lua +++ b/server/main.lua @@ -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)