Fix #369 - Outfit offer type (5) supports 2 outfit ids.

This commit is contained in:
Znote
2019-11-09 22:04:16 +01:00
parent be8b882166
commit b65c860b66
7 changed files with 136 additions and 59 deletions

View File

@@ -65,16 +65,29 @@ function onThink(interval, lastExecution)
-- ORDER TYPE 5 (Outfit and addon)
if orderType == 5 then
served = true
-- Make sure player don't already have this outfit and addon
if not player:hasOutfit(orderItemId, orderCount) then
db.query("DELETE FROM `znote_shop_orders` WHERE `id` = " .. orderId .. ";")
player:addOutfit(orderItemId)
player:addOutfitAddon(orderItemId, orderCount)
player:sendTextMessage(MESSAGE_INFO_DESCR, "Congratulations! You have received a new outfit!")
print("Process complete. [".. player:getName() .."] has recieved outfit: ["..orderItemId.."] with addon: ["..orderCount.."]")
else -- Already has outfit
player:sendTextMessage(MESSAGE_STATUS_WARNING, "You already have this outfit and addon!")
print("Process canceled. [".. player:getName() .."] already have outfit: ["..orderItemId.."] with addon: ["..orderCount.."].")
local itemid = orderItemId
local outfits = {}
if itemid > 1000 then
local first = math.floor(itemid/1000)
table.insert(outfits, first)
itemid = itemid - (first * 1000)
end
table.insert(outfits, itemid)
for _, outfitId in pairs(outfits) do
-- Make sure player don't already have this outfit and addon
if not player:hasOutfit(outfitId, orderCount) then
db.query("DELETE FROM `znote_shop_orders` WHERE `id` = " .. orderId .. ";")
player:addOutfit(outfitId)
player:addOutfitAddon(outfitId, orderCount)
player:sendTextMessage(MESSAGE_INFO_DESCR, "Congratulations! You have received a new outfit!")
print("Process complete. [".. player:getName() .."] has recieved outfit: ["..outfitId.."] with addon: ["..orderCount.."]")
else -- Already has outfit
player:sendTextMessage(MESSAGE_STATUS_WARNING, "You already have this outfit and addon!")
print("Process canceled. [".. player:getName() .."] already have outfit: ["..outfitId.."] with addon: ["..orderCount.."].")
end
end
end

View File

@@ -47,14 +47,27 @@ function onSay(player, words, param)
-- ORDER TYPE 5 (Outfit and addon)
if q_type == 5 then
served = true
-- Make sure player don't already have this outfit and addon
if not player:hasOutfit(q_itemid, q_count) then
db.query("DELETE FROM `znote_shop_orders` WHERE `id` = " .. q_id .. ";")
player:addOutfit(q_itemid)
player:addOutfitAddon(q_itemid, q_count)
player:sendTextMessage(MESSAGE_INFO_DESCR, "Congratulations! You have received a new outfit!")
else
player:sendTextMessage(MESSAGE_STATUS_WARNING, "You already have this outfit and addon!")
local itemid = q_itemid
local outfits = {}
if itemid > 1000 then
local first = math.floor(itemid/1000)
table.insert(outfits, first)
itemid = itemid - (first * 1000)
end
table.insert(outfits, itemid)
for _, outfitId in pairs(outfits) do
-- Make sure player don't already have this outfit and addon
if not player:hasOutfit(outfitId, q_count) then
db.query("DELETE FROM `znote_shop_orders` WHERE `id` = " .. q_id .. ";")
player:addOutfit(outfitId)
player:addOutfitAddon(outfitId, q_count)
player:sendTextMessage(MESSAGE_INFO_DESCR, "Congratulations! You have received a new outfit!")
else
player:sendTextMessage(MESSAGE_STATUS_WARNING, "You already have this outfit and addon!")
end
end
end