forked from opentibiabr/canary
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
85e6518
commit cb57583
Showing
2 changed files
with
68 additions
and
67 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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() |
This file was deleted.
Oops, something went wrong.