function onSay(cid, words, param, channel)
local small = getPlayerItemCount(cid, id of small vial)
local strong = getPlayerItemCount(cid, id of strong vial)
local great = getPlayerItemCount(cid, id of great vial)
local moneys = {
5, -- Price of small vial.
10, -- Price of strong vial.
15 -- Price of great vial.
}
if (small > 0) then
doPlayerAddMoney(cid, moneys[1])
end
if (strong > 0) then
doPlayerAddMoney(cid, moneys[2])
end
if (great > 0) then
doPlayerAddMoney(cid, moneys[1])
end
return FALSE
end
local sellable = {
[7636] = 5, -- small
[7634] = 10, -- strong
[7635] = 15 -- great
}
function onSay(cid, words, param, channel)
local money, i = 0, 0
for id, cost in pairs(sellable) do
if(getPlayerItemCount(cid, id) > 0) then
if(doPlayerRemoveItem(cid, id) == TRUE) then
money = money + cost
i = i + 1
end
end
end
doPlayerAddMoney(cid, money)
doPlayerSendTextMessage(cid, "You sold " .. i .. " items for " .. money .. " gp.")
return TRUE
end
You can't live without editingA bit more configurable (oh and fixed - Chojrak you forgot about removing this item ;p)
Code:local sellable = { [7636] = 5, -- small [7634] = 10, -- strong [7635] = 15 -- great } function onSay(cid, words, param, channel) local money, i = 0, 0 for id, cost in pairs(sellable) do if(getPlayerItemCount(cid, id) > 0) then if(doPlayerRemoveItem(cid, id) == TRUE) then money = money + cost i = i + 1 end end end doPlayerAddMoney(cid, money) doPlayerSendTextMessage(cid, "You sold " .. i .. " items for " .. money .. " gp.") return TRUE end
You can't live without editing
function onSay(cid, words, param, channel)
local ids = {
1234, -- ID of small vial.
5678, -- ID of strong vial.
9101 -- ID of great vial.
}
local costs = {
5, -- Price of small vial.
10, -- Price of strong vial.
15 -- Price of great vial.
}
local small = getPlayerItemCount(cid, ids[1])
local strong = getPlayerItemCount(cid, ids[2]
local great = getPlayerItemCount(cid, ids[3])
if (small > 0) then
doPlayerAddMoney(cid, (small * costs[1]))
doPlayerRemoveItem(cid, ids[1])
elseif (strong > 0) then
doPlayerAddMoney(cid, (strong * costs[2]))
doPlayerRemoveItem(cid, ids[2])
elseif (great > 0) then
doPlayerAddMoney(cid, (great * costs[3]))
doPlayerRemoveItem(cid, ids[3])
end
return FALSE
end
Lua Script Error: [TalkAction Interface]
data/talkactions/scripts/vials.lua:onSay
luaDoPlayerRemoveItem(). Player not found
function onSay(cid, words, param, channel)
local ids = {
7636, -- ID of small vial.
7634, -- ID of strong vial.
7635 -- ID of great vial.
}
local costs = {
2, -- Price of small vial.
3, -- Price of strong vial.
4 -- Price of great vial.
}
local small = getPlayerItemCount(cid, ids[1])
local strong = getPlayerItemCount(cid, ids[2])
local great = getPlayerItemCount(cid, ids[3])
if (small > 0) then
doPlayerAddMoney(cid, (small * costs[1]))
doPlayerRemoveItem(cid, ids[1])
elseif (strong > 0) then
doPlayerAddMoney(cid, (strong * costs[2]))
doPlayerRemoveItem(cid, ids[2])
elseif (great > 0) then
doPlayerAddMoney(cid, (great * costs[3]))
doPlayerRemoveItem(cid, ids[3])
end
return FALSE
end
function onSay(cid, words, param, channel)
local ids = {
7636, -- ID of small vial.
7634, -- ID of strong vial.
7635 -- ID of great vial.
}
local costs = {
2, -- Price of small vial.
3, -- Price of strong vial.
4 -- Price of great vial.
}
local small = getPlayerItemCount(cid, ids[1])
local strong = getPlayerItemCount(cid, ids[2])
local great = getPlayerItemCount(cid, ids[3])
if (small > 0) then
doPlayerAddMoney(cid, (small * costs[1]))
doPlayerRemoveItem(cid, ids[1], small)
elseif (strong > 0) then
doPlayerAddMoney(cid, (strong * costs[2]))
doPlayerRemoveItem(cid, ids[2], strong)
elseif (great > 0) then
doPlayerAddMoney(cid, (great * costs[3]))
doPlayerRemoveItem(cid, ids[3], great)
end
return TRUE
end