Hi guys i'm working on a hardcore like script but i'm facing a issue, in this function, when the player die, i spawn a grave that is a gob (that is a chest), and i want that all the stuff that the player have goes to this chest, but i have two issues:
The first issue is that the chest desappear when the player resurect and not after the time i specified here:
local secondsInADay = 86400
local event = CreateLuaEvent(function()
if grave and grave:IsInWorld() then
grave:Despawn()
end
end, secondsInADay * 1000, 1)
The second issue is that the stuff of the player don't go in the GOB.
local function CreateGrave(player)
if player:GetLevel() < 15 then
return
end
local chestGameObjectEntry = 8000015 -- Utilisez l'ID du modèle de coffre que vous souhaitez
local secondsInADay = 86400 -- Durée pendant laquelle le cimetière restera spawn en secondes (1 jour)
local x, y, z, o = player:GetLocation()
local grave = player:SummonGameObject(chestGameObjectEntry, x, y, z, o)
if grave then
local graveGUID = grave:GetGUIDLow() -- Obtenir le GUID du gardien d'âmes
for slot = 0, 18 do
local item = player:GetItemByPos(255, slot) -- Emplacement des équipements
if item then
grave:AddLoot(item:GetEntry(), 22) -- Ajouter l'objet au coffre (1 quantité)
end
end
for bag = 19, 22 do
for slot = 0, 35 do
local item = player:GetItemByPos(bag, slot) -- Emplacement des sacs équipés
if item then
grave:AddLoot(item:GetEntry(), 5) -- Ajouter l'objet au coffre (1 quantité)
end
end
end
local event = CreateLuaEvent(function()
if grave and grave:IsInWorld() then
grave:Despawn()
end
end, secondsInADay * 1000, 1)
print("Tombe (Coffre) GUID: " .. graveGUID)
local input_Grave_GUID = "UPDATE hc_dead_log SET grave_guid = '" .. graveGUID .. "' WHERE guid = '" .. player:GetGUIDLow() .. "'"
AuthDBExecute(input_Grave_GUID)
end
end
Someone have a tip for me?
Thanks in advance.
I took the liberty of rewriting your code.
The despawn problem is fixed and to see the loot of your object you need to update your gameobject like this :
For your lua script I allowed myself a few optimizations and reworking :
Best regards, iThorgrim