Closed mofigi closed 2 years ago
Yes, that is what custom types are for.
Add new typeid here: https://github.com/Znote/ZnoteAAC/blob/ec55497c5abcad662489e6616d726e749a9e1bb3/Lua/TFS_10/revscriptsys/shopsystem_globalevent.lua#L4
Add type description here: https://github.com/Znote/ZnoteAAC/blob/ec55497c5abcad662489e6616d726e749a9e1bb3/Lua/TFS_10/revscriptsys/shopsystem_globalevent.lua#L26-L34
Add type processing code here: (Above if not served then
)
https://github.com/Znote/ZnoteAAC/blob/ec55497c5abcad662489e6616d726e749a9e1bb3/Lua/TFS_10/revscriptsys/shopsystem_globalevent.lua#L144-L145
Sample:
-- ORDER TYPE 8 (Starter Pack)
if orderType == 8 then
served = true
local itemType = ItemType(orderItemId)
-- Get weight
if player:getFreeCapacity() >= itemType:getWeight(orderCount) then
local backpack = player:getSlotItem(CONST_SLOT_BACKPACK)
-- variable = (condition) and (return if true) or (return if false)
local needslots = itemType:isStackable() and math.floor(orderCount / 100) + 1 or orderCount
if backpack ~= nil and backpack:getEmptySlots(false) >= needslots then
db.query("DELETE FROM `znote_shop_orders` WHERE `id` = " .. orderId .. ";")
-- Create items for player
local scroll = Game.createItem(5957, 1) -- Lottery ticket
scroll:setActionId(1103)
scroll:setAttribute(ITEM_ATTRIBUTE_NAME, "Teleport scroll")
scroll:setAttribute(ITEM_ATTRIBUTE_DESCRIPTION, "Teleports you to starter pack island.")
-- Add items to player
player:addItemEx(scroll)
player:sendTextMessage(MESSAGE_INFO_DESCR, "Congratulations! You have received the starter pack!")
print("Process complete. [".. player:getName() .."] has received starter pack.")
else -- not enough slots
player:sendTextMessage(MESSAGE_STATUS_WARNING, "Your main backpack is full. You need to free up "..needslots.." available slots to get " .. orderCount .. " " .. ItemType(orderItemId):getName() .. "!")
print("Process canceled. [".. player:getName() .."] need more space in his backpack to get " .. orderCount .. "x " .. ItemType(orderItemId):getName() .. ".")
end
else -- not enough cap
player:sendTextMessage(MESSAGE_STATUS_WARNING, "You need more CAP to carry this order!")
print("Process canceled. [".. player:getName() .."] need more cap to carry " .. orderCount .. "x " .. ItemType(orderItemId):getName() .. ".")
end
end
In shop offers, add the new type, itemid is for image to show. https://github.com/Znote/ZnoteAAC/blob/ec55497c5abcad662489e6616d726e749a9e1bb3/config.php#L1002-L1066
Sample:
10 => array(
'type' => 8, // The new custom type you built
'itemid' => 12466,
'count' => 1,
'description' => "Starter pack bundle",
'points' => 10,
),
is it possible to put a pack of various items in the shop? ex: shield + 20 crystal coin + golden helmet for 10 points ?