Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local keywordHandler = KeywordHandler:new()
- local npcHandler = NpcHandler:new(keywordHandler)
- NpcSystem.parseParameters(npcHandler)
- local Topic = {}
- 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 thinkCallback(cid)
- if math.random(300) == 1 then
- npcHandler:say("Leave this island by speaking to me!")
- end
- return true
- end
- function creatureSayCallback(cid, type, msg)
- if (msgcontains(msg, "hello") or msgcontains(msg, "hi")) and (not npcHandler:isFocused(cid)) then
- npcHandler:say(getPlayerSex(cid) == 0 and "Well hello there, lovely lady! Are you ready to leave this island? {Yes} or {No}." or "Hello there, are you ready to leave this island? {Yes} or {No}.", cid)
- Topic[cid] = 1
- npcHandler:addFocus(cid)
- elseif(not npcHandler:isFocused(cid)) then
- return false
- elseif msgcontains(msg, "bye") or msgcontains(msg, "farewell") and npcHandler:isFocused(cid) then
- npcHandler:say("Good bye.", cid, TRUE)
- Topic[cid] = nil
- npcHandler:releaseFocus(cid)
- elseif Topic[cid] == 1 then
- if msgcontains(msg, "yes") then
- npcHandler:say("Set the sails!", cid)
- doTeleportThing(cid, {x = 100, y = 100, z = 7}, true)
- Topic[cid] = 0
- elseif msgcontains(msg, "no") then
- npcHandler:say("Then not.", cid)
- Topic[cid] = 0
- end
- end
- return true
- end
- npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
- npcHandler:setMessage(MESSAGE_WALKAWAY, "How rude!")
- npcHandler:setCallback(CALLBACK_ONTHINK, thinkCallback)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement