• There is NO official Otland's Discord server and NO official Otland's server list. The Otland's Staff does not manage any Discord server or server list. Moderators or administrator of any Discord server or server lists have NO connection to the Otland's Staff. Do not get scammed!

(Solved - thanks)Talkactions (!vials) that change every empty vial in bp for money.

Wiw3K

New Member
Joined
Apr 16, 2008
Messages
371
Reaction score
3
as title says.

I dont want to type !vias 200 but only !vials then every vial will change for gold ex. !vials then message You have gain money for empty vials.
 
Last edited:
Code:
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
 
A 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
 
A 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 :):):)
 
Doesn't work T_T
Lua:
Lua Script Error: [TalkAction Interface]
data/talkactions/scripts/vials.lua:onSay

luaDoPlayerRemoveItem(). Player not found
 
Try this one ;P

Code:
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
 
Last edited:
It Give gold but doesnt remove vials...

Lua:
Lua Script Error: [TalkAction Interface]
data/talkactions/scripts/vials.lua:onSay

luaDoPlayerRemoveItem(). Player not found

take a look at script
Lua:
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
 
Last edited:
IDK :X Try this:

Code:
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
 
Nope, just say !vials. These paremeters weren't used ;p. But i can re-write to use paremeters if you want.
 
Back
Top