Adorius Black
Advanced OT User
- Joined
- Mar 31, 2020
- Messages
- 301
- Solutions
- 3
- Reaction score
- 180
Hi. I have 2 problems with shop system.
The OTX Server Global - Version: (3.10)
- 2 weeks ago I didnt have these problems and from tihs time I didnt touch these scripts. But in these two weeks I did a lot changes so i dont know where is problem hiding.
1.) When I order more same items on webpage (example: 3 Solar Axes) then i go to game and say !shop it give me 1 solar axe "18:09 Congratulations! You have received 1 x solar axe!" and if i say again !shop it say to me "17:23 You have no orders.".
Here you can see scripts i use:
shop.lua
The OTX Server Global - Version: (3.10)
- 2 weeks ago I didnt have these problems and from tihs time I didnt touch these scripts. But in these two weeks I did a lot changes so i dont know where is problem hiding.
1.) When I order more same items on webpage (example: 3 Solar Axes) then i go to game and say !shop it give me 1 solar axe "18:09 Congratulations! You have received 1 x solar axe!" and if i say again !shop it say to me "17:23 You have no orders.".
Here you can see scripts i use:
XML:
<talkaction words="!shop" script="shop.lua" />
Lua:
function onSay(cid, words, param)
local storage = 54073 -- Make sure to select non-used storage. This is used to prevent SQL load attacks.
local cooldown = 0 -- in seconds.
local player = Player(cid)
if player:getStorageValue(storage) <= os.time() then
player:setStorageValue(storage, os.time() + cooldown)
-- Create the query
local orderQuery = db.storeQuery("SELECT `id`, `type`, `itemid`, `count` FROM `shop_orders` WHERE `account_id` = " .. player:getAccountId() .. " LIMIT 1;")
-- Detect if we got any results
if orderQuery ~= false then
-- Fetch order values
local q_id = result.getDataInt(orderQuery, "id")
local q_type = result.getDataInt(orderQuery, "type")
local q_itemid = result.getDataInt(orderQuery, "itemid")
local q_count = result.getDataInt(orderQuery, "count")
result.free(orderQuery)
-- ORDER TYPE 1 (Regular item shop products)
if q_type == 1 then
-- Get wheight
if player:getFreeCapacity() >= ItemType(q_itemid):getWeight(q_count) then
db.query("DELETE FROM `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
-- Add custom order types here
-- Type 2 is reserved for premium days and is handled on website, not needed here.
-- Type 3 is reserved for character gender(sex) change and is handled on website as well.
-- So use type 4+ for custom stuff, like etc packages.
-- if q_type == 4 then
-- end
else
player:sendTextMessage(MESSAGE_STATUS_WARNING, "You have no orders.")
end
else
player:sendTextMessage(MESSAGE_STATUS_CONSOLE_BLUE, "Can only be executed once every " .. cooldown .. " seconds. Remaining cooldown: " .. player:getStorageValue(storage) - os.time())
end
return false
end
same problem i have when i use another method : ModalWindow Shop
With this method I have another problem.
NOTE: Second problem I have only when i use my own map. When I use realmap, problem is solved.
2.) If I choose item in modal window it say "18:08 You got a parcel with: Solar axe, it is in (City) depot." but in depot is not parcel. I already add in Map Editor -> Depot Properties -> City.
So I write /shop one time -> choose item -> click OK I didnt recieve my item in Depot and when I write second time /shop all items are gone.
XML:
<talkaction words="/shop" script="shopp.lua" />
Lua:
function onSay(player, words, param)
local function ucfirst(str)
return (str:gsub("^%l", string.upper))
end
local my_db = db.storeQuery("SELECT `id`, `type`, `itemid`, `count` FROM `shop_orders` WHERE `account_id` = " .. player:getAccountId() .. "")
player:registerEvent('shop')
local title = "- SHOP LIST -"
local townas = player:getTown()
local name = townas:getName()
local message = "----------------------------------------\nYou have some items from website shop, when you press\ntake it you will get a parcel in your town ("..name..").\n\n----------------------------------------\n"
local my_window = ModalWindow(4, title, message)
if my_db == false then
return player:sendTextMessage(MESSAGE_INFO_DESCR,"You don't have any orders.")
end
if my_db ~= false then
local suma = 0
repeat
local id = result.getDataInt(my_db, "itemid")
local choiceid = result.getDataInt(my_db, "id")
suma = suma + 1
if (ItemType(id):getAttack() > 0) and (ItemType(id):getDefense() > 0) then
my_window:addChoice(choiceid,''..suma..'. '..ucfirst(ItemType(id):getName())..' (Atk: '..ItemType(id):getAttack()..' | Def: '..ItemType(id):getDefense()..')')
elseif ItemType(id):getArmor() then
my_window:addChoice(choiceid,''..suma..'. '..ucfirst(ItemType(id):getName())..' (Arm: '..ItemType(id):getArmor()..')')
else
my_window:addChoice(choiceid,''..suma..'. '..ucfirst(ItemType(id):getName()))
end
until not result.next(my_db)
result.free(my_db)
my_window:addButton(1,'Take it')
my_window:addButton(2,'Exit')
my_window:sendToPlayer(player)
end
end
Please... Is here anyone who know how to solve it?
In my opinion it can be issue somewhere in my database? I am not realy good at this so if you want more codes or pictures just write and I will post it.
In my opinion it can be issue somewhere in my database? I am not realy good at this so if you want more codes or pictures just write and I will post it.
Last edited by a moderator: