Skip to content

Commit

Permalink
refacto code to avoid bug when multiple client are carrying at same time
Browse files Browse the repository at this point in the history
  • Loading branch information
daiguel committed Dec 5, 2022
1 parent 40d12eb commit 83e2e87
Showing 1 changed file with 11 additions and 6 deletions.
17 changes: 11 additions & 6 deletions server/main.lua
Original file line number Diff line number Diff line change
Expand Up @@ -130,14 +130,19 @@ lib.callback.register('hunterXhunter:canCarry', function(source, animalNetID)
end
end
table.insert(animalsCarriedNetIDs, animalNetID)
local index= #animalsCarriedNetIDs
print(index)
print(json.encode(animalsCarriedNetIDs, {indent=true}))

SetTimeout(2, function()
table.remove(animalsCarriedNetIDs, index)
print(json.encode(animalsCarriedNetIDs, {indent=true}))
local index = nil
for k, v in pairs(animalsCarriedNetIDs) do
if v == animalNetID then
index = k
end
end
if index ~= nil then
table.remove(animalsCarriedNetIDs, index)
end
end)
print("tototo finished")

return true
end)

Expand Down

0 comments on commit 83e2e87

Please sign in to comment.