Skip to content

Commit

Permalink
fix(bridge/nd): updating player data (#1633)
Browse files Browse the repository at this point in the history
  • Loading branch information
Andyyy7666 committed Feb 29, 2024
1 parent 91f74cb commit 74e4fa1
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 7 deletions.
9 changes: 3 additions & 6 deletions modules/bridge/nd/client.lua
Original file line number Diff line number Diff line change
Expand Up @@ -17,18 +17,15 @@ end
SetTimeout(500, function()
local player = NDCore.getPlayer()
if not player then return end
local groups = reorderGroups(player.groups)
OnPlayerData("groups", groups)
OnPlayerData("groups", reorderGroups(player.groups))
end)

RegisterNetEvent("ND:characterLoaded", function(character)
local groups = reorderGroups(character.groups)
OnPlayerData("groups", groups)
OnPlayerData("groups", reorderGroups(character.groups))
end)

RegisterNetEvent("ND:updateCharacter", function(character)
PlayerData.dead = character.metadata.dead
OnPlayerData("dead", PlayerData.dead)
OnPlayerData("groups", reorderGroups(character.groups))
end)

---@diagnostic disable-next-line: duplicate-set-field
Expand Down
7 changes: 6 additions & 1 deletion modules/bridge/nd/server.lua
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,12 @@ AddEventHandler("ND:moneyChange", function(src, account, amount, changeType, rea
Inventory.SetItem(src, "money", changeType == "set" and amount or changeType == "remove" and item - amount or changeType == "add" and item + amount)
end)

AddEventHandler("ND:updateCharacter", function(character)
local inventory = Inventory(character.source)
if not inventory then return end
inventory.player.groups = reorderGroups(character.groups)
end)

---@diagnostic disable-next-line: duplicate-set-field
function server.syncInventory(inv)
local accounts = Inventory.GetAccountItemCounts(inv)
Expand Down Expand Up @@ -113,4 +119,3 @@ end
function server.getOwnedVehicleId(entityId)
return NDCore.getVehicle(entityId)?.id
end

0 comments on commit 74e4fa1

Please sign in to comment.