Skip to content
This repository has been archived by the owner on Mar 21, 2022. It is now read-only.

Commit

Permalink
fix(server): clone and wipe the playerlist when restarting the resource
Browse files Browse the repository at this point in the history
Since we're looping through the table, we end up trying to index new values as they are added.
  • Loading branch information
thelindat committed Nov 21, 2021
1 parent 6a7d0ad commit 150ec16
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions server/main.lua
Original file line number Diff line number Diff line change
Expand Up @@ -40,17 +40,19 @@ elseif ESX.GetConfig().Multichar == true then
end

if next(ESX.Players) then
for k, v in pairs(ESX.Players) do
local players = table.clone(ESX.Players)
table.wipe(ESX.Players)
for _, v in pairs(players) do
ESX.Players[GetIdentifier(v.source)] = true
end
else ESX.Players = {} end

local function SetupCharacters(source)
while not FETCH do Citizen.Wait(100) end
local identifier = GetIdentifier(source)
ESX.Players[identifier] = true
ESX.Players[identifier] = true

local slots = MySQL.Sync.fetchScalar("SELECT slots FROM multicharacter_slots WHERE identifier = ?", {
local slots = MySQL.Sync.fetchScalar("SELECT slots FROM multicharacter_slots WHERE identifier = ?", {
identifier
}) or SLOTS
identifier = PREFIX..'%:'..identifier
Expand Down

0 comments on commit 150ec16

Please sign in to comment.