Bugfix from Lucas Milbradt. znoteshop.lua now makes sure the player have enough slots available to receive item.

This commit is contained in:
Stefan Brannfjell 2013-11-02 22:11:04 +01:00
parent 1933816180
commit 28816da591

View File

@ -18,18 +18,29 @@ function onSay(cid, words, param)
local q_itemid = result.getDataInt(orderQuery, "itemid") local q_itemid = result.getDataInt(orderQuery, "itemid")
local q_count = result.getDataInt(orderQuery, "count") local q_count = result.getDataInt(orderQuery, "count")
result.free(orderQuery) result.free(orderQuery)
-- 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 -- Get wheight
local playerCap = getPlayerFreeCap(cid) local playerCap = getPlayerFreeCap(cid)
local itemweight = getItemWeightById(q_itemid, q_count) local itemweight = getItemWeightById(q_itemid, q_count)
if playerCap >= itemweight then if playerCap >= itemweight and getTileInfo(getCreaturePosition(cid)).protection then
db.executeQuery("DELETE FROM `znote_shop_orders` WHERE `id` = " .. q_id .. ";") --backpack check
doPlayerAddItem(cid, q_itemid, q_count) local backpack = getPlayerSlotItem(cid, 3)
doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "Congratulations! You have recieved ".. q_count .." "..getItemNameById(q_itemid).."(s)!") local gotItem = false
if(backpack and backpack.itemid > 0) then
local received = doAddContainerItem(getPlayerSlotItem(cid, 3).uid, q_itemid,q_count)
if(received ~= false) then
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
if(not gotItem) then
doPlayerSendTextMessage(cid, MESSAGE_STATUS_WARNING, "You have no available space in backpack to receive that item.")
end
else else
doPlayerSendTextMessage(cid, MESSAGE_STATUS_WARNING, "Need more CAP!") doPlayerSendTextMessage(cid, MESSAGE_STATUS_WARNING, "Need more CAP and Need ProtectZone!")
end end
end end
-- Add custom order types here -- Add custom order types here