Ir para conteúdo

Featured Replies

Postado

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 por Kemix (veja o histórico de edições)

  • Respostas 6
  • Visualizações 647
  • Created
  • Última resposta

Top Posters In This Topic

Most Popular Posts

  • Uma opção seria reescrever o código. Infelizmente, a preguiça não deixa. Troque: node1:addChildKeyword({'yes'}, StdModule.promotePlayer, {npcHandler = npcHandler, cost = 0, level = 200, promo

  • Faça oque zipter98 mandou, mas no modules.lua Depois de :  Coloque: Ficando assim:  

Postado
  • 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 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.

Visitante
Responder

Quem Está Navegando 0

  • Nenhum usuário registrado visualizando esta página.

Estatísticas dos Fóruns

  • Tópicos 96.9k
  • Posts 519.7k

Informação Importante

Confirmação de Termo