[ESX] Weaponshop, weapons removed after disconnect

I have been trying to figure this out for a while now…
A player is able to purchase a weapon OK from weaponshop.
The DB is updated correctly and it shows in their loadout.
When they die esx_ambulancejob functions correctly and removes it.

The problem arises when they disconnect from the server and rejoin.
They join without any weapons but their loadout in the DB is correct…thus what happens is they can’t purchase a weapon because they already own it. The only way to fix this is to die and let esx_ambulancejob remove the phantom weapon.

So far I have a hunch that spawnmanger is the problem, as weapons are correctly added (esx_weaponshop) and removed (esx_ambulancejob).

I came across an interesting piece of code in esx_ambulancejob

if Config.RemoveWeaponsAfterRPDeath then
for i=1, #xPlayer.loadout, 1 do
xPlayer.removeWeapon(xPlayer.loadout[i].name)
end
else – save weapons & restore em’ since spawnmanager removes them
for i=1, #xPlayer.loadout, 1 do
table.insert(playerLoadout, xPlayer.loadout[i])
end

This “workaround” for spawnmanger makes me think this is happening as spawnmanger handles the player when connecting to the server.

Anyone have a similar problem or solution?

Did a /chardel and everything works perfectly now, found out that if you go to the clothing store (using raid_clothes) this happens…

For anyone who stumbles upon this, just need to TriggerEvent(‘esx:restoreLoadout’) after you load the PED model.

3 Likes

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.