kilirt
New Member
- Joined
- May 11, 2009
- Messages
- 223
- Reaction score
- 2
Hello, i've modify a script of lever shop for buy item with an item but this don't work can you repair this plx ?
Lua:
function onUse(cid, item, fromPosition, itemEx, toPosition)
local shop = {
[52000] = {
id = 2798, container = 6104, cost = 1, charges = 100, effect = CONST_ME_GIFT_WRAPS },
[52001] = {
id = 1, container = 9969, cost = 10, charges = 1, effect = CONST_ME_GIFT_WRAPS
},
[52002] = {
id = 1, container = 6527, cost = 20, charges = 1, effect = CONST_ME_GIFT_WRAPS
},
[52003] = {
id = 1, container = 9825, cost = 45, charges = 1, effect = CONST_ME_GIFT_WRAPS
},
[52004] = {
id = 1, container = 11257, cost = 1, charges = 1, effect = CONST_ME_GIFT_WRAPS
},
[52005] = {
id = 1, container = 11297, cost = 30, charges = 1, effect = CONST_ME_GIFT_WRAPS
},
[52006] = {
id = 1, container = 11298, cost = 100, charges = 1, effect = CONST_ME_GIFT_WRAPS
},
[52007] = {
id = 1, container = 11295, cost = 150, charges = 1, effect = CONST_ME_GIFT_WRAPS
},
[52008] = {
id = 1, container = 11296, cost = 100, charges = 1, effect = CONST_ME_GIFT_WRAPS
},
[52009] = {
id = 1, container = 5080, cost = 20, charges = 1, effect = CONST_ME_GIFT_WRAPS
},
[52010] = {
id = 1, container = 2284, cost = 300, charges = 1, effect = CONST_ME_GIFT_WRAPS
},
[52011] = {
id = 1, container = 2300, cost = 5, charges = 1, effect = CONST_ME_GIFT_WRAPS
},
[52012] = {
id = 2300, container = 10522, cost = 30, charges = 1, effect = CONST_ME_GIFT_WRAPS
},
[52013] = {
id = 1, container = 2297, cost = 15, charges = 1, effect = CONST_ME_GIFT_WRAPS
},
[52014] = {
id = 1, container = 8613, cost = 500, charges = 1, effect = CONST_ME_GIFT_WRAPS
},
}
local v = shop[item.actionid]
local weight = getItemWeightById(v.id, tonumber(getItemInfo(v.container).maxItems)) + getItemWeightById(v.container, 1)
if(getPlayerFreeCap(cid) >= weight) then
if getPlayerItemCount(cid, 2157) >= v.cost then
local bp = doCreateItemEx(cid, v.container, 1)
if(doPlayerAddItemEx(cid, bp) ~= RETURNVALUE_NOERROR) then
doPlayerSendCancel(cid, "Sorry, you do not have enough space.")
else
for i = 1, tonumber(getItemInfo(v.container).maxItems) do
doAddContainerItem(bp, v.id, v.charges or 1)
end
doPlayerRemoveMoney(cid, v.cost)
doSendMagicEffect(getThingPos(cid), v.effect)
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, "You buy a" .. getItemInfo(v.id).plural .. ".")
end
else
doPlayerSendCancel(cid, "Sorry, you must have " .. v.cost .. " gold nugget.")
end
else
doPlayerSendCancel(cid, "Sorry, you need " .. weight:format("%.2f") .. " oz. to carry this container of " .. getItemInfo(v.id).plural .. ".")
end
return doTransformItem(item.uid, item.itemid == 9825 and 9826 or 9825)
end