From 28816da5913399c1c12310ec76bee8029b0f86ff Mon Sep 17 00:00:00 2001 From: Stefan Brannfjell Date: Sat, 2 Nov 2013 22:11:04 +0100 Subject: [PATCH] Bugfix from Lucas Milbradt. znoteshop.lua now makes sure the player have enough slots available to receive item. --- .../talkaction shopsystem/znoteshop.lua | 23 ++++++++++++++----- 1 file changed, 17 insertions(+), 6 deletions(-) diff --git a/LUA/TFS_03/talkaction shopsystem/znoteshop.lua b/LUA/TFS_03/talkaction shopsystem/znoteshop.lua index 8c0b865..40a7587 100644 --- a/LUA/TFS_03/talkaction shopsystem/znoteshop.lua +++ b/LUA/TFS_03/talkaction shopsystem/znoteshop.lua @@ -18,18 +18,29 @@ function onSay(cid, words, param) 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 local playerCap = getPlayerFreeCap(cid) local itemweight = getItemWeightById(q_itemid, q_count) - if playerCap >= itemweight then - db.executeQuery("DELETE FROM `znote_shop_orders` WHERE `id` = " .. q_id .. ";") - doPlayerAddItem(cid, q_itemid, q_count) - doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "Congratulations! You have recieved ".. q_count .." "..getItemNameById(q_itemid).."(s)!") + if playerCap >= itemweight and getTileInfo(getCreaturePosition(cid)).protection then + --backpack check + local backpack = getPlayerSlotItem(cid, 3) + 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 - doPlayerSendTextMessage(cid, MESSAGE_STATUS_WARNING, "Need more CAP!") + doPlayerSendTextMessage(cid, MESSAGE_STATUS_WARNING, "Need more CAP and Need ProtectZone!") end end -- Add custom order types here