Ancores
Active Member
- Joined
- Jan 17, 2010
- Messages
- 538
- Reaction score
- 28
I'm a total noob in scripting npcs and can't get this to work lol.
I want to change the talk_state when saying "huhu" to the npc to talk_state 50 and then if I say "bye" or leave the npcs the talk_state should be changed back to 0 so I can say huhu again.
When I say "hi", "huhu" the first time it works and changes to talk_state 50, but then if I say "bye" and then "hi", "huhu" it doesn't work because the talk_state hasn't changed.
But if I say something (just some random letters) when he isn't focused (after saying bye) the talk_state changes back to 0 oO
I want to change the talk_state when saying "huhu" to the npc to talk_state 50 and then if I say "bye" or leave the npcs the talk_state should be changed back to 0 so I can say huhu again.
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)
talk_state = 0
end
function onCreatureSay(cid, type, msg) npcHandler:onCreatureSay(cid, type, msg) end
function onThink() npcHandler:onThink() end
function creatureSayCallback(cid, type, msg)
local talkUser = NPCHANDLER_CONVBEHAVIOR == CONVERSATION_DEFAULT and 0 or cid
if(not npcHandler:isFocused(cid)) then
talk_state = 0
return false
end
if msgcontains(msg, 'huhu') and talk_state ~= 50 then
npcHandler:say("Lalala", cid)
talk_state = 50
end
return true
end
npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())
When I say "hi", "huhu" the first time it works and changes to talk_state 50, but then if I say "bye" and then "hi", "huhu" it doesn't work because the talk_state hasn't changed.
But if I say something (just some random letters) when he isn't focused (after saying bye) the talk_state changes back to 0 oO
Last edited: