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 85e6518 commit cb57583
Show file tree
Hide file tree
Showing 2 changed files with 68 additions and 67 deletions.
68 changes: 68 additions & 0 deletions data/scripts/actions/objects/outfit_memorial.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
local goldenOutfitCache = { [1] = {}, [2] = {}, [3] = {} }
local royalOutfitCache = { [1] = {}, [2] = {}, [3] = {} }
local lastUpdatedGolden = 0
local lastUpdatedRoyal = 0

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

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

local resultId = db.storeQuery("SELECT `name`, `value` FROM `player_storage` INNER JOIN `players` as `p` ON `p`.`id` = `player_id` WHERE `key` = " .. storageKey .. " AND `value` >= 1;")
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, os.time()
end

local outfitMemorial = Action()

function outfitMemorial.onUse(player, item, fromPosition, target, toPosition, isHotkey)
goldenOutfitCache, lastUpdatedGolden = updateOutfitCache(Storage.OutfitQuest.GoldenOutfit, goldenOutfitCache, lastUpdatedGolden)
royalOutfitCache, lastUpdatedRoyal = updateOutfitCache(Storage.OutfitQuest.RoyalCostumeOutfit, royalOutfitCache, lastUpdatedRoyal)

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

local goldenOutfitPrices = { 500000000, 750000000, 1000000000 }
for i, 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 i = 1, 3 do
for j, 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 cb57583

Please sign in to comment.