NPC don't say "hi"
Why when I try to start a conversation to the NPC he does not say "hi"?
- - - Updated - - -
I modified the script, but now he only answers my "hi". After greeting he continues the conversation.
Help-me with this script!
Why when I try to start a conversation to the NPC he does not say "hi"?
Code:
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)
if(not npcHandler:isFocused(cid)) then
return false
end
local talkUser = NPCHANDLER_CONVBEHAVIOR == CONVERSATION_DEFAULT and 0 or cid
if(msgcontains(msg, "hi") or msgcontains(msg, "oi")) then
if getPlayerStorageValue (cid, ENGLISH) == TRUE then
selfSay("Hello. I am the guardian of this small town and I'm having some problems, if you help me I will give you a reward.", cid)
talkState[talkUser] = 1
else
selfSay("Olá. Sou o guardião desta pequena cidade e estou com alguns problemas, se quiser me ajudar eu irei lhe dar uma recompensa.", cid)
talkState[talkUser] = 1
end
end
return TRUE
end
function onThink() npcHandler:onThink() end
local shopModule = ShopModule:new()
npcHandler:addModule(shopModule)
function creatureSayCallback(cid, type, msg)
if(msgcontains(msg, "help") or msgcontains(msg, "ajudar")) then
if getPlayerStorageValue (cid, ENGLISH) == TRUE then
selfSay("I have a debt with a senior this small town. The name of this old and he is Olavio want three chicken feathers. Take him and seek reward with me. You want to do this for me?", cid)
talkState[talkUser] = 1
else
selfSay("Tenho uma dívida com um idoso desta pequena cidade. O nome deste idoso é Olavio e ele quer três penas de galinha. Leve para ele e busque a recompensa comigo. Você quer fazer isto por mim?", cid)
talkState[talkUser] = 1
end
elseif(msgcontains(msg, "yes") or msgcontains(msg, "sim")) then
if(talkState[talkUser] == 1) then
if getPlayerStorageValue (cid, ENGLISH) == TRUE then
selfSay("I'll be waiting for you with your reward!", cid)
else
selfSay("Estarei lhe esperando com sua recompensa!", cid)
end
setPlayerStorageValue(cid, 900001, 1)
end
talkState[talkUser] = 0
elseif(msgcontains(msg, "no") or msgcontains(msg, "nao")) and isInArray({1}, talkState[talkUser]) == TRUE then
if getPlayerStorageValue (cid, ENGLISH) == TRUE then
selfSay("Ok then.", cid)
else
selfSay("Você que sabe...", cid)
end
talkState[talkUser] = 0
end
return TRUE
end
npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())
- - - Updated - - -
I modified the script, but now he only answers my "hi". After greeting he continues the conversation.
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)
local talkUser = NPCHANDLER_CONVBEHAVIOR == CONVERSATION_DEFAULT and 0 or cid
if msgcontains(msg, "hi", "oi") then
if getLanguage(cid) == 1 then
selfSay("Hello. I am the guardian of this small town and I'm having some problems, if you {help} me I will give you a reward.", cid)
else
selfSay("Olá. Sou o guardião desta pequena cidade e estou com alguns problemas, se quiser me {ajudar} eu irei lhe dar uma recompensa.", cid)
end
talkState[talkUser] = 1
end
if(talkState[talkUser] == 1) and (msgcontains(msg, "help", "ajudar")) then
if getLanguage(cid) == 1 then
selfSay("I have a debt with a senior this small town. The name of this old and he is Olavio want three chicken feathers. Take him and seek reward with me. You want to do this for me?", cid)
else
selfSay("Tenho uma dívida com um idoso desta pequena cidade. O nome deste idoso é Olavio e ele quer três penas de galinha. Leve para ele e busque a recompensa comigo. Você quer fazer isto por mim?", cid)
end
talkState[talkUser] = 2
elseif(talkState[talkUser] == 2) and (msgcontains(msg, "yes", "sim")) then
if getLanguage(cid) == 1 then
selfSay("I'll be waiting for you with your reward!", cid)
else
selfSay("Estarei lhe esperando com sua recompensa!", cid)
end
setPlayerStorageValue(cid, 900001, 1)
talkState[talkUser] = 0
elseif (talkState[talkUser] == 2) and (msgcontains(msg, "no", "nao")) then
if getLanguage(cid) == 1 then
selfSay("Ok then.", cid)
else
selfSay("Você que sabe...", cid)
end
talkState[talkUser] = 0
elseif (talkState[talkUser] == 2) and (msgcontains(msg, "bye", "tchau")) then
if getLanguage(cid) == 1 then
selfSay("Goodbye!", cid)
else
selfSay("Adeus!", cid)
end
talkState[talkUser] = 0
end
end
function onThink() npcHandler:onThink() end
npcHandler:addModule(FocusModule:new())
Help-me with this script!