• 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 QUEST . GIVE ITEM TO OTHER NPC

Pawka

New Member
Joined
Nov 9, 2017
Messages
2
Reaction score
0
Hello.
Can somebody help me do script of quest.
This is what i need in this .
If say mission and accept he give us something and you need to give it to another npc.
When you give it and come back he will give us a reward and another mission that we need to accept .
Please help.
 
Need some more information about your server.
Check the support board rules. o/
 
Its cryingdamson 0.3.6 (8.60) V8.2
I need to make script where npc give you 5 mission but you need to do missions in order 1>2>3>4>5 after each you get some reward
 
Well, I always start with a Simple Base NPC.
and from there, you just add to it.

Code:
words | storage = value

mission | 45001 = -1
yes     | 45001 = 1
finish  | 45001 = 2

mission | 45001 = 2
yes     | 45001 = 3
finish  | 45001 = 4

mission | 45001 = 4
yes     | 45001 = 5
finish  | 45001 = 6

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)  end
function onCreatureSay(cid, type, msg)  npcHandler:onCreatureSay(cid, type, msg)  end
function onThink()  npcHandler:onThink()  end
function greet(cid)   talkState[cid] = 0   return true end

function getNpcName()
    return getCreatureName(getNpcId())
end

function creatureSayCallback(cid, type, msg)
    if(not npcHandler:isFocused(cid)) then
        return false
    end

    local talkUser = NPCHANDLER_CONVBEHAVIOR == CONVERSATION_DEFAULT and 0 or cid

    if msgcontains(msg, "job") then
        selfSay("My job is to show the world how fashionable they can be!", cid)

    elseif msgcontains(msg, "name") then
        selfSay("My name is " .. getNpcName() .. ".", cid)

    elseif msgcontains(msg, "mission") then
        if getPlayerStorageValue(cid, 45001) < 1 then
            selfSay("Would you like to start mission 1?", cid)
        elseif getPlayerStorageValue(cid, 45001) == 2 then
            selfSay("Would you like to finish mission 2?", cid)
        elseif getPlayerStorageValue(cid, 45001) == 4 then
            selfSay("Would you like to finish mission 3?", cid)
        elseif getPlayerStorageValue(cid, 45001) == 6 then
            selfSay("You have finished all of the available missions.", cid)
            talkState[talkUser] = 0
            return true
        else
            selfSay("Say finish, to complete your mission.", cid)
            talkState[talkUser] = 0
            return true
        end
        talkState[talkUser] = 1
        return true

    elseif msgcontains(msg, "yes") and talkState[talkUser] == 1 then
        if getPlayerStorageValue(cid, 45001) < 1 then
            selfSay("Great. Say finish, to complete mission 1.", cid)
            setPlayerStorageValue(cid, 45001, 1)
        elseif getPlayerStorageValue(cid, 45001) == 2 then
            selfSay("Great. Say finish, to complete mission 2.", cid)
            setPlayerStorageValue(cid, 45001, 3)
        elseif getPlayerStorageValue(cid, 45001) == 4 then
            selfSay("Great. Say finish, to complete mission 3.", cid)
            setPlayerStorageValue(cid, 45001, 5)
        end
        talkState[talkUser] = 0
        return true

    elseif msgcontains(msg, "finish") then
        if getPlayerStorageValue(cid, 45001) == 1 then
            selfSay("Mission 1 complete.", cid)
            setPlayerStorageValue(cid, 45001, 2)
        elseif getPlayerStorageValue(cid, 45001) == 3 then
            selfSay("Mission 2 complete.", cid)
            setPlayerStorageValue(cid, 45001, 4)
        elseif getPlayerStorageValue(cid, 45001) == 5 then
            selfSay("Mission 3 complete.", cid)
            setPlayerStorageValue(cid, 45001, 6)
        else
            selfSay("You have no active missions.", cid)
        end
        talkState[talkUser] = 0
        return true

    end
    return true
end

npcHandler:setCallback(CALLBACK_GREET, greet)
npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())
If you want this to work with multiple npc's, you basically just split the different storage value checks between the npc's.

You can do less storage value changes, but I used 1 per quest state change so it's easier to follow.
 
Back
Top