• 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!

[REQUEST] Buy Command Edition

Ranyo13

ManCausingMayhem
Joined
Aug 22, 2009
Messages
981
Reaction score
39
Hello otlanders..
I got a buy command that lets you buy certain items for certain ammount of gold coins. e.g: The player enters !buy backpack or !buy aol.. It takes an ammount of money from the buyer and gives the item.. Well i wanted to edit it so when the buyer says (!buy) only he gets a list of whats available that he cud buy.. I think its posted somewhere but i realy cant find it so heres the script:
Code:
local buyableitems = {
["aol"] = {money=10, id=2173, amount=1},
["food"] = {money=1, id=2671, amount=100},
["backpack"] = {money=100, id=1988, amount=1}
}
 
function onSay(cid, words, param)
buyitem = buyableitems[param]
    if (buyitem ~= nil) then
        if getPlayerMoney(cid) >= buyitem.money then
            doSendMagicEffect(getCreaturePosition(cid), 14)
            doPlayerAddItem(cid,buyitem.id,buyitem.amount)
            doPlayerRemoveMoney(cid,buyitem.money)
            doPlayerSendTextMessage(cid,24,"You've succesfully bought "..param.."!")
        else
            doPlayerSendCancel(cid,"You need "..buyitem.money.." gold to buy this item.")
        end
    else
        doPlayerSendCancel(cid,"You can not buy this item.")
    end
return TRUE
end
Please help me with what i requested and i will add u reputation, if u can't script it just dun comment like a weird guy..:rolleyes:
Thanks in advance,
Ranyo13
 
LUA:
local buyableItems = 
{
	["aol"] = {money=10, id=2173, amount=1},
	["food"] = {money=1, id=2671, amount=100},
	["backpack"] = {money=100, id=1988, amount=1}
}
 
function onSay(cid, words, param)
	local text = "Here's a list of all items that you can buy\nBuy Name - Item Name - Price - Amount\n\n"
	if(param == "" or param == nil) then
		for k, v in pairs(buyableItems) do
			text = text .. k .. " - " .. v.money .. " - " .. getItemNameById(v.id) .. " - " .. v.amount .. "\n"
		end
		return doShowTextDialog(cid, 2195, text)
	else
		buyItem = buyableItems[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, "You've succesfully bought " .. param .. "!")
				return true
        		else
            			return doPlayerSendCancel(cid, "You need " .. buyItem.money .. " gold coins to buy this item.")
        		end
    		else
        		return doPlayerSendCancel(cid, "Wrong param for buyable items.")
		end
    	end
	return true
end
 
Back
Top