Use the lever script, put the actionid on the item, remove funcions "doTransformItem(blablablba)" from script and you are done
--[[
Potion Script v1.0
by Shawak
]]--
local config = {
[8502] = {potion = 7620, cost = 50},
[8503] = {potion = 7589, cost = 80},
[8504] = {potion = 7590, cost = 100},
[8505] = {potion = 8472, cost = 200},
[8506] = {potion = 8473, cost = 500},
[8507] = {potion = 7591, cost = 100},
[8508] = {potion = 7588, cost = 80},
[8509] = {potion = 7618, cost = 50},
} -- config end --
function onUse(cid, item, fromPosition, itemEx, toPosition)
local potion = config[item.uid]
if isInArray({1945, 1946}, item.itemid) ~= TRUE then
return TRUE
end
if doPlayerBuyItem(cid,potion.potion, 1, potion.cost, 1) == TRUE then
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "You bought 100 "..getItemNameById(potion.potion).." for "..potion.cost.." gold coins.")
doSendMagicEffect(getPlayerPosition(cid), CONST_ME_FIREWORK_RED)
else
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "You need "..potion.cost.." gold coins for 1 "..getItemNameById(potion.potion)..".")
doSendMagicEffect(getPlayerPosition(cid), CONST_ME_POFF)
end
return TRUE
end
--[[
Potion Script v1.0
by Shawak
]]--
local config = {
[8502] = {potion = 7620, cost = 50},
[8503] = {potion = 7589, cost = 80},
[8504] = {potion = 7590, cost = 100},
[8505] = {potion = 8472, cost = 200},
[8506] = {potion = 8473, cost = 500},
[8507] = {potion = 7591, cost = 100},
[8508] = {potion = 7588, cost = 80},
[8509] = {potion = 7618, cost = 50},
} -- config end --
function onUse(cid, item, fromPosition, itemEx, toPosition)
local potion = config[item.uid]
if doPlayerBuyItem(cid,potion.potion, 1, potion.cost, 1) == TRUE then
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "You bought 100 "..getItemNameById(potion.potion).." for "..potion.cost.." gold coins.")
doSendMagicEffect(getPlayerPosition(cid), CONST_ME_FIREWORK_RED)
else
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "You need "..potion.cost.." gold coins for 1 "..getItemNameById(potion.potion)..".")
doSendMagicEffect(getPlayerPosition(cid), CONST_ME_POFF)
end
return TRUE
end
didnt work![]()
--[[
Potion Script v1.0
by Shawak, corrected by RealSoft
]]--
local config = {
[8502] = {potion = 7620, cost = 50},
[8503] = {potion = 7589, cost = 80},
[8504] = {potion = 7590, cost = 100},
[8505] = {potion = 8472, cost = 200},
[8506] = {potion = 8473, cost = 500},
[8507] = {potion = 7591, cost = 100},
[8508] = {potion = 7588, cost = 80},
[8509] = {potion = 7618, cost = 50},
} -- config end --
function onUse(cid, item, fromPosition, itemEx, toPosition)
local potion = config[item.uid]
if doPlayerBuyItem(cid,potion.potion, 1, potion.cost, 1) == TRUE then
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "You bought 100 "..getItemNameById(config.potion).." for "..config.cost.." gold coins.")
doSendMagicEffect(getPlayerPosition(cid), CONST_ME_FIREWORK_RED)
else
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "You need "..config.cost.." gold coins for 1 "..getItemNameById(config.potion)..".")
doSendMagicEffect(getPlayerPosition(cid), CONST_ME_POFF)
end
return TRUE
end
local t = {
[ITEM] = {pot, price, count, effect}
}
function onUse(cid, item, fromPosition, itemEx, toPosition)
local i = t[item.itemid]
if i then
if getPlayerMoney(cid) >= i[2] then
local id = doCreateItemEx(i, i[1])
if doPlayerAddItemEx(cid, id, true) ~= RETURNVALUE_NOERROR then
return false
end
doPlayerRemoveMoney(cid, i[2])
doSendMagicEffect(getThingPos(cid), i[4])
doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "You have purchased " .. i[3] .. "x " .. getItemInfo(i[1]).name .. ".")
else
return doPlayerSendCancel(cid, "Sorry, you do not have enough money.")
end
end
return true
end