Ldrozd
Piszę skrypty w zeszycie.
Hello guys,
I would like to present you my new script. It is my first release here. Before I didnt want to paste here basic script so I improved myself and wrote this one.
It lets you to buy backpack of potions. Just use the lever.
Maybe one picture to show you how it works. Not really needed but here is it:
I would like to present you my new script. It is my first release here. Before I didnt want to paste here basic script so I improved myself and wrote this one.
It lets you to buy backpack of potions. Just use the lever.
Lua:
-- Written by Ldrozd with Tairen's advice; do not delete it, you arent the creator
function onUse(cid, item, fromPosition, itemEx, toPosition)
local potion = {
[1000] = {id = 7620, bp = 2001, cost = 10000, anim = 30},
[1001] = {id = 7589, bp = 2001, cost = 16000, anim = 30},
[1002] = {id = 7590, bp = 2001, cost = 24000, anim = 30},
[1003] = {id = 7618, bp = 1988, cost = 9200, anim = 29},
[1004] = {id = 7588, bp = 1988, cost = 20000, anim = 29},
[1005] = {id = 7591, bp = 1988, cost = 38000, anim = 29},
[1006] = {id = 8473, bp = 1988, cost = 62000, anim = 29},
[1007] = {id = 8472, bp = 1999, cost = 38000, anim = 28}
}
local actuallPotion = potion[item.actionid]
local weight = getItemWeightById(actuallPotion.id, 20) + getItemWeightById(actuallPotion.bp, 1)
if(getPlayerFreeCap(cid) >= weight) then
if getPlayerMoney(cid) >= actuallPotion.cost then
local bp = doCreateItemEx(cid, actuallPotion.bp, 1)
doAddContainerItem(bp, actuallPotion.id, 20)
if(doPlayerAddItemEx(cid, bp) ~= RETURNVALUE_NOERROR) then
doPlayerSendTextMessage(cid,MESSAGE_INFO_DESCR,"You need more space in your container.")
else
doPlayerRemoveMoney(cid, actuallPotion.cost)
doSendMagicEffect(toPosition, actuallPotion.anim)
doPlayerSendTextMessage(cid,MESSAGE_INFO_DESCR,"You have bought backpack of "..getItemNameById(actuallPotion.id).."s for "..actuallPotion.cost.." gold coins.")
end
else
doPlayerSendTextMessage(cid,MESSAGE_INFO_DESCR,"You need "..actuallPotion.cost.." gold coins to buy these potions.")
end
else
doPlayerSendTextMessage(cid,MESSAGE_INFO_DESCR,"You need at least "..math.ceil(weight).." oz to buy this item.")
end
if item.itemid == 1945 then
doTransformItem(item.uid, item.itemid+1)
elseif item.itemid == 1946 then
doTransformItem(item.uid, item.itemid-1)
else
return true
end
return true
end
Maybe one picture to show you how it works. Not really needed but here is it:
Last edited: