Skip to content

Commit

Permalink
Fix Armor not saving on player exit
Browse files Browse the repository at this point in the history
This PR introduces a feature to save a player's armor when exiting the server. This ensures player stats are preserved and improves the overall gameplay experience.

In addition, I have also submitted a related PR on the qb-ambulancejob repository with complementary changes. Please approve the ambulancejob PR after merging this one to maintain compatibility and prevent potential breakdowns or inconsistencies.
  • Loading branch information
RojinxChhetri authored Dec 25, 2024
1 parent 12eefc3 commit cb0fb59
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions server/events.lua
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,12 @@ end)

AddEventHandler('playerDropped', function(reason)
local src = source
local ped = GetPlayerPed(src)
local armor = GetPedArmour(ped)
if not QBCore.Players[src] then return end
local Player = QBCore.Players[src]
TriggerEvent('qb-log:server:CreateLog', 'joinleave', 'Dropped', 'red', '**' .. GetPlayerName(src) .. '** (' .. Player.PlayerData.license .. ') left..' .. '\n **Reason:** ' .. reason)
TriggerEvent('QBCore:Server:PlayerDropped', Player)
TriggerEvent('qb-log:server:CreateLog', 'joinleave', 'Dropped', 'red', '**' .. GetPlayerName(src) .. '** (' .. Player.PlayerData.license .. ') left..' ..'\n **Reason:** ' .. reason)
Player.Functions.SetMetaData('armor', armor)
Player.Functions.Save()
QBCore.Player_Buckets[Player.PlayerData.license] = nil
QBCore.Players[src] = nil
Expand Down

0 comments on commit cb0fb59

Please sign in to comment.