Crie um arquivo na pasta npc/scripts com nome de tokenexchange.lua e coloque isso:
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)
local config = {
montaria = 74, -- ID Da montaria
token = 21400 -- ID Do Token
}
if(not npcHandler:isFocused(cid)) then
return false
end
local talkUser = NPCHANDLER_CONVBEHAVIOR == CONVERSATION_DEFAULT and 0 or cid
if(msgcontains(msg, 'trade') or msgcontains(msg, 'token')) then
selfSay('Voce quer trocar Silver Raid Token pela montaria XXX?', cid)
talkState[talkUser] = 1
elseif(msgcontains(msg, 'yes') and talkState[talkUser] == 1) then
if(getPlayerItemCount(cid, config.token) >= 1) then
doPlayerRemoveItem(cid, config.token, 1)
doPlayerAddMount(cid, config.montaria)
selfSay('Aqui esta sua montaria =).', cid)
else
selfSay('desculpe, voce nao tem este item.', cid)
end
talkState[talkUser] = 0
elseif(msgcontains(msg, 'no') and isInArray({1}, talkState[talkUser]) == TRUE) then
talkState[talkUser] = 0
selfSay('Ok then.', cid)
end
return true
end
npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())
Na pasta NPC crie um arquivo chamado tokenexchange.xml e coloque isso:
<?xml version="1.0" encoding="UTF-8"?>
<npc name="Token Exchange" script="tokenexchange.lua" walkinterval="2000" floorchange="0">
<health now="100" max="100"/>
<look type="134" head="55" body="60" legs="50" feet="75" addons="3"/>
</npc>
OBS: Configure o script e o nome à seu gosto =)