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

2 or more daily mission at the same time

Thorn

Spriting since 2013
Joined
Sep 24, 2012
Messages
2,203
Solutions
1
Reaction score
923
Location
Chile
otx 2.52 i think tfs 0.3?

Hello guys, i have daily missions npcs, but the thing is that you can only stay with one npc at the same time. To do another one you have to finish the first one or leave, is it possible that the player may start several daily missions at the same time?

i'll post the npc and creaturescript of 2 different daily mission npcs =)

1)
LUA:
local mobsList = {
    ["humongous fungus"] = {storage = 345704, raceName = "humongous fungus"}, -- storage have to be exacly the same as in your npc file!
    ["dragonling"] = {storage = 345705, raceName = "dragonling"},
    ["infected weeper"] = {storage = 345706, raceName = "infected weeper"},
    ["askarak lord"] = {storage = 345707, raceName = "askarak lord"},
    ["abyssador"] = {storage = 345708, raceName = "abyssador"}
}

function onKill(cid, target, lastHit)
local mob = mobsList[getCreatureName(target):lower()]

if isPlayer(cid) then
    if mob then
    local check = getCreatureStorage(cid, mob.storage)
        if check >= 0 and check < 5000 then
            doPlayerSetStorageValue(cid, mob.storage, check + 1)
            doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, mob.raceName .. " killed: " .. (check + 1) .. ".")
        end
    end
end
return true
end

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

local NPCGREETING = "Hola viajero, te gustaria hacer una {mission}?"
local NPCFAREWELL = "Bye"

local monsters = {
    [1] = {storage = 345704, count = 25, reward = 2160, itemcount = 100, name = "humongous fungus"},
    [2] = {storage = 345705, count = 25, reward = 21653, itemcount = 2, name = "dragonling"},
    [3] = {storage = 345706, count = 50, reward = 21653, itemcount = 3, name = "infected weeper"},
    [4] = {storage = 345707, count = 50, reward = 21653, itemcount = 4, name = "askarak lord"},
    [5] = {storage = 345708, count = 100, reward = 21654, itemcount = 2, name = "abyssador"}
}

local cfg = {
        h = 00,
        m = 31
        }

local function check(cid)
local a, b = 1, 0
    while monsters[a] do
        if getCreatureStorage(cid, monsters[a].storage) >= os.time() then
            a = a + 1
        else
            b = a
            break
        end
    end
return b
end

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

    if msgcontains(msg, 'mission') then
    local t = {year=os.date("%Y"),month=os.date("%m"),day=os.date("%d"),hour=cfg.h,min=cfg.m}
    if getCreatureStorage(cid, "dailymission") < os.time() then
        if os.time(t) < os.time() then
            t = {year=os.date("%Y"),month=os.date("%m"),day=os.date("%d")+1,hour=cfg.h,min=cfg.m}
            doCreatureSetStorage(cid, "dailymission",os.time(t))
            for s = 1,#monsters do
                doCreatureSetStorage(cid, monsters[s].storage, 0)
            end
        end
    end
    local missionid = check(cid)
    local has = getCreatureStorage(cid, "hasmission")
        if has >= 1 then
            if getCreatureStorage(cid, monsters[has].storage) >= monsters[has].count then
                selfSay("Felicidades, has completado tu mision!", cid)
                doPlayerAddItem(cid, monsters[has].reward, monsters[has].itemcount)
                doCreatureSetStorage(cid, monsters[has].storage, os.time() + 86400)
                doCreatureSetStorage(cid, "hasmission", 0)
                talk_state = 0
            else
                selfSay("Te gustaria abandonar tu mision actual?", cid)
                talk_state = 2
            end
        elseif missionid ~= 0 then
            selfSay("Ok, debes matar " .. monsters[missionid].count .. " " .. monsters[missionid].name .. "s.",cid)
            doCreatureSetStorage(cid, monsters[missionid].storage, 0)
            doCreatureSetStorage(cid, "hasmission", missionid)
            talk_state = 3
        else
            selfSay("Lo siento, aun no hay misiones para ti.", cid)
        end
    elseif msgcontains(msg, 'yes') and talk_state == 2 then
        local m = getCreatureStorage(cid, "hasmission")
        selfSay("Aun no terminas la mision, maldito mentiroso.", cid)
        doCreatureSetStorage(cid, "hasmission", 0)
        doCreatureSetStorage(cid, monsters[m].storage, -1)
        talk_state = 0
    elseif msgcontains(msg, 'no') and talk_state == 2 then
        selfSay("Bueno entonces... vuelve cuando hayas finalizado tu mision.", cid)
    end
return true
end
   
   
npcHandler:setMessage(MESSAGE_GREET, NPCGREETING)
npcHandler:setMessage(MESSAGE_WALKAWAY, NPCWALKAWAY)
npcHandler:setMessage(MESSAGE_FAREWELL, NPCFAREWELL)
npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())










2)
LUA:
local mobsList = {
    ["orewalker"] = {storage = 345709, raceName = "orewalker"}, -- storage have to be exacly the same as in your npc file!
    ["sandstone scorpion"] = {storage = 345710, raceName = "sandstone scorpion"},
    ["stone devourer"] = {storage = 345711, raceName = "stone devourer"},
    ["lava golem"] = {storage = 345712, raceName = "lava golem"},
    ["shaburak prince"] = {storage = 345713, raceName = "shaburak prince"}
}

function onKill(cid, target, lastHit)
local mob = mobsList[getCreatureName(target):lower()]

if isPlayer(cid) then
    if mob then
    local check = getCreatureStorage(cid, mob.storage)
        if check >= 0 and check < 5000 then
            doPlayerSetStorageValue(cid, mob.storage, check + 1)
            doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, mob.raceName .. " killed: " .. (check + 1) .. ".")
        end
    end
end
return true
end

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

local NPCGREETING = "Hola viajero, te gustaria hacer una {mission}?"
local NPCFAREWELL = "Bye"

local monsters = {
    [1] = {storage = 345709, count = 25, reward = 2160, itemcount = 100, name = "orewalker"},
    [2] = {storage = 345710, count = 25, reward = 8302, itemcount = 1, name = "sandstone scorpion"},
    [3] = {storage = 345711, count = 50, reward = 21652, itemcount = 1, name = "stone devourer"},
    [4] = {storage = 345712, count = 50, reward = 21655, itemcount = 5, name = "lava golem"},
    [5] = {storage = 345713, count = 100, reward = 8981, itemcount = 2, name = "shaburak prince"}
}

local cfg = {
        h = 00,
        m = 31
        }

local function check(cid)
local a, b = 1, 0
    while monsters[a] do
        if getCreatureStorage(cid, monsters[a].storage) >= os.time() then
            a = a + 1
        else
            b = a
            break
        end
    end
return b
end

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

    if msgcontains(msg, 'mission') then
    local t = {year=os.date("%Y"),month=os.date("%m"),day=os.date("%d"),hour=cfg.h,min=cfg.m}
    if getCreatureStorage(cid, "dailymission") < os.time() then
        if os.time(t) < os.time() then
            t = {year=os.date("%Y"),month=os.date("%m"),day=os.date("%d")+1,hour=cfg.h,min=cfg.m}
            doCreatureSetStorage(cid, "dailymission",os.time(t))
            for s = 1,#monsters do
                doCreatureSetStorage(cid, monsters[s].storage, 0)
            end
        end
    end
    local missionid = check(cid)
    local has = getCreatureStorage(cid, "hasmission")
        if has >= 1 then
            if getCreatureStorage(cid, monsters[has].storage) >= monsters[has].count then
                selfSay("Felicidades, has completado tu mision!", cid)
                doPlayerAddItem(cid, monsters[has].reward, monsters[has].itemcount)
                doCreatureSetStorage(cid, monsters[has].storage, os.time() + 86400)
                doCreatureSetStorage(cid, "hasmission", 0)
                talk_state = 0
            else
                selfSay("Te gustaria abandonar tu mision actual?", cid)
                talk_state = 2
            end
        elseif missionid ~= 0 then
            selfSay("Ok, debes matar " .. monsters[missionid].count .. " " .. monsters[missionid].name .. "s.",cid)
            doCreatureSetStorage(cid, monsters[missionid].storage, 0)
            doCreatureSetStorage(cid, "hasmission", missionid)
            talk_state = 3
        else
            selfSay("Lo siento, aun no hay misiones para ti.", cid)
        end
    elseif msgcontains(msg, 'yes') and talk_state == 2 then
        local m = getCreatureStorage(cid, "hasmission")
        selfSay("Aun no terminas la mision, maldito mentiroso.", cid)
        doCreatureSetStorage(cid, "hasmission", 0)
        doCreatureSetStorage(cid, monsters[m].storage, -1)
        talk_state = 0
    elseif msgcontains(msg, 'no') and talk_state == 2 then
        selfSay("Bueno entonces... vuelve cuando hayas finalizado tu mision.", cid)
    end
return true
end
   
   
npcHandler:setMessage(MESSAGE_GREET, NPCGREETING)
npcHandler:setMessage(MESSAGE_WALKAWAY, NPCWALKAWAY)
npcHandler:setMessage(MESSAGE_FAREWELL, NPCFAREWELL)
npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())


plz if someone knows how can i fix this plz help me :(
 
Solution
LUA:
if check >= 0 and check < 5000 then
that number?? :O

You have to set different storage, preferably name

LUA:
doCreatureSetStorage(cid, "hasmission", 0)

Then you also change the variable storage name

LUA:
local has = getCreatureStorage(cid, "hasmission")
LUA:
if check >= 0 and check < 5000 then
that number?? :O

You have to set different storage, preferably name

LUA:
doCreatureSetStorage(cid, "hasmission", 0)

Then you also change the variable storage name

LUA:
local has = getCreatureStorage(cid, "hasmission")
 
Last edited:
Solution
Back
Top