• There is NO official Otland's Discord server and NO official Otland's server list. The Otland's Staff does not manage any Discord server or server list. Moderators or administrator of any Discord server or server lists have NO connection to the Otland's Staff. Do not get scammed!

Npc Script for a long story

D_Evans89

Member
Joined
Dec 3, 2014
Messages
175
Reaction score
12
I have searched and haven't found something that is either for my version or that works.

I am using TFS 0.2.13

I need a script that reacts like this when you say "Hi" :

NPC: example example example example.....
pause
NPC: example example example....
pause
NPC: example example example example....
pause
NPC: Are you sure you want to take on this task?

PLAYER: Yes

NPC: Great, find me the item and bring it back to me.
 
I have searched and haven't found something that is either for my version or that works.

I am using TFS 0.2.13

I need a script that reacts like this when you say "Hi" :

NPC: example example example example.....
pause
NPC: example example example....
pause
NPC: example example example example....
pause
NPC: Are you sure you want to take on this task?

PLAYER: Yes

NPC: Great, find me the item and bring it back to me.
does TFS 0.2.13 have function called addEvent()?
 
I think so. This is the script i currently have, i tweaked it according to a post i saw but it stops at the first message and doesn't continue talking and it states it in regular chat and not npc chat.

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)     npcHandler:onCreatureSay(cid, type, msg)     end
function onThink()         npcHandler:onThink()           end
local storage = 5001
function creatureSayCallback(cid, type, msg)

     local talkUser = NPCHANDLER_CONVBEHAVIOR == CONVERSATION_DEFAULT and 0 or cid

     if not npcHandler:isFocused(cid) then
         if msg == "hi" or msg == "hello" then
             if getPlayerStorageValue(cid, storage) == -1 then
                 selfSay("I created this prison for myself to keep me safe, the creatures are unable to penatrate the magical barriers.", cid)
                 wait(1000)
                 selfSay("I have been working on a powerful morphing potion and things went terribly wrong.", cid)
                 wait(1000)
                 selfSay("The potion was accidently mixed into the punch at a party my colleagues had, now they are Werewolves.", cid)
                 wait(1000)
                 selfSay(" There is a place in a desert town that might hold the solution, in those caves lie a priceless item that I want. Should you bring me this item, you will prove yourself strong enough to visit what I once called home.", cid)
                 wait(1000)
                 selfSay("Are you sure you want to take on this task?", cid)
                 talkState[talkUser] = 1
             elseif getPlayerStorageValue(cid, storage) == 1 then
                 selfSay("Did you find the rune?", cid)
                 talkState[talkUser] = 1
             else
                 selfSay("Thanks again for finding the rune.", cid)
             end
             npcHandler:addFocus(cid)
         else
             return false
         end
     end

     if msgcontains(msg, "yes") and talkState[talkUser] == 1 then
         if getPlayerStorageValue(cid, storage) == -1 then
             selfSay("Thanks alot, come back when you have it.", cid)
             setPlayerStorageValue(cid, storage, 1)
         else
             if doPlayerRemoveItem(cid, 2348, 1) then
                 selfSay("This makes Zafmak very happy, you now have access to my home island. You might as well exterminate the island since there is no cure for this batch. Just be carefull, the Werewolves are very territorial and anger easy.", cid)
                 doPlayerAddItem(cid, 2160, 1)
                 doPlayerAddExp(cid, 15000)
                 setPlayerStorageValue(cid, 5009, 2)
                 setPlayerStorageValue(cid, storage, 2)
             else
                 selfSay("You don't have it.", cid)
             end
         end
         talkState[talkUser] = 0
     elseif msgcontains(msg, "no") and talkState[talkUser] == 1 then
         selfSay("Ok then.", cid)
         talkState[talkUser] = 0
     elseif msgcontains(msg, "bye") then
         selfSay("Bye.", cid)
         npcHandler:releaseFocus(cid)
     end
     return true
end
npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
 
Back
Top