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

Lua Trying to do stuff on my own but having an issue with quest

XiolenceOT

New Member
Joined
Jun 5, 2023
Messages
42
Reaction score
4
Lua:
local keywordHandler = KeywordHandler:new()
local npcHandler = NpcHandler:new(keywordHandler)
NpcSystem.parseParameters(npcHandler)

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_QUEST_1 = 2875
local STORAGE_QUEST_2 = 2876
local REQUIRED_LEVEL = 100

local function greetCallback(cid)
    local player = Player(cid)
    local playerStorage1 = player:getStorageValue(STORAGE_QUEST_1)
    local playerStorage2 = player:getStorageValue(STORAGE_QUEST_2)

    if playerStorage1 <= 0 then
        npcHandler:setMessage(MESSAGE_GREET, "No time to waste! I need you to get to the top of the fortress and destroy the {catapult}.")
    elseif playerStorage1 == 1 then
        npcHandler:setMessage(MESSAGE_GREET, "That's right, get up there, NOW before it's too late!")
    elseif playerStorage1 == 2 then
        npcHandler:setMessage(MESSAGE_GREET, "Thank you for your help! That will deal a great blow to the orc's army!")
        player:setStorageValue(STORAGE_QUEST_1, 3)
        player:addExperience(400000)
    elseif playerStorage1 == 3 then
        if player:getLevel() >= REQUIRED_LEVEL and playerStorage2 <= 0 then
            npcHandler:setMessage(MESSAGE_GREET, "Welcome back, " .. player:getName() .. "! It's been a while, but I've got a plan to finally finish the orc's army from growing once and for all. What do you say?")
        else
            npcHandler:setMessage(MESSAGE_GREET, "Congratulations on completing the quest! Those orcs didn't know what hit them.")
        end
    elseif playerStorage2 == 1 then
        npcHandler:setMessage(MESSAGE_GREET, "Great! Whenever you're ready, go to the orc fortress's basement and use the explosive barrel. We'll blow the entire place sky-high and be done with them for good! Report back to me after you've destroyed the place! Filthy orcs.")
    elseif playerStorage2 == 2 then
        npcHandler:setMessage(MESSAGE_GREET, "I heard the explosion, did everything go according to {plan}?")
    end

    return true
end

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

    local player = Player(cid)
    local playerStorage1 = player:getStorageValue(STORAGE_QUEST_1)
    local playerStorage2 = player:getStorageValue(STORAGE_QUEST_2)

    if msgcontains(msg, "catapult") then
        if playerStorage1 <= 0 then
            npcHandler:say("That's right, get up there, NOW before it's too late!", cid)
            player:setStorageValue(STORAGE_QUEST_1, 1)
        end
    elseif msgcontains(msg, "yes") or msgcontains(msg, "plan") then
        if playerStorage2 == 2 then
            player:setStorageValue(STORAGE_QUEST_2, 3)
            player:addExperience(500000)
            player:addItem(2160, 5)
            npcHandler:say("WOO HOO, no more orcs around here! We did it! Thank you for all of your help. Please take this as a reward. Safe travels, " .. player:getName() .. "!", cid)
        end
    end

    return true
end

npcHandler:setCallback(CALLBACK_GREET, greetCallback)
npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())

So this is two quests in one NPC, the first one works fine, you talk to the npc respond to her keywords, go to the orc fortress and click a catapult part of another script then return to her, tested works fine, quest log updates all good.

The second part requires level 100, and requires the player to go to the basement of the orc fortress and click on an explosive barrel, the barrel works fine, updates the quest log sets players storage 2876 to 2, but when the player returns to nelly after that she always greets the player with "Congratulations on completing the quest! Those orcs didn't know what hit them." no quest update, no experience, no items.

I've been messing around with it on my own for a while trying to fix it. Learning opportunity I suppose, any ideas?
 
change these lines in greetCallback
Lua:
    elseif playerStorage1 == 3 then
        if player:getLevel() >= REQUIRED_LEVEL and playerStorage2 <= 0 then
to
Lua:
    elseif playerStorage1 == 3 and playerStorage2 <= 0 then
        if player:getLevel() >= REQUIRED_LEVEL then
 
change these lines in greetCallback
Lua:
    elseif playerStorage1 == 3 then
        if player:getLevel() >= REQUIRED_LEVEL and playerStorage2 <= 0 then
to
Lua:
    elseif playerStorage1 == 3 and playerStorage2 <= 0 then
        if player:getLevel() >= REQUIRED_LEVEL then

I understand, thank you man
 
Back
Top