I am using the redemrp inventory system to attempt to do dead drops when a player is killed so that essentially a locker is created at their last coordinates and then their inventory is transferrred to the locker. Everything is working except when players access the locker there is no inventory inside. Even though the database is populated and has the inventory that was dumped. It shows up in the database and stays there but never shows up in game for players to access. But if someone puts something in the new locker it shows up to other players but never shows up in the database, database continues to hold the dead players inventory only and never updates with stuff that is placed. I don’t know sql well enough to figure out what is wrong. Could use help:
---DEAD DROPS CODE
data = {}
TriggerEvent("redemrp_inventory:getData",function(call)
data = call
end)
RegisterServerEvent("redemrp:playerDeaded")
AddEventHandler("redemrp:playerDeaded", function(ID,deadedcount,coords)--Need to get _player from somewhere
local _source = source
local player = _player
TriggerEvent('redemrp:getPlayerFromId', _source, function(user)
TriggerClientEvent("redemrp_notification:start", _source, "You are deaded", 2, "success")
local AliveID = ID
local charid = user.getSessionVar("charid")
local identifier = user.get('identifier')
local deadidentifier = identifier.."dead"..deadedcount
local player_inventory = Inventory[identifier .. "_" .. charid]
local ToAliveInv = {}
local ToDeadInv = {}
Wait(3000)
TriggerClientEvent("redemrp_notification:start", _source, "You are still deaded", 2, "success")
--Create ToDeadLocker
local playerped = GetPlayerPed(_source)
local deadcoords = coords
MySQL.ready(function()
data.createLocker("doctor_1" , -329.27, 800.93 ,117.55, nil)
data.createLocker(deadidentifier, coords.x , coords.y , coords.z, nil)
data.updateLockers(-1) -- update locker for everyone
end)
Wait(3000)
TriggerClientEvent("redemrp_notification:start", _source, "Dead Locker Created", 2, "success")
if player_inventory[1] ~= nil then
Wait(3000)
for i,k in pairs(player_inventory) do
table.insert(ToAliveInv ,{name = k.getName(), amount = k.getAmount(), meta = k.getMeta()})
end
end
local JsonItemsInventory = json.encode(ToAliveInv)
MySQL.Async.execute('UPDATE user_locker SET items = @items WHERE identifier = @identifier AND charid = @charid', {
['@identifier'] = deadidentifier,
['@charid'] = 0,
['@items'] = JsonItemsInventory
}, function (rowsChanged)
end)
MySQL.ready(function()
data.updateLockers(-1) -- update locker for everyone (Database has items, in game locker has nothing)
end)
TriggerClientEvent("redemrp_notification:start", _source, "Inventory Should Have Transferred", 2, "success")
--Now delete players Inventory
data.removePlayerInventory(_source)
Wait(4500)
TriggerClientEvent("redemrp_notification:start", _source, "DeadID="..deadidentifier.."DeathCoords: x="..coords.x.." y="..coords.y.." z=",coords.z, 5, "success")
end)
end)