Vá em data/npcs/scripts e crie um arquivo chamado diamond.lua e coloque:
local keywordHandler = KeywordHandler:new()
local npcHandler = NpcHandler:new(keywordHandler)
NpcSystem.parseParameters(npcHandler)
local talkState = {}
function onCreatureAppear(cid) npcHandler:onCreatureAppear(cid) end
function onCreatureDisappear(cid) npcHandler:onCreatureDisappear(cid) end
function onCreatureSay(cid, type, msg) npcHandler:onCreatureSay(cid, type, msg) end
function onThink() npcHandler:onThink() end
function creatureSayCallback(cid, type, msg)
if(not npcHandler:isFocused(cid)) then
return false
end
local talkState = {}
local talkUser = NPCHANDLER_CONVbehavior == CONVERSATION_DEFAULT and 0 or cid
local shopWindow = {}
local moeda = XXX -- id do diamond (moeda que será usada)
local t = {
[xxx] = {price = 1}, ---- xxx é o ID do item a ser vendido e price é a quantidade de diamond necessario
[xxx] = {price = 1},
[xxx] = {price = 1},
}
local onBuy = function(cid, item, subType, amount, ignoreCap, inBackpacks)
if t[item] and not doPlayerRemoveItem(cid, moeda, t[item].price) then
selfSay("You don't have "..t[item].price.." "..getItemNameById(moeda), cid)
else
doPlayerAddItem(cid, item)
selfSay("Here are you.", cid)
end
return true
end
if (msgcontains(msg, 'trade') or msgcontains(msg, 'TRADE'))then
for var, ret in pairs(t) do
table.insert(shopWindow, {id = var, subType = 0, buy = ret.price, sell = 0, name = getItemNameById(var)})
end
openShopWindow(cid, shopWindow, onBuy, onSell)
end
return true
end
npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())
Agora em data/npcs crie um arquivo chamado diamondnpc.lua e coloque:
<?xml version="1.0" encoding="UTF-8"?>
<npc name="Diamond" script="data/npc/scripts/diamond.lua" walkinterval="2000" floorchange="0">
<health now="100" max="100"/>
<look type="302" head="96" body="99" legs="99" feet="115" addons="2"/>
<parameters>
<parameter key="message_greet" value="Hello |PLAYERNAME| I change {diamonds} for {items}, say {trade}, Ola |PLAYERNAME| Eu troco {Diamonds} por {items}, diga {trade}." />
<parameter key="module_keywords" value="1" />
</parameters>
</npc>
npc name= Nome do Npc que troca os itens
look type= ID do outfit que ele usa
parameter key="message_greet" value= O que o NPC fala
Qualquer duivida posta aqui.