Stellow
C++/C#/PHP/LUA
I am trying to make my lua script shortes. This script is supposed to buy items using lever, is not working tho, and not showing any error msg. I am using red 3777 tfs .4
Code:
local config = {
[1001] = {itemid = 7620, price = 5000, cap = 180},
[1002] = {itemid = 7589, price = 8000, cap = 200}
}
function onUse(cid, item, fromPosition, itemEx, toPosition)
local id = config[item.uid]
if(getPlayerFreeCap(cid) < id.cap) then
doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "You need at least " .. id.cap .. " oz to buy this item.")
return true
end
if item.uid < 1001 or item.uid > 1015 then
return false
end
if getCreatureStorage(cid,6667) == -1 then
doPlayerSendCancel(cid,"You need to finish Annihilator 2 Quest to use this lever.")
return false
end
if item.itemid == 1945 then
doTransformItem(item.uid, 1946)
elseif item.itemid == 1946 then
doTransformItem(item.uid, 1945)
end
if item.uid == id then
if getPlayerMoney(cid) >= id.price then
brown_bp = doPlayerAddItem(cid, id.itemid, 100)
doPlayerRemoveMoney(cid, id.price)
doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "You have bought it for ".. id.price .." gold coins.")
else
doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "You do not have enough money.")
end
end
return true
end