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

local config = {
['rat'] = {amount = 20, storage = 21900, startstorage = 45551, startvalue = 1},
['rotworm'] = {amount = 26, storage = 21901, startstorage = 45551, startvalue = 1},
['dragon lord'] = {amount = 25, storage = 21902, startstorage = 45551, startvalue = 1}
}
function onKill(cid, target)
local monster = config[getCreatureName(target):lower()]
if isPlayer(target) or not monster or isSummon(target) then
return true
end

if (getPlayerStorageValue(cid, monster.storage)+1) < monster.amount and getPlayerStorageValue(cid, monster.startstorage) >= monster.startvalue then
setPlayerStorageValue(cid, monster.storage, getPlayerStorageValue(cid, monster.storage) + 1)
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, 'Task message: '..(getPlayerStorageValue(cid, monster.storage)+1)..' of '..monster.amount..' '..getCreatureName(target)..'s killed.')
end
if (getPlayerStorageValue(cid, monster.storage)+1) == monster.amount then
doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, 'Congratulations, you have killed '..(getPlayerStorageValue(cid, monster.storage)+1)..' '..getCreatureName(target)..'s and completed the '..getCreatureName(target)..'s mission.')
setPlayerStorageValue(cid, monster.storage, getPlayerStorageValue(cid, monster.storage) + 1)
end
return true
end
@StreamSide
 
Change 4 in the missions table in the NPC to 2, the dragon lord startvalue should be 2 then.
And you probable have to change the isSummon function to this (for 0.4 versions where getCreatureMaster returns nil).
Code:
function isSummon(cid)
      return getCreatureMaster(cid) ~= nil
end
 
Change 4 in the missions table in the NPC to 2, the dragon lord startvalue should be 2 then.
And you probable have to change the isSummon function to this (for 0.4 versions where getCreatureMaster returns nil).
Code:
function isSummon(cid)
      return getCreatureMaster(cid) ~= nil
end
Change it at creatureevents or in 050-functions?
 
@Limos Its working perfectly but its only once mission per character, i tried to change the time to another day but still same msg that i've done the quests, is it possible to do it everyday? Exhaustion time.
 
You can do it like this, it's a different NPC script and different server version, but the idea is the same, reset all the storages after 24 hours.
https://otland.net/threads/tfs-1-2-...is-not-resetting-storage.241428/#post-2339668
Actually, i already read it and i couldn't understand anything :D cuz it is another tfs so i can't understand anything.
EDIT: @Limos I tried with this exhaustion time, it is working good if i do missions with char didn't done missions before its working good, until now there isn't problem in next day i msg the npc with the same player and i find it working good with the exhaustion but i can take the reward without killing the monsters like Hi, mission, yes, REWARD without killing any monster.
http://pastebin.com/RaCDnxt3
thanks in advance :).
 
Last edited:
Hello
Great tutorial!

I have tried to make my own addon NPC with few talkstates and one storagevalue
I got stuck in one point but got helped and it seemed that I have added to many 'end'. I am learning every day more, looking forward for more tutorials like this :)

Thank you

Here is the code I have made incase someone needs it

CitizenAddonNPC
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 = 5000
citizen       = 23000

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, "addon") or msgcontains(msg, "backpack") or msgcontains(msg, "outfit") then
        if getPlayerStorageValue(cid, storage) == -1 then
            selfSay("Sorry, the backpack I wear is not for sale. It\'s handmade from rare {minotaur leather}.", cid)
            talkState[talkUser] = 1
        elseif getPlayerStorageValue(cid, storage) == 1 then
            selfSay("Ah, right, almost forgot about the backpack! Have you brought me 100 pieces of minotaur leather as requested?", cid)
            talkState[talkUser] = 3
        else
            selfSay("I have already made a backpack for you.", cid)
        end

    elseif msgcontains(msg, "minotaur leather") and talkState[talkUser] == 1 then
        if getPlayerStorageValue(cid, storage) == -1 then
            selfSay("Well, if you really like this backpack, I could make one for you, but minotaur leather is hard to come by these days. Are you willing to put some work into this?", cid)
            talkState[talkUser] = 2
        end
    elseif msgcontains(msg, "yes") and talkState[talkUser] == 2 then
        if getPlayerStorageValue(cid, storage) == -1 then
            selfSay("Alright then, if you bring me 100 pieces of fine minotaur leather I will see what I can do for you. You probably have to kill really many minotaurs though.. so good luck!", cid)                             
            setPlayerStorageValue(cid, storage, 1)
        end
    elseif msgcontains(msg, "yes") then
        if getPlayerStorageValue(cid, storage) == 1 and doPlayerRemoveItem(cid,5878,100) then
            selfSay("Here you go, I hope you like it.", cid)
            doSendMagicEffect(getCreaturePosition(cid), 13)
            doPlayerAddOutfit(cid, 128, 1)
            doPlayerAddOutfit(cid, 136, 1)
            setPlayerStorageValue(cid,citizen,1)
            setPlayerStorageValue(cid,storage,2)
        else
            selfSay("You do not have the leather.", cid)
        end
        talkState[talkUser] = 0
    elseif msgcontains(msg, "no") and talkState[talkUser] == 2 then
        selfSay("Ok then.", cid)
    elseif msgcontains(msg, "no") and talkState[talkUser] == 3 then
        selfSay("What are you waiting for? Without the leather I cannot make a backpack for you.", cid)
        talkState[talkUser] = 0
    end
    return true
end

npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())
 
Last edited:
Back
Top