• 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!
  • 2026 staff recruitment is open! Check it out and consider applying!

Requesting NPC

Klank

Althea ¤ A New World Developer
Joined
Feb 21, 2008
Messages
1,113
Reaction score
705
Location
Norway
Requesting a mission npc for TFS 0.3 (client 10.10)

NPC: Hello |playername|, could you help me? (help)
Player: help
NPC: I lost a "ring" that have a sentimental value for me in this caves of ugly worms.. Could you please get it for me?(yes) // An item (ID)
Player: yes
NPC: Thank you, ill be waiting.

~Get item from quest~
Player: Hi
NPC: Hello again! Did you find the ring? (ring)
Player: ring // Takes the ring from container.
NPC: Take this fine backpack as a reward. Its made of minotaur leather so it should hold! // Obtains citizen bp addon//

~talk after mission done~
Player: Hi
NPC: Hello |playername|, my brave hero!


Hope anyone can make this one :))
 
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 = 5201

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('Hello '..getPlayerName(cid)..', could you {help} me?', cid)
                 talkState[talkUser] = 1
             elseif(getPlayerStorageValue(cid, storage) == 1) then
                 selfSay('Did you find the ring?', cid)
                 talkState[talkUser] = 2
             else
                 selfSay('Hello '..getPlayerName(cid)..', my brave hero!', cid)
             end
             npcHandler:addFocus(cid)
         else
             return false
         end
     end

     if(msgcontains(msg, 'help') and talkState[talkUser] == 1) then
         selfSay(' I lost a ring that has a sentimental value for me in this caves of ugly worms.. Could you please get it for me?', cid)
         talkState[talkUser] = 2
     elseif(msgcontains(msg, 'yes') and talkState[talkUser] == 2) then
         if(getPlayerStorageValue(cid, storage) == -1) then
             selfSay('Thank you, I\'ll be waiting.', cid)
             setPlayerStorageValue(cid, storage, 1)
         else
             if(doPlayerRemoveItem(cid, 2179, 1)) then
                 selfSay('Take this fine backpack as a reward. Its made of minotaur leather so it should hold!', cid)
                 doPlayerAddItem(cid, 3960, 1)
                 setPlayerStorageValue(cid, storage, 2)
             else
                 selfSay('You don\'t have it.', cid)
             end
         end
         talkState[talkUser] = 0
     elseif(msgcontains(msg, 'no') and isInArray({1,2}, talkState[talkUser])) 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)
 
Last edited:
Back
Top