Script do npc, colocar na pasta npc/scripts, nome do arquivo trocar.lua
local keywordHandler = KeywordHandler:new()
local npcHandler = NpcHandler:new(keywordHandler)
NpcSystem.parseParameters(npcHandler)
local talkState = {}
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 talkUser = NPCHANDLER_CONVBEHAVIOR == CONVERSATION_DEFAULT and 0 or cid
local cidade = {x=100, y=784, z=7} --- posição da cidade
local voc = 31
if msgcontains(msg, 'yes') then
npcHandler:say('Voce mudou a sua vocacao.', cid)
doPlayerSetVocation(cid, voc)
doTeleportThing(cid, cidade)
talkState[talkUser] = 0
end
end
npcHandler:setCallback(CALLBACK_ONTHINK, thinkCallback)
npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())
no scripts npc
<?xml version="1.0" encoding="UTF-8"?>
<npc name="Trocador" script="data/npc/scripts/trocar.lua" walkinterval="25" floorchange="0" access="5" >
<health now="150" max="150"/>
<look type="162" head="115" body="0" legs="114" feet="0" addons="3" corpse="2212"/>
<parameters>
<parameter key="message_greet" value="Bem vindo |PLAYERNAME|! Caso queira trocar de vocacao fale {yes}."/>
<parameter key="message_alreadyfocused" value="ja estou falando com alguem."/>
<parameter key="message_farewell" value="Ate logo."/>
</parameters>
</npc>
I dont nothing to show, if u see this, sorry for you lose you time