#Instalando
Crie um arquivo lua chamado "buyitem" dentro de data/talkactions/scripts e em seguida adicione o seguinte texto:
-- script by Notorious
items = {
["torch"] = { cost = 10, count = 1 },
}
function onSay(cid, words, param)
local parameter = param:lower()
if param == "items" then
for index, value in pairs(items) do
index = index:sub(1, 1):upper()..index:sub(2)
msg = "Name: "..index..", Price: "..value.cost..", Count: "..value.count..""
str = (str or "We are selling:") .. "\n" .. "- " .. msg
end
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, str)
str = nil
return true
end
if items[parameter] then
if doPlayerBuyItem(cid, getItemIdByName(parameter), items[parameter].count, items[parameter].cost) then
doSendMagicEffect(getThingPos(cid), math.random(27, 29))
else
doPlayerSendCancel(cid, "You don't have enough money.")
end
else
doPlayerSendCancel(cid, "This item doesn't exist or is not buyable. Say '!buy items' to view avaliable items.")
end
return true
end
Adicione a seguinte TAG (linha) dentro de talkactions.xml:
<talkaction words="!buy" event="script" value="buyitem.lua"/>
#Configurando
Para adicionar novos itens adicione uma nova tag dentro de "items = {}" com os dados do item a ser vendido, exemplo:
["magic sword"] = { cost = 10000, count = 1 },
Lembrando que o nome do item deve existir, estar correto e ser escrito em letras minusculas.
Agora é só usar o comando !buy dentro do jogo ^^