Postado Março 1 Mar 1 Qual servidor ou website você utiliza como base? Canary Qual o motivo deste tópico? Estou criando um NPC para se o player acertar a palavra mágica, o player é teleportado para uma área específica. O NPC não pode interagir, apenas escutar a palavra certa e teleportar o player, mas não está funcionando. Você tem o código disponível? Se tiver publique-o aqui: local internalNpcName = "Guardian" local npcType = Game.createNpcType(internalNpcName) local npcConfig = {} npcConfig.name = internalNpcName npcConfig.description = internalNpcName npcConfig.health = 100 npcConfig.maxHealth = npcConfig.health npcConfig.walkInterval = 0 npcConfig.walkRadius = 2 npcConfig.outfit = { lookTypeEx = 2152, } npcConfig.flags = { floorchange = false, } local keywordHandler = KeywordHandler:new() local npcHandler = NpcHandler:new(keywordHandler) npcType.onThink = function(npc, interval) npcHandler:onThink(npc, interval) end npcType.onAppear = function(npc, creature) npcHandler:onAppear(npc, creature) end npcType.onDisappear = function(npc, creature) npcHandler:onDisappear(npc, creature) end npcType.onMove = function(npc, creature, fromPosition, toPosition) npcHandler:onMove(npc, creature, fromPosition, toPosition) end npcType.onSay = function(npc, creature, type, message) npcHandler:onSay(npc, creature, type, message) end npcType.onCloseChannel = function(npc, creature) npcHandler:onCloseChannel(npc, creature) end local function creatureSayCallback(npc, creature, type, message) local player = Player(creature) if not npcHandler:checkInteraction(npc, creature) then return false end local topos = { x = 32311, y = 11005, z = 6 } player:teleportTo(topos) end -- Greeting message keywordHandler:addGreetKeyword({ "abre-te sesamo" }, { npcHandler = npcHandler, }) npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback) npcHandler:setCallback(CALLBACK_GREET, greetCallback) -- npcType registering the npcConfig table npcType:register(npcConfig) Alguém conseguiria me auxiliar?
Postado Março 15 Mar 15 Diretor local internalNpcName = "Guardian" local npcType = Game.createNpcType(internalNpcName) local npcConfig = {} npcConfig.name = internalNpcName npcConfig.description = internalNpcName npcConfig.health = 100 npcConfig.maxHealth = npcConfig.health npcConfig.walkInterval = 0 npcConfig.walkRadius = 2 npcConfig.outfit = { lookTypeEx = 2152, } npcConfig.flags = { floorchange = false, } local keywordHandler = KeywordHandler:new() local npcHandler = NpcHandler:new(keywordHandler) npcType.onThink = function(npc, interval) npcHandler:onThink(npc, interval) end npcType.onAppear = function(npc, creature) npcHandler:onAppear(npc, creature) end npcType.onDisappear = function(npc, creature) npcHandler:onDisappear(npc, creature) end npcType.onMove = function(npc, creature, fromPosition, toPosition) npcHandler:onMove(npc, creature, fromPosition, toPosition) end npcType.onSay = function(npc, creature, type, message) npcHandler:onSay(npc, creature, type, message) end npcType.onCloseChannel = function(npc, creature) npcHandler:onCloseChannel(npc, creature) end local function creatureSayCallback(npc, creature, type, message) local player = Player(creature) if not player then return false end if message:lower() == "abre-te sésamo" then local topos = Position(32311, 11005, 6) player:getPosition():sendMagicEffect(CONST_ME_TELEPORT) player:teleportTo(topos) topos:sendMagicEffect(CONST_ME_TELEPORT) end return true end keywordHandler:addKeyword({ "abre-te sésamo" }, StdModule.say, {npcHandler = npcHandler, text = "Diga a palavra mágica e será transportado!"}) npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback) npcType:register(npcConfig) Eu sou um entusiasta da programação apaixonado por ajudar a comunidade open source a crescer. Sempre em busca de novos desafios e oportunidades para contribuir com meu código. #OpenSource #Programação #Contribuição
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.