• 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!

Need two NPC with missions

BugaS

Donżuan
Joined
Mar 12, 2009
Messages
1,219
Reaction score
9
Location
NYC
Hello guys!

I want to make a NPC with missions for TFS 0.4. How it should look?

First NPC:

Player: hi
NPC: Hello! So you want to be my friend?
Player: yes
NPC: Okay, but you need to make something for me first. If you are ready, say {mission}
Player: mission
NPC: You must find and kill 250 Fighters first, then back to me for the second mission

After that, player will kill 250 monsters (would be cool, if the system will show him "You killed 20/250 Fighters)

After that player back to the NPC:

Player: hi
NPC; Did you kill 250 fighters?
Player: yes
NPC: Ok! My son forget his books. Can you find him and give it to him?
Player: yes

Now, the NPC is giving the item to player. Player need to find second NPC Son.

And it should be look like that:
Player: hi
NPC: Have you got my books?
Player: yes
NPC: Thanks! Go to my dad and tell him that i love him
And the player is going back to the first NPC and:

Player: Hi
NPC: You gave the books of my son?
Player: yes
NPC: Ok! Thank you very much! Now, I can be your friend. Take this and use it on yourself. I will help you when you call me!

And the NPC give item to the player.

And that's it :D But it should be based on storages. For example, the NPC Son should check if the first NPC gave the storage to the player when gave books, ofc he need to check the item and remove it.

Can anyone help me with that? Thanks a lot!
 
Last edited:
I'm at work, so I'll just do some stuff from memory.
Lua:
-- this is how to check and set a players storage value
getPlayerStorageValue(uid, key)
setPlayerStorageValue(uid, key)

-- this will make your current storage value 0, but only if it's -1 or below.
if getPlayerStorageValue(cid, key) < 0 then
    setPlayerStorageValue(cid, key)
end

-- this will find the current storage value, and add 1 to it.
setPlayerStorageValue(cid, getPlayerStorageValue(cid, key) + 1)


-- this is a code snippet to place into an npc
-- it will check storage values, and allow you to create a conversation
-- Note: Not fully functional as-is. It is a demonstration of what is possible.
elseif msgcontains(msg, "mission") and talkState[talkUser] == 0 and getPlayerStorageValue(cid, key_1) < 0 then
    selfSay("Would like you like to start xxxx task?", cid)
    talkState[talkUser] = 1
elseif msgcontains(msg, "yes") and talkState[talkUser] == 1 then
    selfSay("Great! Talk to me about your mission when your finished.", cid)
    setPlayerStorageValue(cid, key_1, 0)
    setPlayerStorageValue(cid, key_2, 0)
    talkState[talkUser] = 0

elseif msgcontains(msg, "mission") and talkState[talkUser] == 0 and getPlayerStorageValue(cid, key_1) == 0 then
    selfSay("Have you completed your task?", cid)
    talkState[talkUser] = 2
elseif msgcontains(msg, "yes") and talkState[talkUser] == 2 then
    if getPlayerStorageValue(cid, key_ 2) == 250 then
        selfSay("Great! Now please speak with NPC 2. He will have a mission for you.", cid)
        setPlayerStorageValue(cid, key_1, 1)
    else
        selfSay("You haven't completed your mission. Come back when you have.", cid)
    end
    talkState[talkUser] = 0


-- extra code snippet for a second NPC
-- Again, mostly functional, but requires a bit of editing, such as the storages values.
elseif msgcontains(msg, "mission") and talkState[talkUser] == 0 and getPlayerStorageValue(cid, key_1) < 1 then
    selfSay("Hmm? I have nothing for you.", cid)
    talkState[talkUser] = 0
elseif msgcontains(msg, "mission") and talkState[talkUser] == 0 and getPlayerStorageValue(cid, key_1) == 1 then
    selfSay("Would like you like to start yyyy task?", cid)
    talkState[talkUser] = 1
Here is some other links you may find useful for what your trying to do.
Simple Npc
Kill Creature Gain Storage Value

Good luck. :p
 
Back
Top