Ajuda em npc
Pessoal sou iniciante em script eu montei esse ai abaixo e queria saber se tem algo errado.
Tambem queria sabe se o talkState funciona dese jeito que puis ou nao
Explicacão do npc:
O npc fala (Voce deve levar 4 {dragon ham} ao mendigo em frente ao dp.{ok}?)
quando o player manda ok ele não manda a mensagen (selfSay('Pode ir ele esta a sua espera!!', cid))
Script :
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, 'missao') then
talkState[talkUser] = 0
if getPlayerStorageValue(cid,7700) == 1 then
selfSay('Voce deve levar 4 {dragon ham} ao mendigo em frente ao dp.{ok}?', cid)
setPlayerStorageValue(cid,7700,2)
talkState[talkUser] = 1
elseif talkState[talkUser] == 1 then
if msgcontains(msg, 'ok') then
selfSay('Pode ir ele esta a sua espera!!', cid)
talkState[talkUser] = 0
end
else
selfSay('Ah seu fanfarao saia daqui', cid)
end
if getPlayerStorageValue(cid,7700) == 3 then
selfSay('Voce deve levar 4 {health potion} ao mendigo em frente a arena.{ok}?', cid)
setPlayerStorageValue(cid,7700,4)
talkState[talkUser] = 1
elseif talkState[talkUser] == 1 then
if msgcontains(msg, 'ok') then
selfSay('Pode ir ele esta a sua espera!!', cid)
end
else
selfSay('Ah seu fanfarao saia daqui', cid)
end
else
if msgcontains(msg, 'no') then
selfSay('Então porque veio aqui ?', cid)
end
end
return true
end
npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())
Creditos :
50% Meu por iniciar
15% Do Vodkart por dar uma ajuda
35% Pra quem consegui me ajuda
rep+ pra quem ajudar.