Postado Novembro 16, 2016 8 anos Eu ia fazer com tabelas (vetores), mas fiz com pressa se funcionar nos podemos adaptar para vetores, para ficar mais facil a edição... por hora teste isso: local keywordHandler = KeywordHandler:new() local npcHandler = NpcHandler:new(keywordHandler) NpcSystem.parseParameters(npcHandler) local vocation = {} local town = {} local destination = {} 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 local function greetCallback(cid) local level = getPlayerLevel(cid) if level < 8 then npcHandler:say("CHILD! COME BACK WHEN YOU HAVE GROWN UP!", cid) return false elseif level > 8 then npcHandler:say(getCreatureName(cid) .. ", I CAN'T LET YOU LEAVE - YOU ARE TOO STRONG ALREADY! YOU CAN ONLY LEAVE WITH LEVEL 8 OR LOWER.", cid) return false elseif getPlayerVocation(cid) > 0 then npcHandler:say("YOU ALREADY HAVE A VOCATION!", cid) return false end return true end local function creatureSayCallback(cid, type, msg) if not npcHandler:isFocused(cid) then return false elseif msgcontains(msg, "yes") and npcHandler.topic[cid] == 0 then npcHandler:say("You have to choose your vocation.: {KNIGHT}, {PALADIN}, {SORCERER}, OR {DRUID}?", cid) npcHandler.topic[cid] = 1 elseif msgcontains(msg, "no") and npcHandler.topic[cid] == 0 then npcHandler:say("What you want?", cid) elseif npcHandler.topic[cid] == 1 then if msgcontains(msg, "sorcerer") then npcHandler:say("A SORCERER! ARE YOU SURE? THIS DECISION IS IRREVERSIBLE!", cid) npcHandler.topic[cid] = 2 vocation[cid] = 1 town[cid] = 2 -- Edite aqui o ID town da vocação sorcerer destination[cid] = {x = 159, y = 387, z = 6} -- Edite aqui o destino da vocação sorcerer elseif msgcontains(msg, "druid") then npcHandler:say("A DRUID! ARE YOU SURE? THIS DECISION IS IRREVERSIBLE!", cid) npcHandler.topic[cid] = 3 vocation[cid] = 2 town[cid] = 2 -- Edite aqui o ID town da vocação druid destination[cid] = {x = 159, y = 387, z = 6} -- Edite aqui o destino da vocação druid elseif msgcontains(msg, "paladin") then npcHandler:say("A PALADIN! ARE YOU SURE? THIS DECISION IS IRREVERSIBLE!", cid) npcHandler.topic[cid] = 4 vocation[cid] = 3 town[cid] = 2 -- Edite aqui o ID town da vocação paladin destination[cid] = {x = 159, y = 387, z = 6} -- Edite aqui o destino da vocação paladin elseif msgcontains(msg, "knight") then npcHandler:say("A KNIGHT! ARE YOU SURE? THIS DECISION IS IRREVERSIBLE!", cid) npcHandler.topic[cid] = 5 vocation[cid] = 4 town[cid] = 2 -- Edite aqui o ID town da vocação knight destination[cid] = {x = 159, y = 387, z = 6} -- Edite aqui o destino da vocação knight else npcHandler:say("{KNIGHT}, {PALADIN}, {SORCERER}, OR {DRUID}?", cid) end elseif npcHandler.topic[cid] == 2 or npcHandler.topic[cid] == 3 or npcHandler.topic[cid] == 4 or npcHandler.topic[cid] == 5 then if msgcontains(msg, "yes") then npcHandler:say("SO BE IT!", cid) doPlayerSetVocation(cid, vocation[cid]) doPlayerSetTown(cid, town[cid]) local destination = destination[cid] npcHandler:releaseFocus(cid) doSendMagicEffect(getCreaturePosition(cid), CONST_ME_TELEPORT) doTeleportThing(cid, destination) doSendMagicEffect(destination, CONST_ME_TELEPORT) else npcHandler:say("THEN WHAT? {KNIGHT}, {PALADIN}, {SORCERER}, OR {DRUID}?", cid) npcHandler.topic[cid] = 1 end else npcHandler:say("What you want?", cid) end return true end local function onAddFocus(cid) town[cid] = 0 vocation[cid] = 0 destination[cid] = 0 end local function onReleaseFocus(cid) town[cid] = nil vocation[cid] = nil destination[cid] = nil end npcHandler:setCallback(CALLBACK_ONADDFOCUS, onAddFocus) npcHandler:setCallback(CALLBACK_ONRELEASEFOCUS, onReleaseFocus) npcHandler:setCallback(CALLBACK_GREET, greetCallback) npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback) npcHandler:addModule(FocusModule:new()) Desculpe a demora! Eu não testei. Leia o codigo, está comentado as partes que você deve editar com o TOWN e DESTINATION que cada vocação deve ir. Poste aqui o resultado. Editado Novembro 16, 2016 8 anos por login12 (veja o histórico de edições)
Participe da conversa
Você pode postar agora e se cadastrar mais tarde. Se você tem uma conta, faça o login para postar com sua conta.