• 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!
  • New resources must be posted under Resources tab. A discussion thread will be created automatically, you can't open threads manually anymore.

TalkAction Buy Items With Command

Programmer

Lua, Java, C
Joined
Jan 26, 2013
Messages
67
Reaction score
3
Location
United States
Buy Items With Command
By Programmer (Credits to Darkhaos)

Hello, today I introduce to you a script dealing with buying useful items with a simple command "!buy". It has been tested by me personally with TFS 0.3.6pl and 0.4, it worked flawlessly. It is also simple to configure with any items you prefer to buy with the table. Thanks, and have a wonderful day! c:


Lua:
--Buy Items With Command
	--Script by Programmer (Credits to Darkhaos)

local shop = 
{
	["aol"] = {money=10000, id=3057, amount=1},
	["backpack"] = {money=100, id=2854, amount=1},
	["food"] = {money=10, id=3725, amount=100},
	["rope"] = {money=50, id=3003, amount=1},
	["shovel"] = {money=50, id=3457, amount=1},
	["machete"] = {money=250, id=3308, amount=1},
	["pick"] = {money=200, id=3456, amount=1},
	["rod"] = {money=500, id=3483, amount=1},
	["worms"] = {money=200, id=3492, amount=100}
}
 
function onSay(cid, words, param)
	local text = "Here's a list of items available in the shop\nBuy Name : Item Name : Price : Amount\n\n"
	if(param == "" or param == nil) then
		for k, v in pairs(shop) do
			text = text .. k .. " - " .. v.money .. " - " .. getItemNameById(v.id) .. " - " .. v.amount .. "\n"
		end
		return doShowTextDialog(cid, 2195, text)
	else
		buyItem = shop[param]
		if buyItem then
       			if getPlayerMoney(cid) >= buyItem.money then
				doSendMagicEffect(getCreaturePosition(cid), 14)
				doPlayerAddItem(cid, buyItem.id, buyItem.amount)
            			doPlayerRemoveMoney(cid, buyItem.money)
            			doPlayerSendTextMessage(cid, 24, "Great choice! You've bought " .. param .. "for " .. buyItem.money .. "!")
				return true
        		else
            			return doPlayerSendCancel(cid, "You require " .. buyItem.money .. " gold coins to buy this item.")
        		end
    		else
        		return doPlayerSendCancel(cid, "Parameter Error 404: Wrong param")
		end
    	end
	return true
end
 
Last edited:
I like it :) I guess you could help me alot with scripting ;)
 
you can add an option for buy it with count, for items like worms, food -and also an aol-, its simply and easy, but i will deserve it to your creativity.
 
Back
Top