Process all orders at once in shop talkaction script

This commit is contained in:
Znote 2019-09-09 02:16:37 +02:00
parent c5323dbc78
commit c0f891b2d7
4 changed files with 286 additions and 212 deletions

View File

@ -7,60 +7,76 @@ function onSay(cid, words, param)
setPlayerStorageValue(cid, storage, os.time() + cooldown) setPlayerStorageValue(cid, storage, os.time() + cooldown)
local accid = getAccountNumberByPlayerName(getCreatureName(cid)) local accid = getAccountNumberByPlayerName(getCreatureName(cid))
local type_desc = {
"itemids",
"pending premium (skip)",
"pending gender change (skip)",
"pending character name change (skip)",
"Outfit and addons"
}
print("Player: " .. getCreatureName(cid) .. " triggered !shop talkaction.")
-- Create the query -- Create the query
local orderQuery = db.storeQuery("SELECT `id`, `type`, `itemid`, `count` FROM `znote_shop_orders` WHERE `account_id` = " .. accid .. " LIMIT 1;") local orderQuery = db.storeQuery("SELECT `id`, `type`, `itemid`, `count` FROM `znote_shop_orders` WHERE `account_id` = " .. accid .. ";")
local served = false
-- Detect if we got any results -- Detect if we got any results
if orderQuery ~= false then if orderQuery ~= false then
-- Fetch order values repeat
local q_id = result.getDataInt(orderQuery, "id") -- Fetch order values
local q_type = result.getDataInt(orderQuery, "type") local q_id = result.getDataInt(orderQuery, "id")
local q_itemid = result.getDataInt(orderQuery, "itemid") local q_type = result.getDataInt(orderQuery, "type")
local q_count = result.getDataInt(orderQuery, "count") local q_itemid = result.getDataInt(orderQuery, "itemid")
result.free(orderQuery) local q_count = result.getDataInt(orderQuery, "count")
print("Processing type "..q_type..": ".. type_desc[q_type])
-- ORDER TYPE 1 (Regular item shop products) -- ORDER TYPE 1 (Regular item shop products)
if q_type == 1 then if q_type == 1 then
-- Get wheight served = true
local playerCap = getPlayerFreeCap(cid) -- Get wheight
local itemweight = getItemWeight(q_itemid, q_count) local playerCap = getPlayerFreeCap(cid)
if playerCap >= itemweight then local itemweight = getItemWeight(q_itemid, q_count)
db.query("DELETE FROM `znote_shop_orders` WHERE `id` = " .. q_id .. ";") if playerCap >= itemweight then
doPlayerAddItem(cid, q_itemid, q_count) db.query("DELETE FROM `znote_shop_orders` WHERE `id` = " .. q_id .. ";")
doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "Congratulations! You have recieved ".. q_count .." "..getItemName(q_itemid).."(s)!") doPlayerAddItem(cid, q_itemid, q_count)
else doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "Congratulations! You have recieved ".. q_count .." "..getItemName(q_itemid).."(s)!")
doPlayerSendTextMessage(cid, MESSAGE_STATUS_WARNING, "Need more CAP!") else
end doPlayerSendTextMessage(cid, MESSAGE_STATUS_WARNING, "Need more CAP!")
end end
-- ORDER TYPE 5 (Outfit and addon)
if q_type == 5 then
-- Make sure player don't already have this outfit and addon
if not canPlayerWearOutfit(cid, q_itemid, q_count) then
db.query("DELETE FROM `znote_shop_orders` WHERE `id` = " .. q_id .. ";")
doPlayerAddOutfit(cid,q_itemid,q_count)
doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "Congratulations! You have received a new outfit!")
else
doPlayerSendTextMessage(cid, MESSAGE_STATUS_WARNING, "You already have this outfit and addon!")
end end
-- 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 canPlayerWearOutfit(cid, q_itemid, q_count) then
db.query("DELETE FROM `znote_shop_orders` WHERE `id` = " .. q_id .. ";")
doPlayerAddOutfit(cid,q_itemid,q_count)
doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "Congratulations! You have received a new outfit!")
else
doPlayerSendTextMessage(cid, MESSAGE_STATUS_WARNING, "You already have this outfit and addon!")
end
end
-- ORDER TYPE 6 (Mounts)
-- Not supported on TFS 0.2
-- Add custom order types here
-- Type 1 is for itemids (Already coded here)
-- Type 2 is for premium (Coded on web)
-- Type 3 is for gender change (Coded on web)
-- Type 4 is for character name change (Coded on web)
-- Type 5 is for character outfit and addon (Already coded here)
-- Type 6 is for mounts (Not for TFS 0.2)
-- So use type 7+ for custom stuff, like etc packages.
-- if q_type == 7 then
-- end
until not result.next(orderQuery)
result.free(orderQuery)
if not served then
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "You have no orders to process in-game.")
end end
-- ORDER TYPE 6 (Mounts)
-- Not supported on TFS 0.2
-- Add custom order types here
-- Type 1 is for itemids (Already coded here)
-- Type 2 is for premium (Coded on web)
-- Type 3 is for gender change (Coded on web)
-- Type 4 is for character name change (Coded on web)
-- Type 5 is for character outfit and addon (Already coded here)
-- Type 6 is for mounts (Not for TFS 0.2)
-- So use type 7+ for custom stuff, like etc packages.
-- if q_type == 7 then
-- end
else else
doPlayerSendTextMessage(cid, MESSAGE_STATUS_WARNING, "You have no orders.") doPlayerSendTextMessage(cid, MESSAGE_STATUS_WARNING, "You have no orders.")
end end
else else
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Can only be executed once every "..cooldown.." seconds. Remaining cooldown: ".. getPlayerStorageValue(cid, storage) - os.time()) doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Can only be executed once every "..cooldown.." seconds. Remaining cooldown: ".. getPlayerStorageValue(cid, storage) - os.time())
end end

View File

@ -7,72 +7,90 @@ function onSay(cid, words, param)
setPlayerStorageValue(cid, storage, os.time() + cooldown) setPlayerStorageValue(cid, storage, os.time() + cooldown)
local accid = getAccountNumberByPlayerName(getCreatureName(cid)) local accid = getAccountNumberByPlayerName(getCreatureName(cid))
local type_desc = {
"itemids",
"pending premium (skip)",
"pending gender change (skip)",
"pending character name change (skip)",
"Outfit and addons",
"Mounts"
}
print("Player: " .. getCreatureName(cid) .. " triggered !shop talkaction.")
-- Create the query -- Create the query
local orderQuery = db.storeQuery("SELECT `id`, `type`, `itemid`, `count` FROM `znote_shop_orders` WHERE `account_id` = " .. accid .. ";") local orderQuery = db.storeQuery("SELECT `id`, `type`, `itemid`, `count` FROM `znote_shop_orders` WHERE `account_id` = " .. accid .. ";")
local served = false
-- Detect if we got any results -- Detect if we got any results
if orderQuery ~= false then if orderQuery ~= false then
-- Fetch order values repeat
local q_id = result.getDataInt(orderQuery, "id") -- Fetch order values
local q_type = result.getDataInt(orderQuery, "type") local q_id = result.getDataInt(orderQuery, "id")
local q_itemid = result.getDataInt(orderQuery, "itemid") local q_type = result.getDataInt(orderQuery, "type")
local q_count = result.getDataInt(orderQuery, "count") local q_itemid = result.getDataInt(orderQuery, "itemid")
result.free(orderQuery) local q_count = result.getDataInt(orderQuery, "count")
print("Processing type "..q_type..": ".. type_desc[q_type])
-- ORDER TYPE 1 (Regular item shop products) -- ORDER TYPE 1 (Regular item shop products)
if q_type == 1 then if q_type == 1 then
-- Get wheight served = true
local playerCap = getPlayerFreeCap(cid) -- Get wheight
local itemweight = getItemWeightById(q_itemid, q_count) local playerCap = getPlayerFreeCap(cid)
if playerCap >= itemweight then local itemweight = getItemWeightById(q_itemid, q_count)
if playerCap >= itemweight then
local delete = db.storeQuery("DELETE FROM `znote_shop_orders` WHERE `id` = " .. q_id .. ";")
result.free(delete)
doPlayerAddItem(cid, q_itemid, q_count)
doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "Congratulations! You have recieved ".. q_count .." "..getItemNameById(q_itemid).."(s)!")
else
doPlayerSendTextMessage(cid, MESSAGE_STATUS_WARNING, "Need more CAP!")
end
end
-- 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 canPlayerWearOutfit(cid, q_itemid, q_count) then
local delete = db.storeQuery("DELETE FROM `znote_shop_orders` WHERE `id` = " .. q_id .. ";") local delete = db.storeQuery("DELETE FROM `znote_shop_orders` WHERE `id` = " .. q_id .. ";")
result.free(delete) result.free(delete)
doPlayerAddItem(cid, q_itemid, q_count) doPlayerAddOutfit(cid,q_itemid,q_count)
doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "Congratulations! You have recieved ".. q_count .." "..getItemNameById(q_itemid).."(s)!") doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "Congratulations! You have received a new outfit!")
else else
doPlayerSendTextMessage(cid, MESSAGE_STATUS_WARNING, "Need more CAP!") doPlayerSendTextMessage(cid, MESSAGE_STATUS_WARNING, "You already have this outfit and addon!")
end end
end
-- ORDER TYPE 5 (Outfit and addon)
if q_type == 5 then
-- Make sure player don't already have this outfit and addon
if not canPlayerWearOutfit(cid, q_itemid, q_count) then
local delete = db.storeQuery("DELETE FROM `znote_shop_orders` WHERE `id` = " .. q_id .. ";")
result.free(delete)
doPlayerAddOutfit(cid,q_itemid,q_count)
doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "Congratulations! You have received a new outfit!")
else
doPlayerSendTextMessage(cid, MESSAGE_STATUS_WARNING, "You already have this outfit and addon!")
end end
end
-- ORDER TYPE 6 (Mounts) -- ORDER TYPE 6 (Mounts)
if q_type == 6 then if q_type == 6 then
-- Make sure player don't already have this outfit and addon served = true
if not getPlayerMount(cid, q_itemid) then -- Failed to find a proper hasMount 0.3 function? -- Make sure player don't already have this outfit and addon
local delete = db.storeQuery("DELETE FROM `znote_shop_orders` WHERE `id` = " .. q_id .. ";") if not getPlayerMount(cid, q_itemid) then -- Failed to find a proper hasMount 0.3 function?
result.free(delete) local delete = db.storeQuery("DELETE FROM `znote_shop_orders` WHERE `id` = " .. q_id .. ";")
doPlayerAddMount(cid, q_itemid) result.free(delete)
doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "Congratulations! You have received a new mount!") doPlayerAddMount(cid, q_itemid)
else doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "Congratulations! You have received a new mount!")
doPlayerSendTextMessage(cid, MESSAGE_STATUS_WARNING, "You already have this mount!") else
doPlayerSendTextMessage(cid, MESSAGE_STATUS_WARNING, "You already have this mount!")
end
end end
end
-- Add custom order types here -- Add custom order types here
-- Type 1 is for itemids (Already coded here) -- Type 1 is for itemids (Already coded here)
-- Type 2 is for premium (Coded on web) -- Type 2 is for premium (Coded on web)
-- Type 3 is for gender change (Coded on web) -- Type 3 is for gender change (Coded on web)
-- Type 4 is for character name change (Coded on web) -- Type 4 is for character name change (Coded on web)
-- Type 5 is for character outfit and addon (Already coded here) -- Type 5 is for character outfit and addon (Already coded here)
-- Type 6 is for mounts (Already coded here) -- Type 6 is for mounts (Already coded here)
-- So use type 7+ for custom stuff, like etc packages. -- So use type 7+ for custom stuff, like etc packages.
-- if q_type == 7 then -- if q_type == 7 then
-- end -- end
until not result.next(orderQuery)
result.free(orderQuery)
if not served then
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "You have no orders to process in-game.")
end
else else
doPlayerSendTextMessage(cid, MESSAGE_STATUS_WARNING, "You have no orders.") doPlayerSendTextMessage(cid, MESSAGE_STATUS_WARNING, "You have no orders.")
end end
else else
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Can only be executed once every "..cooldown.." seconds. Remaining cooldown: ".. getPlayerStorageValue(cid, storage) - os.time()) doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Can only be executed once every "..cooldown.." seconds. Remaining cooldown: ".. getPlayerStorageValue(cid, storage) - os.time())
end end

View File

@ -7,78 +7,97 @@ function onSay(cid, words, param)
setPlayerStorageValue(cid, storage, os.time() + cooldown) setPlayerStorageValue(cid, storage, os.time() + cooldown)
local accid = getAccountNumberByPlayerName(getCreatureName(cid)) local accid = getAccountNumberByPlayerName(getCreatureName(cid))
local type_desc = {
"itemids",
"pending premium (skip)",
"pending gender change (skip)",
"pending character name change (skip)",
"Outfit and addons",
"Mounts"
}
print("Player: " .. getCreatureName(cid) .. " triggered !shop talkaction.")
-- Create the query -- Create the query
local orderQuery = db.storeQuery("SELECT `id`, `type`, `itemid`, `count` FROM `znote_shop_orders` WHERE `account_id` = " .. accid .. " LIMIT 1;") local orderQuery = db.storeQuery("SELECT `id`, `type`, `itemid`, `count` FROM `znote_shop_orders` WHERE `account_id` = " .. accid .. ";")
local served = false
-- Detect if we got any results -- Detect if we got any results
if orderQuery ~= false then if orderQuery ~= false then
-- Fetch order values repeat
local q_id = result.getDataInt(orderQuery, "id") -- Fetch order values
local q_type = result.getDataInt(orderQuery, "type") local q_id = result.getDataInt(orderQuery, "id")
local q_itemid = result.getDataInt(orderQuery, "itemid") local q_type = result.getDataInt(orderQuery, "type")
local q_count = result.getDataInt(orderQuery, "count") local q_itemid = result.getDataInt(orderQuery, "itemid")
result.free(orderQuery) local q_count = result.getDataInt(orderQuery, "count")
-- ORDER TYPE 1 (Regular item shop products) print("Processing type "..q_type..": ".. type_desc[q_type])
if q_type == 1 then -- ORDER TYPE 1 (Regular item shop products)
-- Get wheight if q_type == 1 then
local playerCap = getPlayerFreeCap(cid) served = true
local itemweight = getItemWeightById(q_itemid, q_count) -- Get wheight
if playerCap >= itemweight and getTileInfo(getCreaturePosition(cid)).protection then local playerCap = getPlayerFreeCap(cid)
--backpack check local itemweight = getItemWeightById(q_itemid, q_count)
local backpack = getPlayerSlotItem(cid, 3) if playerCap >= itemweight and getTileInfo(getCreaturePosition(cid)).protection then
local gotItem = false --backpack check
if(backpack and backpack.itemid > 0) then local backpack = getPlayerSlotItem(cid, 3)
local received = doAddContainerItem(getPlayerSlotItem(cid, 3).uid, q_itemid,q_count) local gotItem = false
if(received ~= false) then if(backpack and backpack.itemid > 0) then
db.executeQuery("DELETE FROM `znote_shop_orders` WHERE `id` = " .. q_id .. ";") local received = doAddContainerItem(getPlayerSlotItem(cid, 3).uid, q_itemid,q_count)
doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "Congratulations! You have recieved ".. q_count .." "..getItemNameById(q_itemid).."(s)!") if(received ~= false) then
gotItem = true db.executeQuery("DELETE FROM `znote_shop_orders` WHERE `id` = " .. q_id .. ";")
doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "Congratulations! You have recieved ".. q_count .." "..getItemNameById(q_itemid).."(s)!")
gotItem = true
end
end end
end
if(not gotItem) then if(not gotItem) then
doPlayerSendTextMessage(cid, MESSAGE_STATUS_WARNING, "You have no available space in backpack to receive that item.") doPlayerSendTextMessage(cid, MESSAGE_STATUS_WARNING, "You have no available space in backpack to receive that item.")
end
else
doPlayerSendTextMessage(cid, MESSAGE_STATUS_WARNING, "Need more CAP and Need ProtectZone!")
end end
end
-- 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 canPlayerWearOutfit(cid, q_itemid, q_count) then
db.executeQuery("DELETE FROM `znote_shop_orders` WHERE `id` = " .. q_id .. ";")
doPlayerAddOutfit(cid,q_itemid,q_count)
doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "Congratulations! You have received a new outfit!")
else else
doPlayerSendTextMessage(cid, MESSAGE_STATUS_WARNING, "Need more CAP and Need ProtectZone!") doPlayerSendTextMessage(cid, MESSAGE_STATUS_WARNING, "You already have this outfit and addon!")
end end
end
-- ORDER TYPE 5 (Outfit and addon)
if q_type == 5 then
-- Make sure player don't already have this outfit and addon
if not canPlayerWearOutfit(cid, q_itemid, q_count) then
db.executeQuery("DELETE FROM `znote_shop_orders` WHERE `id` = " .. q_id .. ";")
doPlayerAddOutfit(cid,q_itemid,q_count)
doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "Congratulations! You have received a new outfit!")
else
doPlayerSendTextMessage(cid, MESSAGE_STATUS_WARNING, "You already have this outfit and addon!")
end end
end
-- ORDER TYPE 6 (Mounts) -- ORDER TYPE 6 (Mounts)
if q_type == 6 then if q_type == 6 then
-- Make sure player don't already have this outfit and addon served = true
if not getPlayerMount(cid, q_itemid) then -- Failed to find a proper hasMount 0.3 function? -- Make sure player don't already have this outfit and addon
db.executeQuery("DELETE FROM `znote_shop_orders` WHERE `id` = " .. q_id .. ";") if not getPlayerMount(cid, q_itemid) then -- Failed to find a proper hasMount 0.3 function?
doPlayerAddMount(cid, q_itemid) db.executeQuery("DELETE FROM `znote_shop_orders` WHERE `id` = " .. q_id .. ";")
doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "Congratulations! You have received a new mount!") doPlayerAddMount(cid, q_itemid)
else doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "Congratulations! You have received a new mount!")
doPlayerSendTextMessage(cid, MESSAGE_STATUS_WARNING, "You already have this mount!") else
doPlayerSendTextMessage(cid, MESSAGE_STATUS_WARNING, "You already have this mount!")
end
end end
end
-- Add custom order types here -- Add custom order types here
-- Type 1 is for itemids (Already coded here) -- Type 1 is for itemids (Already coded here)
-- Type 2 is for premium (Coded on web) -- Type 2 is for premium (Coded on web)
-- Type 3 is for gender change (Coded on web) -- Type 3 is for gender change (Coded on web)
-- Type 4 is for character name change (Coded on web) -- Type 4 is for character name change (Coded on web)
-- Type 5 is for character outfit and addon (Already coded here) -- Type 5 is for character outfit and addon (Already coded here)
-- Type 6 is for mounts (Already coded here) -- Type 6 is for mounts (Already coded here)
-- So use type 7+ for custom stuff, like etc packages. -- So use type 7+ for custom stuff, like etc packages.
-- if q_type == 7 then -- if q_type == 7 then
-- end -- end
until not result.next(orderQuery)
result.free(orderQuery)
if not served then
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "You have no orders to process in-game.")
end
else else
doPlayerSendTextMessage(cid, MESSAGE_STATUS_WARNING, "You have no orders.") doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "You have no orders.")
end end
else else

View File

@ -6,67 +6,88 @@ function onSay(player, words, param)
if player:getStorageValue(storage) <= os.time() then if player:getStorageValue(storage) <= os.time() then
player:setStorageValue(storage, os.time() + cooldown) player:setStorageValue(storage, os.time() + cooldown)
local type_desc = {
"itemids",
"pending premium (skip)",
"pending gender change (skip)",
"pending character name change (skip)",
"Outfit and addons",
"Mounts"
}
print("Player: " .. player:getName() .. " triggered !shop talkaction.")
-- Create the query -- Create the query
local orderQuery = db.storeQuery("SELECT `id`, `type`, `itemid`, `count` FROM `znote_shop_orders` WHERE `account_id` = " .. player:getAccountId() .. " LIMIT 1;") local orderQuery = db.storeQuery("SELECT `id`, `type`, `itemid`, `count` FROM `znote_shop_orders` WHERE `account_id` = " .. player:getAccountId() .. ";")
local served = false
-- Detect if we got any results -- Detect if we got any results
if orderQuery ~= false then if orderQuery ~= false then
-- Fetch order values repeat
local q_id = result.getNumber(orderQuery, "id") -- Fetch order values
local q_type = result.getNumber(orderQuery, "type") local q_id = result.getNumber(orderQuery, "id")
local q_itemid = result.getNumber(orderQuery, "itemid") local q_type = result.getNumber(orderQuery, "type")
local q_count = result.getNumber(orderQuery, "count") local q_itemid = result.getNumber(orderQuery, "itemid")
local q_count = result.getNumber(orderQuery, "count")
print("Processing type "..q_type..": ".. type_desc[q_type])
-- ORDER TYPE 1 (Regular item shop products)
if q_type == 1 then
served = true
-- Get wheight
if player:getFreeCapacity() >= ItemType(q_itemid):getWeight(q_count) then
db.query("DELETE FROM `znote_shop_orders` WHERE `id` = " .. q_id .. ";")
player:addItem(q_itemid, q_count)
player:sendTextMessage(MESSAGE_INFO_DESCR, "Congratulations! You have received " .. q_count .. " x " .. ItemType(q_itemid):getName() .. "!")
else
player:sendTextMessage(MESSAGE_STATUS_WARNING, "Need more CAP!")
end
end
-- 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!")
end
end
-- ORDER TYPE 6 (Mounts)
if q_type == 6 then
served = true
-- Make sure player don't already have this outfit and addon
if not player:hasMount(q_itemid) then
db.query("DELETE FROM `znote_shop_orders` WHERE `id` = " .. q_id .. ";")
player:addMount(q_itemid)
player:sendTextMessage(MESSAGE_INFO_DESCR, "Congratulations! You have received a new mount!")
else
player:sendTextMessage(MESSAGE_STATUS_WARNING, "You already have this mount!")
end
end
-- Add custom order types here
-- Type 1 is for itemids (Already coded here)
-- Type 2 is for premium (Coded on web)
-- Type 3 is for gender change (Coded on web)
-- Type 4 is for character name change (Coded on web)
-- Type 5 is for character outfit and addon (Already coded here)
-- Type 6 is for mounts (Already coded here)
-- So use type 7+ for custom stuff, like etc packages.
-- if q_type == 7 then
-- end
until not result.next(orderQuery)
result.free(orderQuery) result.free(orderQuery)
if not served then
-- ORDER TYPE 1 (Regular item shop products) player:sendTextMessage(MESSAGE_STATUS_CONSOLE_BLUE, "You have no orders to process in-game.")
if q_type == 1 then
-- Get wheight
if player:getFreeCapacity() >= ItemType(q_itemid):getWeight(q_count) then
db.query("DELETE FROM `znote_shop_orders` WHERE `id` = " .. q_id .. ";")
player:addItem(q_itemid, q_count)
player:sendTextMessage(MESSAGE_INFO_DESCR, "Congratulations! You have received " .. q_count .. " x " .. ItemType(q_itemid):getName() .. "!")
else
player:sendTextMessage(MESSAGE_STATUS_WARNING, "Need more CAP!")
end
end end
-- ORDER TYPE 5 (Outfit and addon)
if q_type == 5 then
-- 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!")
end
end
-- ORDER TYPE 6 (Mounts)
if q_type == 6 then
-- Make sure player don't already have this outfit and addon
if not player:hasMount(q_itemid) then
db.query("DELETE FROM `znote_shop_orders` WHERE `id` = " .. q_id .. ";")
player:addMount(q_itemid)
player:sendTextMessage(MESSAGE_INFO_DESCR, "Congratulations! You have received a new mount!")
else
player:sendTextMessage(MESSAGE_STATUS_WARNING, "You already have this mount!")
end
end
-- Add custom order types here
-- Type 1 is for itemids (Already coded here)
-- Type 2 is for premium (Coded on web)
-- Type 3 is for gender change (Coded on web)
-- Type 4 is for character name change (Coded on web)
-- Type 5 is for character outfit and addon (Already coded here)
-- Type 6 is for mounts (Already coded here)
-- So use type 7+ for custom stuff, like etc packages.
-- if q_type == 7 then
-- end
else else
player:sendTextMessage(MESSAGE_STATUS_WARNING, "You have no orders.") player:sendTextMessage(MESSAGE_STATUS_CONSOLE_BLUE, "You have no orders.")
end end
else else
player:sendTextMessage(MESSAGE_STATUS_CONSOLE_BLUE, "Can only be executed once every " .. cooldown .. " seconds. Remaining cooldown: " .. player:getStorageValue(storage) - os.time()) player:sendTextMessage(MESSAGE_STATUS_CONSOLE_BLUE, "Can only be executed once every " .. cooldown .. " seconds. Remaining cooldown: " .. player:getStorageValue(storage) - os.time())