Skip to content

Commit

Permalink
fix: outfit memorial
Browse files Browse the repository at this point in the history
  • Loading branch information
omarcopires committed Mar 22, 2024
1 parent ab5fa95 commit 932dcfd
Show file tree
Hide file tree
Showing 2 changed files with 70 additions and 67 deletions.
70 changes: 70 additions & 0 deletions data/scripts/actions/objects/outfit_memorial.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
local goldenOutfitCache = { [1] = {}, [2] = {}, [3] = {} }
local royalOutfitCache = { [1] = {}, [2] = {}, [3] = {} }
local lastUpdatedGolden = os.time()
local lastUpdatedRoyal = os.time()

local function updateOutfitCache(storageKey, cache, lastUpdated)
local currentTime = os.time()
if currentTime < lastUpdated + 60 * 10 then
return cache, lastUpdated
end

local newCache = { [1] = {}, [2] = {}, [3] = {} }

local resultId = db.storeQuery("SELECT `key_name`, `timestamp`, `value` FROM `kv_store` WHERE `key_name` = '" .. storageKey .. "'")

if resultId then
repeat
table.insert(newCache[Result.getNumber(resultId, "value")], Result.getString(resultId, "name"))
until not Result.next(resultId)

Result.free(resultId)
end

return newCache, currentTime
end

local outfitMemorial = Action()

function outfitMemorial.onUse(player, item, fromPosition, target, toPosition, isHotkey)
goldenOutfitCache, lastUpdatedGolden = updateOutfitCache("golden-outfit-quest", goldenOutfitCache, lastUpdatedGolden)
royalOutfitCache, lastUpdatedRoyal = updateOutfitCache("royal-costume-outfit-quest", royalOutfitCache, lastUpdatedRoyal)

local msg = NetworkMessage()
msg:addByte(0xB0)

local goldenOutfitPrices = { 500000000, 750000000, 1000000000 }
for _, price in ipairs(goldenOutfitPrices) do
msg:addU32(price)
end

for i = 1, 3 do
msg:addU16(#goldenOutfitCache[i])

for j = 1, #goldenOutfitCache[i] do
msg:addString(goldenOutfitCache[i][j], "outfitMemorial.onUse - goldenOutfitCache[i][j]")
end
end

local royalOutfitPrices = { 30000, 25000 }
for _ = 1, 3 do
for _, price in ipairs(royalOutfitPrices) do
msg:addU16(price)
end
end

for i = 1, 3 do
msg:addU16(#royalOutfitCache[i])

for j = 1, #royalOutfitCache[i] do
msg:addString(royalOutfitCache[i][j], "outfitMemorial.onUse - royalOutfitCache[i][j]")
end
end

msg:sendToPlayer(player)
msg:delete()
return true
end

outfitMemorial:id(31518, 31519, 31520, 31521, 31522, 31523)
outfitMemorial:register()
67 changes: 0 additions & 67 deletions data/scripts/actions/objects/outfits_memorial.lua

This file was deleted.

0 comments on commit 932dcfd

Please sign in to comment.