Postado Fevereiro 28, 2014 11 anos Estava fazendo o script, por isso da pergunta .. O script ficou 'um pouco' extenso, mas funcional. Substitua o conteúdo do arquivo xml do npc, por esse: <?xml version="1.0" encoding="UTF-8"?> <npc name="Captain Eric" script="data/npc/scripts/captain.lua" walkinterval="2000" floorchange="0"> <health now="150" max="150"/> <look type="97" head="96" body="58" legs="3" feet="114" addons="0"/> <parameters> <parameter key="message_greet" value="Hi |PLAYERNAME|. I send you to gloria, hydra lair, azeroth, sand trap, tiquanda, zatur or liberty bay."/> </parameters> </npc> Agora, crie um novo arquivo .lua em Data/Npcs/Scripts, e o nomeie de captain. coloque isso dentro: local keywordHandler = KeywordHandler:new() local npcHandler = NpcHandler:new(keywordHandler) NpcSystem.parseParameters(npcHandler) 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 talkUser = NPCHANDLER_CONVBEHAVIOR == CONVERSATION_DEFAULT and 0 or cid local position = { tiquanda = {x= 161, y=191, z=6}, libertybay = {x= 304, y=135, z=6}, hydralair = {x= 887, y=1004, z=7}, gloria = {x= 776, y=792, z=7}, azeroth = {x= 712, y=1001, z=6}, sandtrap = {x= 283, y=409, z=6}, zatur = {x= 1203, y=1085, z=5} } local msgerror = 'Necessário premium account.' if(msgcontains(msg, 'tiquanda')) then if getPlayerVipTime(cid) < 1 then doPlayerSendTextMessage(cid, MESSAGE_FIRST, msgerror) else doTeleportThing(cid, position.tiquanda) doSendMagicEffect(getPlayerPosition(cid), math.random(1, 23)) return true end elseif (msgcontains(msg, 'liberty bay')) then if getPlayerVipTime(cid) < 1 then doPlayerSendTextMessage(cid, MESSAGE_FIRST, msgerror) else doTeleportThing(cid, position.libertybay) doSendMagicEffect(getPlayerPosition(cid), math.random(1, 23)) return true end elseif (msgcontains(msg, 'hydralair')) then if getPlayerVipTime(cid) < 1 then doPlayerSendTextMessage(cid, MESSAGE_FIRST, msgerror) else doTeleportThing(cid, position.hydralair) doSendMagicEffect(getPlayerPosition(cid), math.random(1, 23)) return true end elseif (msgcontains(msg, 'gloria')) then if getPlayerVipTime(cid) < 1 then doPlayerSendTextMessage(cid, MESSAGE_FIRST, msgerror) else doTeleportThing(cid, position.gloria) doSendMagicEffect(getPlayerPosition(cid), math.random(1, 23)) return true end elseif (msgcontains(msg, 'azeroth')) then if getPlayerVipTime(cid) < 1 then doPlayerSendTextMessage(cid, MESSAGE_FIRST, msgerror) else doTeleportThing(cid, position.azeroth) doSendMagicEffect(getPlayerPosition(cid), math.random(1, 23)) return true end elseif (msgcontains(msg, 'sandtrap')) then if getPlayerVipTime(cid) < 1 then doPlayerSendTextMessage(cid, MESSAGE_FIRST, msgerror) else doTeleportThing(cid, position.sandtrap) doSendMagicEffect(getPlayerPosition(cid), math.random(1, 23)) return true end elseif (msgcontains(msg, 'zatur')) then if getPlayerVipTime(cid) < 1 then doPlayerSendTextMessage(cid, MESSAGE_FIRST, msgerror) else doTeleportThing(cid, position.zatur) doSendMagicEffect(getPlayerPosition(cid), math.random(1, 23)) return true end end return true end npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback) npcHandler:addModule(FocusModule:new())
Postado Fevereiro 28, 2014 11 anos Autor Estava fazendo o script, por isso da pergunta .. O script ficou 'um pouco' extenso, mas funcional. Substitua o conteúdo do arquivo xml do npc, por esse: <?xml version="1.0" encoding="UTF-8"?> <npc name="Captain Eric" script="data/npc/scripts/captain.lua" walkinterval="2000" floorchange="0"> <health now="150" max="150"/> <look type="97" head="96" body="58" legs="3" feet="114" addons="0"/> <parameters> <parameter key="message_greet" value="Hi |PLAYERNAME|. I send you to gloria, hydra lair, azeroth, sand trap, tiquanda, zatur or liberty bay."/> </parameters> </npc> Agora, crie um novo arquivo .lua em Data/Npcs/Scripts, e o nomeie de captain. coloque isso dentro: local keywordHandler = KeywordHandler:new() local npcHandler = NpcHandler:new(keywordHandler) NpcSystem.parseParameters(npcHandler) 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 talkUser = NPCHANDLER_CONVBEHAVIOR == CONVERSATION_DEFAULT and 0 or cid local position = { tiquanda = {x= 161, y=191, z=6}, libertybay = {x= 304, y=135, z=6}, hydralair = {x= 887, y=1004, z=7}, gloria = {x= 776, y=792, z=7}, azeroth = {x= 712, y=1001, z=6}, sandtrap = {x= 283, y=409, z=6}, zatur = {x= 1203, y=1085, z=5} } local msgerror = 'Necessário premium account.' if(msgcontains(msg, 'tiquanda')) then if getPlayerVipTime(cid) < 1 then doPlayerSendTextMessage(cid, MESSAGE_FIRST, msgerror) else doTeleportThing(cid, position.tiquanda) doSendMagicEffect(getPlayerPosition(cid), math.random(1, 23)) return true end elseif (msgcontains(msg, 'liberty bay')) then if getPlayerVipTime(cid) < 1 then doPlayerSendTextMessage(cid, MESSAGE_FIRST, msgerror) else doTeleportThing(cid, position.libertybay) doSendMagicEffect(getPlayerPosition(cid), math.random(1, 23)) return true end elseif (msgcontains(msg, 'hydralair')) then if getPlayerVipTime(cid) < 1 then doPlayerSendTextMessage(cid, MESSAGE_FIRST, msgerror) else doTeleportThing(cid, position.hydralair) doSendMagicEffect(getPlayerPosition(cid), math.random(1, 23)) return true end elseif (msgcontains(msg, 'gloria')) then if getPlayerVipTime(cid) < 1 then doPlayerSendTextMessage(cid, MESSAGE_FIRST, msgerror) else doTeleportThing(cid, position.gloria) doSendMagicEffect(getPlayerPosition(cid), math.random(1, 23)) return true end elseif (msgcontains(msg, 'azeroth')) then if getPlayerVipTime(cid) < 1 then doPlayerSendTextMessage(cid, MESSAGE_FIRST, msgerror) else doTeleportThing(cid, position.azeroth) doSendMagicEffect(getPlayerPosition(cid), math.random(1, 23)) return true end elseif (msgcontains(msg, 'sandtrap')) then if getPlayerVipTime(cid) < 1 then doPlayerSendTextMessage(cid, MESSAGE_FIRST, msgerror) else doTeleportThing(cid, position.sandtrap) doSendMagicEffect(getPlayerPosition(cid), math.random(1, 23)) return true end elseif (msgcontains(msg, 'zatur')) then if getPlayerVipTime(cid) < 1 then doPlayerSendTextMessage(cid, MESSAGE_FIRST, msgerror) else doTeleportThing(cid, position.zatur) doSendMagicEffect(getPlayerPosition(cid), math.random(1, 23)) return true end end return true end npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback) npcHandler:addModule(FocusModule:new()) Amigo eu falo com o npc e ele nao responde o player `FALA HI, NOME DO LUGAR QUE QUER IR, E ELE NAO RESPONDE NADA` Logo isso da um erro no distro, vou postar a seguir. Como arrumo isso agora?
Postado Fevereiro 28, 2014 11 anos local keywordHandler = KeywordHandler:new() local npcHandler = NpcHandler:new(keywordHandler) NpcSystem.parseParameters(npcHandler) 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 talkUser = NPCHANDLER_CONVBEHAVIOR == CONVERSATION_DEFAULT and 0 or cid local position = { tiquanda = {x= 161, y=191, z=6}, libertybay = {x= 304, y=135, z=6}, hydralair = {x= 887, y=1004, z=7}, gloria = {x= 776, y=792, z=7}, azeroth = {x= 712, y=1001, z=6}, sandtrap = {x= 283, y=409, z=6}, zatur = {x= 1203, y=1085, z=5} } local msgerror = 'Necessário premium account.' if(msgcontains(msg, 'tiquanda')) then if getPlayerPremiumDays(cid) < 1 then doPlayerSendTextMessage(cid, MESSAGE_FIRST, msgerror) else doTeleportThing(cid, position.tiquanda) doSendMagicEffect(getPlayerPosition(cid), math.random(1, 23)) return true end elseif (msgcontains(msg, 'liberty bay')) then if getPlayerPremiumDays(cid) < 1 then doPlayerSendTextMessage(cid, MESSAGE_FIRST, msgerror) else doTeleportThing(cid, position.libertybay) doSendMagicEffect(getPlayerPosition(cid), math.random(1, 23)) return true end elseif (msgcontains(msg, 'hydralair')) then if getPlayerPremiumDays(cid) < 1 then doPlayerSendTextMessage(cid, MESSAGE_FIRST, msgerror) else doTeleportThing(cid, position.hydralair) doSendMagicEffect(getPlayerPosition(cid), math.random(1, 23)) return true end elseif (msgcontains(msg, 'gloria')) then if getPlayerPremiumDays(cid) < 1 then doPlayerSendTextMessage(cid, MESSAGE_FIRST, msgerror) else doTeleportThing(cid, position.gloria) doSendMagicEffect(getPlayerPosition(cid), math.random(1, 23)) return true end elseif (msgcontains(msg, 'azeroth')) then if getPlayerPremiumDays(cid) < 1 then doPlayerSendTextMessage(cid, MESSAGE_FIRST, msgerror) else doTeleportThing(cid, position.azeroth) doSendMagicEffect(getPlayerPosition(cid), math.random(1, 23)) return true end elseif (msgcontains(msg, 'sandtrap')) then if getPlayerPremiumDays(cid) < 1 then doPlayerSendTextMessage(cid, MESSAGE_FIRST, msgerror) else doTeleportThing(cid, position.sandtrap) doSendMagicEffect(getPlayerPosition(cid), math.random(1, 23)) return true end elseif (msgcontains(msg, 'zatur')) then if getPlayerPremiumDays(cid) < 1 then doPlayerSendTextMessage(cid, MESSAGE_FIRST, msgerror) else doTeleportThing(cid, position.zatur) doSendMagicEffect(getPlayerPosition(cid), math.random(1, 23)) return true end end return true end npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback) npcHandler:addModule(FocusModule:new())
Postado Fevereiro 28, 2014 11 anos Autor Funcionous agora muito obrigado! Queria saber tipo, onde edito esse mesmo script para colocar em outros npcs de barco? Pode explicar ? REP+
Postado Fevereiro 28, 2014 11 anos Solução No início do script, há uma tabela com as coordenadas das cidades. local position = { tiquanda = {x= 161, y=191, z=6}, libertybay = {x= 304, y=135, z=6}, hydralair = {x= 887, y=1004, z=7}, gloria = {x= 776, y=792, z=7}, azeroth = {x= 712, y=1001, z=6}, sandtrap = {x= 283, y=409, z=6}, zatur = {x= 1203, y=1085, z=5} } Explicando.. Por exemplo, você gostaria de adicionar uma nova cidade no script, chamada Londres, com as coordenadas x=0, y=1, z=2 : londres = {x= 0, 1, z=2}, viu? bastaria criar uma nova linha, e adiciona-la no meio das outras da tabela (acima da última), colocando o nome da cidade, pra ficar mais fácil de ser reconhecida, e suas coordenadas. Após tê-la adicionada na tabela, procure por: local msgerror = 'Necessário premium account.' E adicione isso, logo abaixo: elseif (msgcontains(msg, 'londres')) then if getPlayerPremiumDays(cid) < 1 then doPlayerSendTextMessage(cid, MESSAGE_FIRST, msgerror) else doTeleportThing(cid, position.londres) doSendMagicEffect(getPlayerPosition(cid), math.random(1, 23)) return true end Colocando o nome da cidade, aqui: elseif (msgcontains(msg, 'londres')) then e aqui: doTeleportThing(cid, position.londres) Ah, e disponha. É um prazer ajudar. Editado Fevereiro 28, 2014 11 anos por Nogard (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.