• 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 NEED HELP WITH MY MINING QUEST LINE

DefensiveMode

New Member
Joined
Sep 6, 2013
Messages
21
Reaction score
2
so my server going to be 7.72 i'm using Tfs 1.3+

ok so my problem is i'm trying to get a quest line going for my mining. and i some what got it going this is what ive got so far. (my first time doing this) so i'm trying to get players to go visit Emperor Kruzak and start the mission. he gives a detailed msg on how he needs to go find Gilion Once players get there they ask for a mission and he sends players to retrieve a treasure map and kill 20 goblins. once you gain the map and kill the 20 goblins you talk to him again he rewards you with a pickaxe. and i would like for gillion to sell the pickaxe if the players looses it or someone takes it. but only if they do the quest. if someone can help me out i would be very much appreciated. still learning how to do this and all the forums ive read there coded different and i can't get them to work.


NPC#1

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

-- Promotion
local promoteKeyword = keywordHandler:addKeyword({'promot'}, StdModule.say, {npcHandler = npcHandler, text = 'Do you want to be promoted in your vocation for 20000 gold?'})
    promoteKeyword:addChildKeyword({'yes'}, StdModule.promotePlayer, {npcHandler = npcHandler, level = 20, cost = 20000})
    promoteKeyword:addChildKeyword({''}, StdModule.say, {npcHandler = npcHandler, text = 'Ok, whatever.', reset = true})
    
    npcHandler:addModule(FocusModule:new())


-- Mining
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 creatureSayCallback(cid, type, msg)
    if(not npcHandler:isFocused(cid)) then
        return false
    end
 
    local talkUser = NPCHANDLER_CONVBEHAVIOR == CONVERSATION_DEFAULT and 0 or cid
    local storage = 9105
 
    if(msgcontains(msg, 'mining')) then
        if(getPlayerStorageValue(cid, storage) == -1) then
            selfSay('Who are you, What are you seeking? A mission? GOOD!!! Ive Sent My General Gilion On A Treasure Hunt At The Top Of Kazordoon Mountain, He Has Failed To Report In. Help Me Find Him. Then Maybeeee I Will Consider You Joining Our Ranks!!!', cid)
            setPlayerStorageValue(cid, storage, 1)

        elseif(getPlayerStorageValue(cid, storage) == 1) then
            selfSay('Already visited Gilion? Haven\'t heard anything from him yet, please go visit him.', cid)

        elseif(getPlayerStorageValue(cid, storage) > 1) then
            selfSay('Gilion told me you were helping him, that is great.', cid)
        end
    end
    return true
end
 
npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())




NPC#2

Lua:
- King, visit him first and ask about pickaxe

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 = 9105



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, "mission") then

         if getPlayerStorageValue(cid, storage) == 1 then

             selfSay("I have a mission for you to kill 20 Goblins, do you accept?", cid)

             talkState[talkUser] = 1

         elseif getPlayerStorageValue(cid, storage) == 1 then

             selfSay("Did you kill 20 Goblins?", cid)

             talkState[talkUser] = 1

         else

             selfSay("You already did the mission.", cid)

         end

     elseif msgcontains(msg, "yes") and talkState[talkUser] == 1 then

         if getPlayerStorageValue(cid, storage) == -1 then

             selfSay("Good, come back when you killed them.", cid)

             setPlayerStorageValue(cid, storage, 1)

         else

             if getPlayerStorageValue(cid, 15007) == 20 then

                 selfSay("Good job, here is your reward.", cid)

                 doPlayerAddItem(cid, 22691, 1)

                 doPlayerAddExp(cid, 1000)

                 setPlayerStorageValue(cid, storage, 2)

             else

                 selfSay("You didn't kill them all.", cid)

             end

         end

         talkState[talkUser] = 0

     elseif msgcontains(msg, "no") and talkState[talkUser] == 1 then

         selfSay("Ok then.", cid)

         talkState[talkUser] = 0

     end

     return true

end



npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)

npcHandler:addModule(FocusModule:new())


CREATURE SCRIPT

Lua:
local config =
["goblin"] = {questStarted = 9105, questStorage = 9105, creatureStorage = 15007, killsRequired = 20, raceName = "Goblins"},
local msgType = MESSAGE_STATUS_CONSOLE_ORANGE
 
function onKill(cid, target, lastHit)
 
local creature = questCreatures[getCreatureName(target):lower()]
 
    if creature then
        if isPlayer(target) or isSummon(target) then return true end
 
        if getCreatureStorage(cid, creature.questStarted) > 0 then
            if getCreatureStorage(cid, creature.questStorage) < creature.killsRequired then
                if getCreatureStorage(cid, creature.questStorage) < 0 then
                    doCreatureSetStorage(cid, creature.questStorage, 0)
                end
 
                if getCreatureStorage(cid, creature.creatureStorage) < 0 then
                    doCreatureSetStorage(cid, creature.creatureStorage, 0)
                end
                doCreatureSetStorage(cid, creature.questStorage, getCreatureStorage(cid, creature.questStorage) + 1)
                doCreatureSetStorage(cid, creature.creatureStorage, getCreatureStorage(cid, creature.creatureStorage) + 1)
                doPlayerSendTextMessage(cid, msgType, getCreatureStorage(cid, creature.creatureStorage) .. " " .. getCreatureName(target) .. " defeated. Total [" .. getCreatureStorage(cid, creature.questStorage) .. "/" .. creature.killsRequired .. "] " .. creature.raceName .. ".")
            end
        end
    end
    return true
end
 

Similar threads

Back
Top