Postado Dezembro 11, 2015 9 anos Faça oque zipter98 mandou, mas no modules.lua Depois de : Citar player:setVocation(Vocation(promotion and promotion:getId() or 0)) Coloque: Citar if parameters.new_hometown then doPlayerSetTown(cid, parameters.new_hometown) doTeleportThing(cid, getTownTemplePosition(parameters.new_hometown)) end Ficando assim: Citar else local promotion = player:getVocation():getPromotion() player:setVocation(Vocation(promotion and promotion:getId() or 0)) if parameters.new_hometown then doPlayerSetTown(cid, parameters.new_hometown) doTeleportThing(cid, getTownTemplePosition(parameters.new_hometown)) end npcHandler:say(parameters.text, cid) end Editado Dezembro 11, 2015 9 anos por Kemix (veja o histórico de edições)
Postado Dezembro 11, 2015 9 anos Autor muito Obrigado Kemix, zipter98, LucasAyres. Consegui fazer funcionar, fico da seguinte maneira. Script do NPC: 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 CITYID = 3 -- Townid da cidade! local CITYNAME = "castle king" -- Nome da Cidade! local node1 = keywordHandler:addKeyword({'promot'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'I can promote you for 20000 gold coins. Do you want me to promote you?'}) node1:addChildKeyword({'yes'}, StdModule.promotePlayer, {npcHandler = npcHandler, new_hometown = CITYID, cost = 0, level = 200, promotion = 1, text = 'Congratulations! You are now promoted.'}) node1:addChildKeyword({'no'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'Alright then, come back when you are ready.', reset = true}) return 0 end npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback) npcHandler:addModule(FocusModule:new()) E a parte do Modules fico assim: (eu tirei a parte do PA pra promoted). function StdModule.promotePlayer(cid, message, keywords, parameters, node) local npcHandler = parameters.npcHandler if npcHandler == nil then error("StdModule.promotePlayer called without any npcHandler instance.") end if not npcHandler:isFocused(cid) then return false end local player = Player(cid) if player:getStorageValue(Storage.Promotion) == 1 then npcHandler:say("You are already promoted!", cid) elseif player:getLevel() < parameters.level then npcHandler:say("I am sorry, but I can only promote you once you have reached level " .. parameters.level .. ".", cid) elseif not player:removeMoney(parameters.cost) then npcHandler:say("You do not have enough money!", cid) else if parameters.new_hometown then doPlayerSetTown(cid, parameters.new_hometown) doTeleportThing(cid, getTownTemplePosition(parameters.new_hometown)) end local promotion = player:getVocation():getPromotion() player:setVocation(Vocation(promotion and promotion:getId() or 0)) npcHandler:say(parameters.text, cid) end npcHandler:resetNpc(cid) return true end Editado Dezembro 11, 2015 9 anos por BrunoLeo (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.