Ir para conteúdo
  • 0

Problema de MSG


Luga03

Pergunta

Eai pessoal, criei um npc só que está dando um problema, ele quando fala hi, ele manda uma mensagem de message_greet, dai tem que falar help, ai depois que fala help, recebe uma mensagem, e tem que falar outra coisa, só que a eu falo e não acontece nada! Exemplo:

PLAYER: Hi
NPC: |PLAYERNAME|? It's been a long time! or maybe it's the first time we meet? Time keeps fooling me... so, how Mougter can {help} you, young soul?
PLAYER: help
NPC: So you want to help? Can I turn it into a {Deighter}, {Flgheter} and {Flwoew}.You will want to be that Monster?
PLAYER: Deighter
NPC: (Aparti daqui não acontece mais nada)

NPC:

 

<?xml version="1.0" encoding="UTF-8"?>
<npc name="Arceus" script="Arceus.lua" walkinterval="2000" floorchange="0">
<health now="100" max="100"/>
<look type="128" head="17" body="54" legs="114" feet="0" addons="2"/>
<parameters>
<parameter key="message_greet" value="|PLAYERNAME|? It's been a long time! or maybe it's the first time we meet? Time keeps fooling me... so, how Mougtercan {help} you, young soul?"/>
</parameters>
</npc>

 



LUA:

 

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 talkUser = NPCHANDLER_CONVBEHAVIOR == CONVERSATION_DEFAULT and 0 or cid
 
if (msgcontains(msg, 'help')) and talkState[talkUser] == 0 then
selfSay('So you want to help? Can I turn it into a {Deighter}, {Flgheter} and {Flwoew}.You will want to be that Monster?', cid)
talkState[talkUser] = 1
if (msgcontains(msg, 'Deighter')) and talkState[talkUser] == 1 then
talkState[talkUser] = 0
setMonsterClass(cid, 2)
selfSay('You have just become a Deighter!', cid)
elseif (msgcontains(msg, 'Flgheter')) and talkState[talkUser] == 1 then
talkState[talkUser] = 0
setMonsterClass(cid, 5)
selfSay('You have just become a Flgheter!', cid)
elseif (msgcontains(msg, 'Flwoew')) and talkState[talkUser] == 1 then
talkState[talkUser] = 0
setMonsterClass(cid, 8)
selfSay('You have just become a Flwoew!', cid)
end
end
return true
end
 
npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback) 
npcHandler:addModule(FocusModule:new())

 

 

 

tem como vcs ajudarem pfv???

Editado por Zet0N0Murmurouu
Link para o comentário
Compartilhar em outros sites

6 respostass a esta questão

Posts Recomendados

  • 0

 

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 talkUser, msg  = NPCHANDLER_CONVbehavior == CONVERSATION_DEFAULT and 0 or cid, msg:lower()
local tabblem = {["deighter"] = 2,["flgheter"] = 5,["flwoew"] = 8}  
if isInArray({'help', 'ajuda', 'helper', 'ajudar'}, msg) then
selfSay('So you want to help? Can I turn it into a {deighter}, {flgheter} and {flwoew}.You will want to be that Monster?', cid)
talkState[talkUser] = 1
elseif talkState[talkUser] == 1 then
if tabblem[msg] then
setMonsterClass(cid, tabblem[msg])
selfSay('You have just become a '..msg..'!', cid)
else
selfSay('wrong name!', cid)
end
end
return true
end
npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())
Link para o comentário
Compartilhar em outros sites

  • 0
  • Diretor

Tente esse amigo:

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 talkUser = NPCHANDLER_CONVBEHAVIOR == CONVERSATION_DEFAULT and 0 or cid
 
if (msgcontains(msg, 'help')) then
selfSay('So you want to help? Can I turn it into a {Deighter}, {Flgheter} and {Flwoew}.You will want to be that Monster?', cid)
elseif (msgcontains(msg, 'Deighter')) then
selfSay('You have just become a Deighter!', cid)
elseif (msgcontains(msg, 'Flgheter')) then
selfSay('You have just become a Flgheter!', cid)
elseif (msgcontains(msg, 'Flwoew')) then
selfSay('You have just become a Flwoew!', cid)
end
end
return true
end
 
npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())
Link para o comentário
Compartilhar em outros sites

  • 0

Você apenas mudou um if para elseif e ainda esqueceu de tirar um end, mas mesmo assim vo ajeitar oq vc tentou fazer e ver aq. e também não funcionou!

Dei uma adaptada e identada no código só que quando fala help, o npc não responde!

 

 
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 talkUser = NPCHANDLER_CONVBEHAVIOR == CONVERSATION_DEFAULT and 0 or cid
 
if (msgcontains(msg, 'help')) and talkState[talkUser] == 0 then
selfSay('So you want to help? Can I turn it into a {Deighter}, {Flgheter} and {Flwoew}.You will want to be that Monster?', cid)
talkState[talkUser] = 1
if (msgcontains(msg, 'Deighter')) and talkState[talkUser] == 1 then
talkState[talkUser] = 0
setMonsterClass(cid, 2)
selfSay('You have just become a Deighter!', cid)
elseif (msgcontains(msg, 'Flgheter')) and talkState[talkUser] == 1 then
talkState[talkUser] = 0
setMonsterClass(cid, 5)
selfSay('You have just become a Flgheter!', cid)
elseif (msgcontains(msg, 'Flwoew')) and talkState[talkUser] == 1 then
talkState[talkUser] = 0
setMonsterClass(cid, 8)
selfSay('You have just become a Flwoew!', cid)
end
end
return true
end
 
npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback) 
npcHandler:addModule(FocusModule:new())

 

 

A droga o editor, tira os espaços da identação! affffff

Editado por Zet0N0Murmurouu
Link para o comentário
Compartilhar em outros sites

  • 0
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 talkUser, msg  = NPCHANDLER_CONVbehavior == CONVERSATION_DEFAULT and 0 or cid, msg:lower()
local tabblem = {["deighter"] = 2,["flgheter"] = 5,["flwoew"] = 8}  
if isInArray({'help', 'ajuda', 'helper', 'ajudar'}, msg) then
selfSay('So you want to help? Can I turn it into a {deighter}, {flgheter} and {flwoew}.You will want to be that Monster?', cid)
talkState[talkUser] = 1
elseif talkState[talkUser] == 1 then
if tabblem[msg] then
setMonsterClass(cid, tabblem[msg])
selfSay('You have just become a '..msg..'!', cid)
else
selfSay('wrong name!', cid)
end
end
return true
end
npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())

 

Funcionou perfeitamente! te amo vlw :)

Link para o comentário
Compartilhar em outros sites

Visitante
Este tópico está impedido de receber novos posts.
×
×
  • Criar Novo...