Ir para conteúdo
  • Cadastre-se

Suporte script npc task e questlog system bugs!


Posts Recomendados

Galera seguinte, eu to com o servidor global 8.6 aquele que tem ethno e gengia, com distro 0.4, o que acontece é que quando fui colocar o systema de quest log acontece o seguinte erro: um exemplo pra eu explicar pra vcs \/

 

<?xml version="1.0" encoding="UTF-8"?>
<quests>
    <quest name="Example Quest I" startstorageid="30031" startstoragevalue="1">
        <mission name="The head of Kiper" storageid="1001" startvalue="1" endvalue="3">
            <missionstate id="1" description="Kill Kiper!"/>   AQUI A DESCRIÇAO 1 DA MISSAO
            <missionstate id="2" description="Give his head to Talaturen!"/>  AQUI A DESCRIÇAO 2 DA MISSAO
            <missionstate id="3" description="Take the medal you got from Talaturen to Ruly!"/> AQUI A DESCRIÇAO 3 DA MISSAO
        </mission>
        <mission name="Ruly's Revenge" storageid="30031" startvalue="4" endvalue="6">
            <missionstate id="4" description="You received a document with instructions from Ruly, follow them."/>
            <missionstate id="5" description="Go back to Ruly and tell him that you followed his instructions to the end."/>
            <missionstate id="6" description="You got a reward from Ruly, he was very thankful with that you helped him to take his revenge."/>
        </mission>
    </quest>
</quests>

 

A descriçao 1 ou a 2 ou a 3 só estao aparecendo depois que o player recebe o storage no caso ali storageid="1001" startvalue="1" endvalue="3">

ele ira termina aassim a ultima storage 1001,3 apenas quando o player recebe a 1001,3 que aparece alguma descriçao, antes disso nao aparece, tipo quando o player recebe a storage 1001,1 era pra aparecer a descriçao 1 pra ele e nao aparece nenhuma descriçao, ganha a storage 1001,2 e tambem nao aparece nada mas ao receber a final storage ai sim ai ele ganha mas ai nao serve pra nada esse quest log de auxilio nas quest... no outro ot que tenho aqui ele funciona perfeitamente porem ele tem muitos bug em ZAO. E nao conpenssa trabalhar nele.

 

 

 

 

 

 

 

Outro erro o npc Grizzly Adams nao funciona nesse servidor

 

eu usei esse script pra tentar colocar o sistema de task:

 

local keywordHandler = KeywordHandler:new()
local npcHandler = NpcHandler:new(keywordHandler)
NpcSystem.parseParameters(npcHandler)
local Topic = {}

local data = {
    [14007] = {'crocodile', 'Happy hunting, old chap! Come back to me when you are through with your task.', 'Alright, then return to your duties! Day light is a-wasting! You have already smashed %u crocodiles. Come back to me when you are done.', 'Spiffing work, old chap. Now I have a special task for you. Recently several citizens of Port Hope have vanished. It is rumoured that they were killed by a crocodile. The people call it \'Snapper\'. Hunt down and kill that evil man eating beast.', 800, 1, 'Snapper', },
    [14008] = {'tarantula', 'Happy hunting, old chap! Come back to me when you are through with your task.', 'Alright, then return to your duties! Day light is a-wasting! You have already smashed %u tarantulas. Come back to me when you are done.', 'Nicely done! Now I shall assign you a special task. Rumour has it that there is an ancient and evil tarantula who preys on humans. She is called \'Hide\'. Track her down and kill her! Good luck, old chap.', 1500, 1, 'Hide'},
    [14009] = {'carniphila', 'Good show, old chap! Speak to me again when you are done hunting.', 'Alright, then return to your duties! Day light is a-wasting! You have already smashed %u carniphilas. Come back to me when you are done.', 'That took some time, huh? Good hunting though. If you\'re up for another hunting mission just ask me for a {task}.', 1500, 1},
    [14010] = {'stone golem', 'Happy hunting, friend! When you have finished hunting, return here. ', 'Alright, then return to your duties! Day light is a-wasting! You have already smashed %u stone golems. Come back to me when you are done.', 'Good show, old chap. If you\'re up for another hunting mission just ask me for a task.', 2000, 1},
    [14011] = {'mammoth', 'Happy hunting, friend! Come back to me when you are done hunting.', 'Alright, then return to your duties! Day light is a-wasting! You have already smashed %u mammoths. Come back to me when you are done.', 'Jolly good job you did there, but now I have a special task for you. The citizens of Svargrond live in fear because of a frightfully bad-tempered mammoth they call \'Blood Tusk\'. Go there and put an end to him. Happy hunting!', 'Bloodtusk', 4000, 1},
    [14012] = {'ice golem', 'Happy hunting, friend! Come back to me when you are done hunting.', 'Alright, then return to your duties! Day light is a-wasting! You have already smashed %u ice golems. Come back to me when you are done.', 'As i see it, you need more of a challenge! I have heard that there is an ice golem the hunters in Svargrond call \'Shardhead\'. He is an extremely dangerous example of his kind! I believe you are equal to the task, %s!', 15000, 1, 'Shardhead'},
    [14013] = {'quara constrictor scout', 'Happy hunting, friend! Come back to me when you are done hunting.', 'Alright, then you should go on with your task. You have already killed %u quara scouts in total. Come back to me when you are done.', 'Jolly good show! What a hunter! If you\'re up for another hunting mission just ask me for a {task}.', 10000, 1}, -- ?
    [14014] = {'quara constrictor', 'Happy hunting, friend! Come back to me when you are done hunting.', 'Alright, then you should go on with your task. You have already killed %u underwater quaras in total. Come back to me when you are done.', 'Superb work. However, there is something else I want you to do. It is said that there is a Quara general named \'Thul\' who is responsible for the attacks on Liberty Bay. Find him and kill him and bring peace to Liberty bay!', 12000, 1, 'Thul'}, -- OK
    [14015] = {'water elemental', 'Happy hunting, my old mocker! Come back to me when you are done hunting. ', 'Alright, then return to your duties! Day light is a-wasting! You have already smashed %u water elementals. Come back to me when you are done.', 'Fantastic! If you\'re up for another hunting mission just ask me for a {task}.', 7000, 1},
    [14016] = {'earth elemental', 'Happy hunting, friend! Come back to me when you are done hunting. ', 'Alright, then return to your duties! Day light is a-wasting! You have already smashed %u earth elementals. Come back to me when you are done.', 'Fantastic! If you\'re up for another hunting mission just ask me for a {task}.', 10000, 1},
    [14017] = {'energy elemental', 'Happy hunting, pal! Come back to me when you are done hunting. ', 'Alright, then return to your duties! Day light is a-wasting! You have already smashed %u energy elementals. Come back to me when you are done.', 'Fantastic! If you\'re up for another hunting mission just ask me for a {task}.', 10000, 1},
    [14018] = {'fire elemental', 'Happy hunting, old friend! Come back to me when you are done hunting. ', 'Alright, then return to your duties! Day light is a-wasting! You have already smashed %u fire elementals. Come back to me when you are done.', 'Fantastic! If you\'re up for another hunting mission just ask me for a {task}.', 7000, 1},
    [14019] = {'mutated rat', 'Happy hunting, old chap! Come back to me when you are done hunting. ', 'Alright, then stop dilly dallying here and go on with your task. You have already exterminated %u mutated rats. Come back to me when you are done.', {'Very good work, old chap. Lucky you are here - I have just been told of a task which is perfect for you. ...', 'The Yalaharians are having a spot of bother with a huge mutated rat. They call it \'Esmeralda\' and you should find her somewhere in the sewers. Good hunting!'}, 10000, 1, 'Esmeralda'}, -- OK
    [14020] = {'giant spider', 'Jolly good show! Come back to me when you are done hunting. ', 'Alright, then return to your duties! Day light is a-wasting! You have already smashed %u giant spiders. Come back to me when you are done.', 'Well THAT was a hunt. Good job. Have you heared about \'The Old Widow\'? It must have a hideout. Try to find it and slay the beast.', 5000, 1, 'Old Widow'},
    [14021] = {'hydra', 'Happy hunting, old chap! Come back to me when you are done hunting.', 'Alright, then return to your duties! Day light is a-wasting! You have already smashed %u hydras. Come back to me when you are done.', {'With Nornur the God of Fate as my witness, you are truly born to hunt. If anyone can do this task, you can! Listen: ...', 'It is said that the Lizards of Chor are training hydras for attacks against us. They have already successfully bred a hydra named \'The Many\'. Find her and kill her!'}, 0, 3, 'Many'},
    [14001] = {'sea serpent', 'Happy hunting, old chap! Come back to me when you are done hunting.', 'Alright, then return to your duties! Day light is a-wasting! You have already smashed %u sea serpents. Come back to me when you are done.', 'Good job, old chap! Are you up for a challenge? Have you heard of the legendary sea serpent called \'The Leviathan\'? It must be somewhere near the spot you found. This is a true test of your hunting skills - find it and kill it. Good hunting!', 0, 3, 'Leviathan'},
    [14022] = {'behemoth', 'Happy hunting, old chap! Come back to me when you are done hunting.', 'Alright, then return to your duties! Day light is a-wasting! You have already smashed %u behemoths. Come back to me when you are done.', 'Such marvellous hunting skills! Perhaps you can help me with this one. Have you heard about \'Stonecracker\'? ...', 0, 3, 'Stonecracker'}, -- OK
    [14002] = {'serpent spawn', 'Happy hunting, old chap! Come back to me when you are done hunting.', 'Alright, then return to your duties! Day light is a-wasting! You have already smashed %u serpent spawns. Come back to me when you are done.', 'My - you can be proud of yourself! However, you\'re not finished yet. There are rumours about a being called \'The Noxious Spawn\' which was seen deep down in the ruins of Banuta. Try to find its hideout.', 0, 3, 'Noxious Spawn'},
}

local curTask = 14500
local points = 14501
local rank = 14502
local questLog = 14503
local tiquanda = 14505
local demodras = 16345

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 greetCallback(cid)
    local cur, r, msg = getPlayerStorageValue(cid, points), getPlayerStorageValue(cid, rank)
    if cur >= 5 and r < 1 then
        msg = 'Welcome back |PLAYERNAME|. You have completed 5 tasks for our society. Ask me for a {promotion} to advance your rank!'
    elseif cur >= 10 and r < 2 then
        msg = 'Good to see you again |PLAYERNAME|. You have completed 10 tasks for our society. Ask me for a {promotion} to advance your rank!'
    elseif cur >= 20 and r < 3 then
        msg = 'Salutations |PLAYERNAME|. You have completed 20 tasks for our society. Ask me for a {promotion} to advance your rank!'
    elseif cur >= 30 and r < 4 then
        msg = 'Always good to welcome you back, |PLAYERNAME|. You have completed 30 tasks for our society. Ask me for a {promotion} to advance your rank!'
    elseif cur >= 50 and r < 5 then
        msg = 'By the gods....50 hunting tasks....this is astounding! Ask me for a {promotion} to advance your rank! And while you are here, I also have another {special} task for you.'
    else
        msg = 'Welcome back |PLAYERNAME|. What brings you here this time?'
    end
    npcHandler:setMessage(MESSAGE_GREET, msg)
    Topic[cid] = 0
    return true
end

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

    if msgcontains(msg, 'task') then
        local cur = getPlayerStorageValue(cid, curTask)
        if cur < 1 or (cur ~= 14006 and getPlayerStorageValue(cid, cur) == tasks[data[cur][1]].amount + 1 and getPlayerStorageValue(cid, cur + 100) == -1) then
            local v, lvl = '', getPlayerLevel(cid)
            if lvl < 50 then
                v, Topic[cid] = '{Crocodiles}, {tarantulas}, {carniphilas}, {stone golems} or {mammoths}', 1
            elseif lvl < 90 then
                v, Topic[cid] = '{Ice golems}, {Quara}, {elementals}, {mutated rats} or {giant spiders}', 2
            elseif 90 <= lvl then
                v, Topic[cid] = '{Hydras}, {sea serpents}, {behemoths}' .. (getPlayerStorageValue(cid, rank) == 5 and ', {serpent spawns} or {demons}' or ' or {serpent spawns}'), 3
            end
            selfSay('All right, what would you like to hunt? ' .. v .. '?', cid)
        elseif cur == 14006 and getPlayerStorageValue(cid, cur) == tasks['demon'].amount then
            selfSay({'Such derring do deserves a special reward! Take this holy icon. It neutralizes great evil and gives you access to areas which are protected by those forces. But remember ...', 'This is a one time opportunity! You won\'t get the holy icon twice.'}, cid)
            doPlayerAddItem(cid, 10305, 1)
            setPlayerStorageValue(cid, curTask, -1)
        elseif cur ~= 14006 and getPlayerStorageValue(cid, cur) == tasks[data[cur][1]].amount and getPlayerStorageValue(cid, cur + 100) < 1 then
            local tmp
            if type(data[cur][4]) == 'table' then
                tmp = {}
                for i = 1, #data[cur][4] do
                    tmp = string.format(data[cur][4], getCreatureName(cid))
                end
            end
            selfSay(tmp or string.format(data[cur][4], getCreatureName(cid)), cid)
            if data[cur][5] > 0 then
                doPlayerAddExp(cid, data[cur][5])
                doSendAnimatedText(getThingPos(cid), data[cur][5], 215)
            end
            if data[cur][6] then
                setPlayerStorageValue(cid, points, getPlayerStorageValue(cid, points) + data[cur][6])
            end
            if data[cur][7] then -- special task (he sends you to kill the boss)
                setPlayerStorageValue(cid, cur + 100, 1)
            end
            setPlayerStorageValue(cid, cur, getPlayerStorageValue(cid, cur) + 1)
            Topic[cid] = 0
        elseif getPlayerStorageValue(cid, cur + 100) == 2 then
            setPlayerStorageValue(cid, points, getPlayerStorageValue(cid, points) + 1)
            selfSay('Fantastic! If you\'re up for another hunting mission just ask me for a {task}.', cid)
            setPlayerStorageValue(cid, cur + 100, -1)
        else
            selfSay(getPlayerStorageValue(cid, cur + 100) < 1 and 'You are not done with your task yet. Come back to me when you are. Or do you want to abort your task to start a different one?' or string.format('Find %s\'s hideout. I hope for you that you are skilled enough to kill him. Or do you want to abort your task to start a different one?', data[cur][7]), cid)
            Topic[cid] = 4
        end
    elseif msgcontains(msg, 'trade') and getPlayerStorageValue(cid, rank) >= 1 then
        local items = {
            {name='antlers', id=11208, sell=50},
            {name='bloody pincers', id=10549, sell=50},
            {name='crab pincers', id=11183, sell=35},
            {name='cyclops toe', id=10573, sell=55},
            {name='frosty ear of a troll', id=10564, sell=30},
            {name='hydra head', id=11193, sell=600},
            {name='lancer leetle shell', id=11366, sell=80},
            {name='mutated bat ear', id=10578, sell=420},
            {name='sabretooth', id=11222, sell=400},
            {name='sandcrawler shell', id=11367, sell=20},
            {name='scarab pincers', id=10547, sell=280},
            {name='terramite legs', id=11365, sell=60},
            {name='terramite shell', id=11363, sell=170},
            {name='terrorbird beak', id=11184, sell=95},
            {name='cyclops trophy', id=7398, sell=500},
            {name='minotaur trophy', id=7401, sell=500},
        }
        if getPlayerStorageValue(cid, rank) >= 3 then
            table.insert(items, {name='deer trophy', id=7397, sell=3000})
            table.insert(items, {name='lion trophy', id=7400, sell=3000})
            table.insert(items, {name='wolf trophy', id=7394, sell=3000})
        end
        if getPlayerStorageValue(cid, rank) >= 4 then
            table.insert(items, {name='behemoth trophy', id=7396, sell=20000})
            table.insert(items, {name='demon trophy', id=7393, sell=40000})
            table.insert(items, {name='dragon lord trophy', id=7399, sell=10000})
            table.insert(items, {name='demon backpack', id=10518, buy=1000})
        end
        openShopWindow(cid, items,
            function(cid, itemid, subType, amount, ignoreCap, inBackpacks)
                customCallbackOnBuy(cid, itemid, subType, amount, ignoreCap, inBackpacks, items)
            end,
            function(cid, itemid, subType, amount, ignoreCap, inBackpacks)
                customCallbackOnSell(cid, itemid, subType, amount, ignoreCap, inBackpacks, items)
            end
        )
        selfSay("Alright, show me what you've got.", cid)
    elseif Topic[cid] == 4 then
        local cur = getPlayerStorageValue(cid, curTask)
        if msgcontains(msg, 'yes') or msgcontains(msg, 'abort') then
            selfSay('Alright, as you wish. Ask me for a task if you are interested in a different hunting mission.', cid)
            setPlayerStorageValue(cid, cur, -1)
            setPlayerStorageValue(cid, curTask, -1)
            if getPlayerStorageValue(cid, cur + 100) > 0 then
                setPlayerStorageValue(cid, cur + 100, -1)
            end
        else
            selfSay(cur == 14006 and string.format('Alright, then stop dilly dallying here and go on with your task. You have already exterminated %u demons. Come back to me when you are done.', getPlayerStorageValue(cid, cur)) or getPlayerStorageValue(cid, cur + 100) < 1 and string.format(data[getPlayerStorageValue(cid, curTask)][3], getPlayerStorageValue(cid, cur)) or 'Alright, then you should go on with your task.', cid)
        end
        Topic[cid] = 0
    elseif Topic[cid] == 1 and msgcontains(msg, 'crocodile') then
        local v = tasks['crocodile']
        selfSay('They are a nuisance! You\'ll find them here in the jungle near the river. Hunt ' .. v.amount .. ' crocodiles and you\'ll get a nice reward. Interested?', cid)
        Topic[cid] = v.storage
    elseif Topic[cid] == 1 and msgcontains(msg, 'tarantula') then
        local v = tasks['tarantula']
        selfSay('There is a veritable plague of tarantulas living in the caves north of the river to the east. Can you squish ' .. v.amount .. ' tarantulas for the Hunting Elite. What do you say?', cid)
        Topic[cid] = v.storage
    elseif Topic[cid] == 1 and msgcontains(msg, 'carniphila') then
        local v = tasks['carniphila']
        selfSay('Damn walking weed-thingies! You\'ll find them deeper in the jungle. Weed out ' .. v.amount .. ' carniphilas for our society. Alright?', cid)
        Topic[cid] = v.storage
    elseif Topic[cid] == 1 and msgcontains(msg, 'golem') then
        local v = tasks['stone golem']
        selfSay('They can be found all over Tibia. You\'ll find them in mountain caves or rocky dungeons. Hunt ' .. v.amount .. ' of them and come back to me. Understood?', cid)
        Topic[cid] = v.storage
    elseif Topic[cid] == 1 and msgcontains(msg, 'mammoth') then
        local v = tasks['mammoth']
        selfSay('This particular species are found in Svargrond. Impressive beasts, but you wouldn\'t want one in your back garden. Hunt ' .. v.amount .. ' of them. Alright?', cid)
        Topic[cid] = v.storage
    elseif Topic[cid] == 2 and msgcontains(msg, 'golem') then
        local v = tasks['ice golem']
        selfSay('The ice golems on the glacier of Hrodmir are becoming a threat to the civilians in Svargrond. Travel to the Ice Islands and hunt ' .. v.amount .. ' Ice Golems. Do you accept this task?', cid)
        Topic[cid] = v.storage
    elseif Topic[cid] == 2 and msgcontains(msg, 'quara') then
        selfSay('There are different types of quaras. The weaker {scouts} which can be found on Malada, one of the shattered Islands and the more skilled {underwater} kind which can be found in Calassa and some smaller colonies. Which one do you wish to hunt?', cid)
        Topic[cid] = 5
    elseif Topic[cid] == 5 and msgcontains(msg, 'scout') then
        local v = tasks['quara constrictor scout']
        selfSay('Good choice! Hunt down those Quara scouts - remember no less than ' .. v.amount .. '! Focus! Do you accept this task?', cid)
        Topic[cid] = v.storage
    elseif Topic[cid] == 5 and msgcontains(msg, 'underwater') then
        local v = tasks['quara constrictor']
        selfSay('As you wish. Seek out a Quara settlement and hunt ' .. v.amount .. ' Quaras, it doesn\'t matter which type you hunt. Alright?', cid)
        Topic[cid] = v.storage
    elseif Topic[cid] == 2 and msgcontains(msg, 'elemental') then
        selfSay({'Since the creation of the elemental shrines and the portals, the curtain separating the worlds is thin, allowing the elementals to surge into our world. They have to be contained. ...', 'The choice as to which kind of elementals you hunt is yours, as long as they are in the lands of Tibia. Hunt 70 {earth}, {energy}, {fire} or {water} elementals. Which one do you choose?'} , cid)
        Topic[cid] = 6
    elseif Topic[cid] == 6 and msgcontains(msg, 'water') then
        local v = tasks['water elemental']
        selfSay('Alright, go hunt ' .. v.amount .. ' water elementals or massive water elementals. Don\'t forget your umbrella! Alright?', cid)
        Topic[cid] = v.storage
    elseif Topic[cid] == 6 and msgcontains(msg, 'earth') then
        local v = tasks['earth elemental']
        selfSay('Good choice! I need you to slay ' .. v.amount .. ' earth elementals or massive earth elementals. There are some in the so called Taboo-area in the eastern jungle of Tiquanda and I heard about a cave in Edron where you\'ll find them. Are you game?', cid)
        Topic[cid] = v.storage
    elseif Topic[cid] == 6 and msgcontains(msg, 'energy') then
        local v = tasks['energy elemental']
        selfSay('A brave hunter! Kill ' .. v.amount .. ' energy elementals or massive energy elementals. You\'ll find them in the mountains between Darama and Tiquanda. Are you sure you want to do this?', cid)
        Topic[cid] = v.storage
    elseif Topic[cid] == 6 and msgcontains(msg, 'fire') then
        local v = tasks['fire elemental']
        selfSay('Don\'t get burnt! Your challenge, should you choose to accept it, is to kill ' .. v.amount .. ' fire elementals or massive fire elementals. Are you ready?', cid)
        Topic[cid] = v.storage
    elseif Topic[cid] == 2 and msgcontains(msg, 'mutated rat') then
        local v = tasks['mutated rat']
        selfSay('Recently, I heard of a disturbing development in Yalahar - a plague of monstrous Mutated rats! If they were to spread to the rest of Tibia.. <shudders> My task for you is to contain their numbers in Yalahar. Hunt ' .. v.amount .. ' of them. What do you say?', cid)
        Topic[cid] = v.storage
    elseif Topic[cid] == 2 and msgcontains(msg, 'giant spider') then
        local v = tasks['giant spider']
        selfSay('Never liked spiders. Entirely too many legs. And I always find them in my bath! Those nasty creepy crawlies are a threat to the hygiene of every living being in Tibia. Hunt ' .. v.amount .. ' of them. Okay?', cid)
        Topic[cid] = v.storage
    elseif Topic[cid] == 3 and msgcontains(msg, 'hydra') then
        local v = tasks['hydra']
        selfSay('The hydras are located in the eastern jungle of Tiquanda and there are several mountain caves that are inhabited by them. Your task is to hunt a mere ' .. v.amount .. ' hydras. Are you willing to do that?', cid)
        Topic[cid] = v.storage
    elseif Topic[cid] == 3 and msgcontains(msg, 'sea serpent') then
        local v = tasks['sea serpent']
        selfSay({'The sea serpents are a threat to honest seafarers! Captain Haba knows where to find them. ...', 'Go to Svargrond and talk to him. ' .. v.amount .. ' sea serpents should be enough to reduce the threat - but not their young though! After all, they are an endangered species! Got it?'}, cid)
        Topic[cid] = v.storage
    elseif Topic[cid] == 3 and msgcontains(msg, 'behemoth') then
        local v = tasks['behemoth']
        selfSay('Behemoths must be kept away from the settlements at all costs. You\'ll find them east of here in the taboo-area or under the cyclopolis in Edron. Go there and hunt a few of them - shall we say... ' .. v.amount .. '? Are you up for that?', cid)
        Topic[cid] = v.storage
    elseif Topic[cid] == 3 and msgcontains(msg, 'serpent spawn') then
        local v = tasks['serpent spawn']
        selfSay('Very dangerous, nasty, slimey creatures. They live deep in the old ruins of Banuta. I think a mere ' .. v.amount .. ' serpent spawns should do the trick. What do you say?', cid)
        Topic[cid] = v.storage
    elseif Topic[cid] == 3 and getPlayerStorageValue(cid, rank) == 5 and msgcontains(msg, 'demon') and getPlayerStorageValue(cid, curTask) < 1 then
        local v = tasks['demon']
        selfSay('The spawn of pure evil must be erased from Tibia. You\'ll find demons lurking in the northern ruins of Edron as well as in some of other deeper dungeons of Tibia. We need to wipe them out! Slay ' .. v.amount .. ' demons for the Greater Good!', cid)
        setPlayerStorageValue(cid, curTask, v.storage)
        setPlayerStorageValue(cid, v.storage, 0)
        Topic[cid] = 0
    elseif Topic[cid] >= 14000 and msgcontains(msg, 'yes') then
        selfSay(data[Topic[cid]][2], cid)
        setPlayerStorageValue(cid, curTask, Topic[cid])
        setPlayerStorageValue(cid, Topic[cid], 0)
        if getPlayerStorageValue(cid, questLog) < 1 then
            setPlayerStorageValue(cid, questLog, 1)
            setPlayerStorageValue(cid, points, 0)
        end
        Topic[cid] = 0
    elseif msgcontains(msg, 'special') and getPlayerStorageValue(cid, rank) == 5 then
        local v, k = getPlayerStorageValue(cid, tiquanda), getPlayerStorageValue(cid, demodras)
        if v < 1 then
            if getPlayerLevel(cid) >= 90 then
                setPlayerStorageValue(cid, tiquanda, 1)
                selfSay({'Have you heard about {Tiquandas Revenge}? It is said that the jungle itself is alive and takes revenge for all the bad things people have done to it. ...', 'I myself believe that there is some truth in this clap trap. Something \'real\' which therefore must have a hideout somewhere. Go find it and take revenge yourself! Ask me about the {special} task when you\'re done.'}, cid)
            else
                selfSay('Your eagerness is commendable, and your rank within our hunting elite is great buuuut I\'m afraid you\'re a little bit too weak for the special tasks. Get more experience and the special tasks will be no match for you.', cid)
            end
        elseif v == 2 then
            selfSay('Great achievement, old chap! You are an outstanding hunter, no doubt about it!', cid)
            setPlayerStorageValue(cid, tiquanda, 3)
        elseif v == 3 and k < 1 then
            if getPlayerLevel(cid) >= 100 then
                setPlayerStorageValue(cid, demodras, 1)
                selfSay('This task is a very dangerous one. I want you to look for {Demodras}\' hideout. It might be somewhere under the {Plains of Havoc}. Good luck, old chap, come back in one piece and ask me about the {special} task when you\'re done.', cid)
            else
                selfSay('Your eagerness is commendable, and your rank within our hunting elite is great buuuut I\'m afraid you\'re a little bit too weak for the special tasks. Get more experience and the special tasks will be no match for you.', cid)
            end
        elseif k == 2 then
            selfSay('Great achievement, old chap! You are an outstanding hunter, no doubt about it!', cid)
            setPlayerStorageValue(cid, demodras, 3)
        end
    elseif msgcontains(msg, 'promotion') then
        local cur, r, msg, exp, item = getPlayerStorageValue(cid, points), getPlayerStorageValue(cid, rank)
        if cur >= 5 and r < 1 then
            msg, exp = {'You have completed 5 tasks! Let me promote you to the first rank: Huntsman. Congratulations! ...', 'If you find any trophies that you don\'t need, feel free to ask me for a trade.'}, 5000
        elseif cur >= 10 and r < 2 then
            msg, exp = {'You have completed 10 hunting tasks. It\'s time for a promotion. You advance to the rank of \'Ranger\'. Congratulations! ...', 'Oh, I made a deal with Lorek. He ships Rangers from our society - and higher ranks of course - to Banuta, Chor or near the mountain pass to Darama. Just ask him for a passage.'}, 8000
        elseif cur >= 20 and r < 3 then
            msg, exp = {'Good show! You have completed 20 hunting tasks for the \'Paw and Fur - Hunting Elite. You have earned the right to join the ranks of those known as \'Big game hunter\'. Congratulations! ...', 'From now on I\'ll buy more trophies from you!'}, 10000
        elseif cur >= 30 and r < 4 then
            msg, exp, item = 'Spiffing! You have done 30 hunting tasks! From now on you can call yourself a \'Trophy hunter\'. As a reward I have this special backpack for you and in addition you can sell some more rare trophies to me.', 15000, 10518
        elseif cur >= 50 and r < 5 then
            msg, exp = 'Congratulations! You have made the highest rank: \'Elite hunter\'. If haven\'t yet done so ask me for the {special} task.', 30000
        end
        if msg then
            selfSay(msg, cid)
            setPlayerStorageValue(cid, rank, math.max(1, r + 1))
            if exp then
                doPlayerAddExp(cid, exp)
                doSendAnimatedText(getThingPos(cid), exp, 215)
            end
            if item then
                doPlayerAddItem(cid, item, 1)
            end
        end
    end
end

npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:setMessage(MESSAGE_FAREWELL, 'Happy hunting, old chap!')
npcHandler:setMessage(MESSAGE_WALKAWAY, 'Happy hunting, old chap!')
npcHandler:setCallback(CALLBACK_GREET, greetCallback)
npcHandler:addModule(FocusModule:new())

 

da erro na linha: obs( esse erro eh na 224 porque eu pedi no jogo a task de hydra se eu pedir outra dara na linha do outro monstro.)

 

36 : function onCreatureSay(cid, type, msg)        npcHandler:onCreatureSay(cid, type, msg)        end

224: local v = tasks['hydra']

 

224: attempt to index global 'tasks' (a nil value)

stack traceback

224: in function 'callback'

393: in function 'onCreatureSay'

36: in function: 36

 

no outro servidor funciona perfeitamente esse script e a distro e 0.4 tambem.. Se alguem sabe ajudar agradeço se confundi me pergunte que tento explicar melhor.

up

Editado por Gustavo12345 (veja o histórico de edições)


Link para o post
Compartilhar em outros sites

Creio que no servidor que você pegou esse script tenha algo definido na lib para o npc de tasks, lá provavelmente é definido o "tasks" que o script não está encontrando no servidor novo.

Link para o post
Compartilhar em outros sites

Em todos arquivos dentro da pasta lib, eu chequei em todos ele procurando por tasks e nao achei nada... 0 results em todas.



Link para o post
Compartilhar em outros sites

Não sei o que pode ser então, talvez esteja definido em outro lugar ou até nas sources, tente instalar esse:

Script do NPC, só trocar pelo seu:

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 choose = {}
local cancel = {}
local available = {}

local grizzlyAdamsConfig = {
                            ranks = {
                                    huntsMan_rank = {
                                                    {id=11208, buy=0, sell=50, name='antlers'},
                                                    {id=10549, buy=0, sell=100, name='bloody pincers'},
                                                    {id=11183, buy=0, sell=35, name='crab pincers'},
                                                    {id=10573, buy=0, sell=55, name='cyclops toe'},
                                                    {id=10564, buy=0, sell=30, name='frosty ear of a troll'},
                                                    {id=11193, buy=0, sell=600, name='hydra head'},
                                                    {id=11366, buy=0, sell=80, name='lancer beetle shell'},
                                                    {id=10578, buy=0, sell=420, name='mutated bat ear'},
                                                    {id=11222, buy=0, sell=400, name='sabretooth'},
                                                    {id=11367, buy=0, sell=20, name='sandcrawler shell'},
                                                    {id=10547, buy=0, sell=280, name='scarab pincers'},
                                                    {id=11365, buy=0, sell=60, name='terramite legs'},
                                                    {id=11363, buy=0, sell=170, name='terramite shell'},
                                                    {id=11184, buy=0, sell=30000, name='terrorbird beak'},
                                                    
                                                    {id=7398, buy=0, sell=500, name='cyclops trophy'},
                                                    {id=11315, buy=0, sell=15000, name='draken trophy'},
                                                    {id=11330, buy=0, sell=8000, name='lizard trophy'},
                                                    {id=7401, buy=0, sell=500, name='minotaur trophy'}
                                                    },

                                    bigGameHunter_rank = {
                                                    {id=7397, buy=0, sell=3000, name='deer trophy'},
                                                    {id=7400, buy=0, sell=3000, name='lion trophy'},
                                                    {id=7394, buy=0, sell=3000, name='wolf trophy'}
                                                    },

                                    trophyHunter_rank = {
                                                    {id=7393, buy=0, sell=40000, name='demon trophy'},
                                                    {id=7396, buy=0, sell=20000, name='behemoth trophy'},
                                                    {id=7399, buy=0, sell=10000, name='dragon lord trophy'},
                                                    
                                                    {id=10518, buy=1000, sell=0, name='demon backpack'},
                                                    },
                                    }
                            }

local Topic = {}
function greetCallback(cid)
    Topic[cid] = 0
    return true
end

local function setNewTradeTable(table)
local items = {}
for _, v in ipairs(table) do
    items[v.id] = {itemId = v.id, buyPrice = v.buy, sellPrice = v.sell, subType = 0, realName = v.name}
end
return items
end

local function setNewLineTable(oldTable, newTable)
for k, v in pairs(oldTable) do
    table.insert(newTable, k, v)
end
return true
end

function creatureSayCallback(cid, type, msg)
    local talkUser = NPCHANDLER_CONVBEHAVIOR == CONVERSATION_PRIVATE and 0 or cid
if (msgcontains(msg, "hi") or msgcontains(msg, "hello")) and (not npcHandler:isFocused(cid)) then
if (getPlayerStorageValue(cid, 100157) == -1) then
        npcHandler:say("Welcome "..getCreatureName(cid)..". Would you like to join the 'Paw and Fur - Hunting Elite'?", cid)
        npcHandler:addFocus(cid)
        talkState[talkUser] = 5
  else
        npcHandler:say("Welcome back old chap. What brings you here this time?", cid)
        npcHandler:addFocus(cid)
        talkState[talkUser] = 0
        end
        return true
    end
 
    if(not npcHandler:isFocused(cid)) then
        return false
    end
    
    if msgcontains(msg, "bye") or msgcontains(msg, "farewell") then
        selfSay("Happy hunting, old chap!", cid, TRUE)
        Topic[talkUser] = 0
        npcHandler:releaseFocus(cid)
        npcHandler:resetNpc(cid)
    end
    
    if (isInArray({"yes", "join"}, msg:lower()) and talkState[talkUser] == 5) then
        setPlayerStorageValue(cid, 100157, 1)
        npcHandler:say("Great! A warm welcome to our newest member: "..getCreatureName(cid).."! Ask me for a {task} if you want to go on a hunt.", cid)
        talkState[talkUser] = 0
   elseif (msg:lower() == "no" and talkState[talkUser] == 5) then
        npcHandler:say("No problem old chap. Come back if you change your mind.", cid)  
   end

if (getPlayerStorageValue(cid, 100157) == -1) then
    npcHandler:say("You'll have to {join} us to get more information.",cid)
    return false
end
if isInArray({"offer", "trade"}, msg:lower()) then
if getPlayerRank(cid) >= 2 then
        if getPlayerRank(cid) == 2 or getPlayerRank(cid) == 3 then
            tradeRank = grizzlyAdamsConfig.ranks.huntsMan_rank
        elseif getPlayerRank(cid) == 4 then
            tradeRank = grizzlyAdamsConfig.ranks.bigGameHunter_rank
            setNewLineTable(grizzlyAdamsConfig.ranks.huntsMan_rank, grizzlyAdamsConfig.ranks.bigGameHunter_rank)
        elseif getPlayerRank(cid) == 5 or getPlayerRank(cid) == 6 then
            tradeRank = grizzlyAdamsConfig.ranks.trophyHunter_rank
            setNewLineTable(grizzlyAdamsConfig.ranks.huntsMan_rank, grizzlyAdamsConfig.ranks.bigGameHunter_rank)
            setNewLineTable(grizzlyAdamsConfig.ranks.huntsMan_rank, grizzlyAdamsConfig.ranks.trophyHunter_rank)
        end
        local items = setNewTradeTable(tradeRank)
            local function onBuy(cid, item, subType, amount, ignoreCap, inBackpacks)
            if ignoreCap == false and (getPlayerFreeCap(cid) < getItemWeightById(items[item].itemId, amount) or inBackpacks and getPlayerFreeCap(cid) < (getItemWeightById(items[item].itemId, amount) + getItemWeightById(1988, 1))) then
                return doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, 'You don\'t have enough cap.')
            end
            if items[item].buyPrice then
                doPlayerRemoveMoney(cid, amount * items[item].buyPrice)
                for i = 1, amount do
                    if inBackpacks then
                        local backpack = doCreateItemEx(1988, 1)
                        doAddContainerItem(backpack, items[item].itemId, amount)
                    else
                        doPlayerAddItem(cid, items[item].itemId, amount, true)
                    end
                end
                return doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, 'You bought '..amount..'x '..items[item].realName..' for '..items[item].buyPrice * amount..' gold coins.')
            end
            return true
            end
            
            local function onSell(cid, item, subType, amount, ignoreCap, inBackpacks)
            if items[item].sellPrice then
                doPlayerAddMoney(cid, items[item].sellPrice * amount)
                doPlayerRemoveItem(cid, items[item].itemId, amount)
                return doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, 'You sold '..amount..'x '..items[item].realName..' for '..items[item].sellPrice * amount..' gold coins.')
            end
            return true
            end
        openShopWindow(cid, tradeRank, onBuy, onSell)
        return selfSay('It\'s my offer.', cid)
    else
        return selfSay('You don\'t have any rank.', cid)
        end
end
 
    if isInArray({"tasks", "task", "mission"}, msg:lower()) then
        local can = getTasksByPlayer(cid)
        if (getPlayerStorageValue(cid, 100157) == -1) then
             return (npcHandler:say("You'll have to {join}, to get any {tasks}.",cid))
        end
        if #can > 0 then
            local text = ""
            local sep = ", "
            table.sort(can, (function(a, b) return (a < b) end))
            local t = 0
            for _, id in ipairs(can) do
                t = t + 1
                if t == #can - 1 then
                    sep = " and "
                elseif t == #can then
                    sep = "."
                end
                text = text .. "{" .. (tasks[id].name or tasks[id].raceName) .. "}" .. sep
            end
            selfSay("The current task" .. (#can > 1 and "s" or "") .. " that you can choose " .. (#can > 1 and "are" or "is") .. " " .. text, cid)
            talkState[talkUser] = 0
        else
            selfSay("I don't have any task for you right now.", cid)
        end
    elseif msg ~= "" and canStartTask(cid, msg) then
        if #getPlayerStartedTasks(cid) >= tasksByPlayer then
            selfSay("Sorry, but you already started " .. tasksByPlayer .. " tasks. You can check their {status} or {cancel} a task.", cid)
            return true
        end
        local task = getTaskByName(msg)
        if task and getCreatureStorage(cid, QUESTSTORAGE_BASE + task) > 0 then  
            return false
        end
        selfSay("In this task you must defeat " .. tasks[task].killsRequired .. " " .. tasks[task].raceName .. ". Are you sure that you want to start this task?", cid)
        choose[cid] = task
        talkState[talkUser] = 1
    elseif msg:lower() == "yes" and talkState[talkUser] == 1 then
        doCreatureSetStorage(cid, QUESTSTORAGE_BASE + choose[cid], 1)
        selfSay("Excellent! You can check the {status} of your task saying {report} to me. Also you can {cancel} tasks to.", cid)
        choose[cid] = nil
        talkState[talkUser] = 0    
    elseif (msg:lower() == "report" or msg:lower() == "status") then
        local started = getPlayerStartedTasks(cid)
        local finishedAtLeastOne = false
        local finished = 0
        if started and #started > 0 then
            for _, id in ipairs(started) do
                if getCreatureStorage(cid, KILLSSTORAGE_BASE + id) >= tasks[id].killsRequired then
                    for _, reward in ipairs(tasks[id].rewards) do
                        local deny = false
                        if reward.storage then
                            if getCreatureStorage(cid, reward.storage[1]) >= reward.storage[2] then
                                deny = true
                            end
                        end
                        if isInArray({REWARD_MONEY, "money"}, reward.type:lower()) and not deny then
                            doPlayerAddMoney(cid, reward.value[1])
                        elseif isInArray({REWARD_EXP, "exp", "experience"}, reward.type:lower()) and not deny then
                            doPlayerAddExperience(cid, reward.value[1])
                            doPlayerSendDefaultCancel(cid, "You gained " .. reward.value[1] .. " experience points.")
                        elseif isInArray({REWARD_ACHIEVEMENT, "achievement", "ach"}, reward.type:lower()) and not deny then
                            if doPlayerAddAchievement then
                                doPlayerAddAchievement(cid, reward.value[1], true)
                            end
                        elseif isInArray({REWARD_STORAGE, "storage", "stor"}, reward.type:lower()) and not deny then
                            doCreatureSetStorage(cid, reward.value[1], reward.value[2])
                        elseif isInArray({REWARD_POINT, "points", "point"}, reward.type:lower()) and not deny then
                            doCreatureSetStorage(cid, POINTSSTORAGE, getCreatureStorage(cid, POINTSSTORAGE) + reward.value[1])
                        elseif isInArray({REWARD_ITEM, "item", "items", "object"}, reward.type:lower()) and not deny then
                            doPlayerAddItem(cid, reward.value[1], reward.value[2])
                        end
 
                        if reward.storage then
                            doCreatureSetStorage(cid, reward.storage[1], reward.storage[2])
                        end
                    end
 
                    if tasks[id].norepeatable then
                        doCreatureSetStorage(cid, QUESTSTORAGE_BASE + id, 2)
                    else
                        doCreatureSetStorage(cid, QUESTSTORAGE_BASE + id, 0)
                    end
                    doCreatureSetStorage(cid, KILLSSTORAGE_BASE + id, 0)
                    if getCreatureStorage(cid, REPEATSTORAGE_BASE + id) < 1 then
                        doCreatureSetStorage(cid, REPEATSTORAGE_BASE + id, 0)
                    end
                    doCreatureSetStorage(cid, REPEATSTORAGE_BASE + id, getCreatureStorage(cid, REPEATSTORAGE_BASE + id) + 1)
                    finishedAtLeastOne = true
                    finished = finished + 1
                end
            end
 
            if not finishedAtLeastOne then
         local started = getPlayerStartedTasks(cid)
        if started and #started > 0 then
            local text = ""
            local sep = ", "
            table.sort(started, (function(a, b) return (a < b) end))
            local t = 0
            for _, id in ipairs(started) do
                t = t + 1
                if t == #started - 1 then
                    sep = " and "
                elseif t == #started then
                    sep = "."
                end
                text = text .. "{" .. (tasks[id].name or tasks[id].raceName) .. "}" .. sep
            end
                selfSay("The current task" .. (#started > 1 and "s" or "") .. " that you started " .. (#started > 1 and "are" or "is") .. " " .. text, cid)
                Topic[cid] = 1
            else
                selfSay("Awesome! you finished " .. (finished > 1 and "various" or "a") .. " task" .. (finished > 1 and "s" or "") .. ". Talk to me again if you want to start a {task}.", cid)
            end
        else
            selfSay("You haven't started any task yet.", cid)
        end
        end
    elseif msg:lower() == "started" then
        local started = getPlayerStartedTasks(cid)
        if started and #started > 0 then
            local text = ""
            local sep = ", "
            table.sort(started, (function(a, b) return (a < b) end))
            local t = 0
            for _, id in ipairs(started) do
                t = t + 1
                if t == #started - 1 then
                    sep = " and "
                elseif t == #started then
                    sep = "."
                end
                text = text .. "{" .. (tasks[id].name or tasks[id].raceName) .. "}" .. sep
            end
 
            selfSay("The current task" .. (#started > 1 and "s" or "") .. " that you started " .. (#started > 1 and "are" or "is") .. " " .. text, cid)
        else
            selfSay("You haven't started any task yet.", cid)
        end
    elseif msg:lower() == "cancel" then
        local started = getPlayerStartedTasks(cid)
        local task = getTaskByName(msg)
        local text = ""
            local sep = ", "
            table.sort(started, (function(a, b) return (a < b) end))
            local t = 0
            for _, id in ipairs(started) do
                t = t + 1
                if t == #started - 1 then
                    sep = " or "
                elseif t == #started then
                    sep = "?"
                end
                text = text .. "{" .. (tasks[id].name or tasks[id].raceName) .. "}" .. sep
            end
        if started and #started > 0 then
            selfSay("Cancelling a task will make the counter restart. Which of these tasks you want cancel?" .. (#started > 1 and "" or "") .. " " .. text, cid)
            talkState[talkUser] = 2
        else
            selfSay("You haven't started any task yet.", cid)
        end
    elseif getTaskByName(msg) and talkState[talkUser] == 2 and isInArray(getPlayerStartedTasks(cid), getTaskByName(msg)) then
        local task = getTaskByName(msg)
        if getCreatureStorage(cid, KILLSSTORAGE_BASE + task) > 0 then
            selfSay("You currently killed " .. getCreatureStorage(cid, KILLSSTORAGE_BASE + task) .. "/" .. tasks[task].killsRequired .. " " .. tasks[task].raceName .. ". Cancelling this task will restart the count. Are you sure you want to cancel this task?", cid)
        else
            selfSay("Are you sure you want to cancel this task?", cid)
        end
        talkState[talkUser] = 3
        cancel[cid] = task
    elseif getTaskByName(msg) and Topic[cid] == 1 and isInArray(getPlayerStartedTasks(cid), getTaskByName(msg)) then
        local task = getTaskByName(msg)
        if getCreatureStorage(cid, KILLSSTORAGE_BASE + task) > 0 then
            selfSay("You currently killed " .. getCreatureStorage(cid, KILLSSTORAGE_BASE + task) .. "/" .. tasks[task].killsRequired .. " " .. tasks[task].raceName .. ".", cid)
            Topic[cid] = 0
        else
            selfSay("You haven't started any task yet.", cid)
        end
    elseif msg:lower() == "yes" and talkState[talkUser] == 3 then
        doCreatureSetStorage(cid, QUESTSTORAGE_BASE + cancel[cid], -1)
        doCreatureSetStorage(cid, KILLSSTORAGE_BASE + cancel[cid], -1)
        selfSay("You have cancelled the task " .. (tasks[cancel[cid]].name or tasks[cancel[cid]].raceName) .. ".", cid)
        talkState[talkUser] = 0
    elseif isInArray({"points", "rank"}, msg:lower()) then
        if getCreatureStorage(cid, POINTSSTORAGE) < 1 then
        selfSay("At this time, you have 0 Paw & Fur points. You " .. (getPlayerRank(cid) == 6 and "are an Elite Hunter" or getPlayerRank(cid) == 5 and "are a Trophy Hunter" or getPlayerRank(cid) == 4 and "are a Big Game Hunter" or getPlayerRank(cid) == 3 and "are a Ranger" or getPlayerRank(cid) == 2 and "are a Huntsman" or getPlayerRank(cid) == 1 and "are a Member"  or "haven't been ranked yet") .. ".", cid)
        elseif getCreatureStorage(cid, POINTSSTORAGE) >= 1 then
        selfSay("At this time, you have " .. getCreatureStorage(cid, POINTSSTORAGE) .. " Paw & Fur points. You " .. (getPlayerRank(cid) == 6 and "are an Elite Hunter" or getPlayerRank(cid) == 5 and "are a Trophy Hunter" or getPlayerRank(cid) == 4 and "are a Big Game Hunter" or getPlayerRank(cid) == 3 and "are a Ranger" or getPlayerRank(cid) == 2 and "are a Huntsman" or getPlayerRank(cid) == 1 and "are a Member"  or "haven't been ranked yet") .. ".", cid)
        end
        talkState[talkUser] = 0
    end
end
 
npcHandler:setMessage(MESSAGE_FAREWELL, "Happy hunting, old chap!")
npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)

 

Agora em "Data/lib" crie 104-KillingInTheNameOf.lua e cole:

RANK_NONE = 0
RANK_JOIN = 1
RANK_HUNTSMAN = 2
RANK_RANGER = 3
RANK_BIGGAMEHUNTER = 4
RANK_TROPHYHUNTER = 5
RANK_ELITEHUNTER = 6
 
REWARD_MONEY = 1
REWARD_EXP = 2
REWARD_ACHIEVEMENT = 3
REWARD_STORAGE = 4
REWARD_POINT = 5
REWARD_ITEM = 6
 
QUESTSTORAGE_BASE = 1500
JOIN_STOR = 100157
KILLSSTORAGE_BASE = 65000
REPEATSTORAGE_BASE = 48950
POINTSSTORAGE = 2500
tasks =
{
    --Tasks for level 6 to 49.
    [1] = {killsRequired = 100, raceName = "Trolls", level = {6, 19}, premium = true, creatures = {"troll", "troll champion", "island troll", "swamp troll"}, rewards = {
                                                                                                                                        {type = "exp", value = {200}},
                                                                                                                                        {type = "money", value = {200}}
                                                                                                                                    }},
    [2] = {killsRequired = 150, raceName = "Goblins", level = {6, 19}, premium = true, creatures = {"goblin", "goblin assassin", "goblin leader"}, rewards = {
                                                                                                                                        {type = "exp", value = {300}},
                                                                                                                                        {type = "money", value = {250}}
                                                                                                                                    }},
    [3] = {killsRequired = 300, raceName = "Crocodiles", level = {6, 49}, premium = true, creatures = {"crocodile"}, rewards = {
                                                                                                                                        {type = "exp", value = {800}},
                                                                                                                                        {type = "achievement", value = {"Blood-Red Snapper"}},
                                                                                                                                        {type = "storage", value = {35000, 1}},
                                                                                                                                        {type = "points", value = {1}}
                                                                                                                                    }},
    [4] = {killsRequired = 300, raceName = "Badgers", level = {6, 49}, premium = true, creatures = {"badger"}, rewards = {
                                                                                                                                        {type = "exp", value = {500}},
                                                                                                                                        {type = "points", value = {1}}
                                                                                                                                    }},
    [5] = {killsRequired = 300, raceName = "Tarantulas", level = {6, 49}, premium = true, creatures = {"tarantula"}, rewards = {
                                                                                                                                        {type = "exp", value = {1500}},
                                                                                                                                        {type = "achievement", value = {"No More Hiding"}},
                                                                                                                                        {type = "storage", value = {35001, 1}},
                                                                                                                                        {type = "points", value = {2}}
                                                                                                                                    }},
    [6] = {killsRequired = 150, raceName = "Carniphilas", level = {6, 49}, premium = true, creatures = {"carniphila"}, rewards = {
                                                                                                                                        {type = "exp", value = {2500}},
                                                                                                                                        {type = "achievement", value = {"Rootless Behaviour"}},
                                                                                                                                        {type = "storage", value = {35002, 1}},
                                                                                                                                        {type = "points", value = {3}}
                                                                                                                                    }},
    [7] = {killsRequired = 200, raceName = "Stone Golems", level = {6, 49}, premium = true, creatures = {"stone golem"}, rewards = {
                                                                                                                                        {type = "exp", value = {2000}},
                                                                                                                                        {type = "points", value = {3}}
                                                                                                                                    }},
    [8] = {killsRequired = 300, raceName = "Mammoths", level = {6, 49}, premium = true, creatures = {"mammoth"}, rewards = {
                                                                                                                                        {type = "exp", value = {4000}},
                                                                                                                                        {type = "achievement", value = {"Meat Skewer"}},
                                                                                                                                        {type = "storage", value = {35003, 1}},
                                                                                                                                        {type = "points", value = {3}}
                                                                                                                                    }},
    [9] = {killsRequired = 300, raceName = "Gnarlhounds", level = {6, 49}, premium = true, creatures = {"gnarlhound"}, rewards = {
                                                                                                                                        {type = "exp", value = {1000}},
                                                                                                                                        {type = "points", value = {2}}
                                                                                                                                    }},
    [10] = {killsRequired = 300, raceName = "Terramites", level = {6, 49}, premium = true, creatures = {"terramite"}, rewards = {
                                                                                                                                        {type = "exp", value = {1000}},
                                                                                                                                        {type = "points", value = {2}}
                                                                                                                                    }},
    [11] = {killsRequired = 300, raceName = "Apes", level = {6, 49}, premium = true, creatures = {"kongra", "sibang", "merklin"}, rewards = {
                                                                                                                                        {type = "exp", value = {1000}},
                                                                                                                                        {type = "points", value = {2}}
                                                                                                                                    }},
    [12] = {killsRequired = 300, raceName = "Thornback Tortoises", level = {6, 49}, premium = true, creatures = {"thornback tortoise"}, rewards = {
                                                                                                                                        {type = "exp", value = {1500}},
                                                                                                                                        {type = "points", value = {2}}
                                                                                                                                    }},
    [13] = {killsRequired = 300, raceName = "Gargoyles", level = {6, 49}, premium = true, creatures = {"gargoyle"}, rewards = {
                                                                                                                                        {type = "exp", value = {1500}}
                                                                                                                                    }},
 
    --Tasks for level 50 to 79.
 
    [14] = {killsRequired = 300, raceName = "Ice Golems", level = {50, 79}, premium = true, creatures = {"ice golem"}, rewards = {
                                                                                                                                        {type = "exp", value = {12000}},
                                                                                                                                        {type = "achievement", value = {"Breaking The Ice"}},
                                                                                                                                        {type = "storage", value = {35004, 1}},
                                                                                                                                        {type = "points", value = {2}}
                                                                                                                                    }},
    [15] = {killsRequired = 400, raceName = "Quara Scouts", level = {50, 79}, premium = true, creatures = {"quara pincher scout", "quara predator scout", "quara hydromancer scout", "quara constrictor scout", "quara mantassin scout"}, rewards = {
                                                                                                                                        {type = "exp", value = {10000}},
                                                                                                                                        {type = "points", value = {2}}
                                                                                                                                    }},
    [16] = {killsRequired = 400, raceName = "Mutated Rats", level = {50, 79}, premium = true, creatures = {"mutated rat"}, rewards = {
                                                                                                                                        {type = "exp", value = {10000}},
                                                                                                                                        {type = "achievement", value = {"Twisted Mutation"}},
                                                                                                                                        {type = "storage", value = {35005, 1}},
                                                                                                                                        {type = "points", value = {2}}
                                                                                                                                    }},                                                                                                
    [17] = {killsRequired = 250, raceName = "Ancient Scarabs", level = {50, 79}, premium = true, creatures = {"ancient scarab"}, rewards = {
                                                                                                                                        {type = "exp", value = {15000}},
                                                                                                                                        {type = "achievement", value = {"Crawling Death"}},
                                                                                                                                        {type = "storage", value = {35006, 1}},
                                                                                                                                        {type = "points", value = {2}}
                                                                                                                                    }},    
    [18] = {killsRequired = 300, raceName = "Wyverns", level = {50, 79}, premium = true, creatures = {"wyvern"}, rewards = {
                                                                                                                                        {type = "exp", value = {12000}},
                                                                                                                                        {type = "points", value = {2}}
                                                                                                                                    }},                                                                                                        
    [19] = {killsRequired = 300, raceName = "Lancer Beetles", level = {50, 79}, premium = true, creatures = {"lancer beetle"}, rewards = {
                                                                                                                                        {type = "exp", value = {8000}},
                                                                                                                                        {type = "points", value = {2}}
                                                                                                                                    }},                                                                                                        
    [20] = {killsRequired = 400, raceName = "Wailing Widows", level = {50, 79}, premium = true, creatures = {"wailing widow"}, rewards = {
                                                                                                                                        {type = "exp", value = {12000}},
                                                                                                                                        {type = "points", value = {3}}
                                                                                                                                    }},                                                                                                        
    [21] = {killsRequired = 250, raceName = "Killer Caimans", level = {50, 79}, premium = true, creatures = {"killer caiman"}, rewards = {
                                                                                                                                        {type = "exp", value = {10000}},
                                                                                                                                        {type = "points", value = {2}}
                                                                                                                                    }},                                                                                                        
    [22] = {killsRequired = 300, raceName = "Bonebeasts", level = {50, 79}, premium = true, creatures = {"bonebeast"}, rewards = {
                                                                                                                                        {type = "exp", value = {12000}},
                                                                                                                                        {type = "achievement", value = {"Spareribs for Dinner"}},
                                                                                                                                        {type = "storage", value = {35007, 1}},
                                                                                                                                        {type = "points", value = {2}}
                                                                                                                                    }},    
    [23] = {killsRequired = 300, raceName = "Crystal Spiders", level = {50, 79}, creatures = {"crystal spider"}, premium = true, rewards = {
                                                                                                                                        {type = "exp", value = {15000}},
                                                                                                                                        {type = "achievement", value = {"Arachnoise"}},
                                                                                                                                        {type = "storage", value = {35008, 1}},
                                                                                                                                        {type = "points", value = {3}}
                                                                                                                                    }},    
    [24] = {killsRequired = 300, raceName = "Mutated Tigers", level = {50, 79}, premium = true, creatures = {"mutated tiger"}, rewards = {
                                                                                                                                        {type = "exp", value = {12000}},
                                                                                                                                        {type = "points", value = {2}}
                                                                                                                                    }},    
 
    --Taks for level 80 to 129.
 
    [25] = {killsRequired = 600, raceName = "Underwater Quara", level = {80, 129}, premium = true, creatures = {"quara hydromancer", "quara predator", "quara constrictor", "quara mantassin", "quara pincher"}, rewards = {
                                                                                                                                        {type = "exp", value = {15000}},
                                                                                                                                        {type = "achievement", value = {"Back into the Abyss"}},
                                                                                                                                        {type = "storage", value = {35009, 1}},
                                                                                                                                        {type = "points", value = {3}}
                                                                                                                                    }},    
 
    [26] = {killsRequired = 500, raceName = "Giant Spiders", level = {80, 129}, premium = true, creatures = {"giant spider"}, rewards = {
                                                                                                                                        {type = "exp", value = {20000}},
                                                                                                                                        {type = "achievement", value = {"Choking on Her Venom"}},
                                                                                                                                        {type = "storage", value = {35010, 1}},
                                                                                                                                        {type = "points", value = {3}}
                                                                                                                                    }},    
 
    [27] = {killsRequired = 300, raceName = "Werewolves", level = {80, 129}, premium = true, creatures = {"werewolf"}, rewards = {
                                                                                                                                        {type = "exp", value = {30000}},
                                                                                                                                        {type = "achievement", value = {"Howly Silence"}},
                                                                                                                                        {type = "storage", value = {35011, 1}},
                                                                                                                                        {type = "points", value = {4}}
                                                                                                                                    }},
 
    [28] = {killsRequired = 400, raceName = "Nightmares", level = {80, 129}, premium = true, creatures = {"nightmare", "nightmare scion"}, rewards = {
                                                                                                                                        {type = "exp", value = {25000}},
                                                                                                                                        {type = "achievement", value = {"Dream is Over"}},
                                                                                                                                        {type = "storage", value = {35012, 1}},
                                                                                                                                        {type = "points", value = {3}}
                                                                                                                                    }},        
 
    [29] = {killsRequired = 600, raceName = "Hellspawns", level = {80, 129}, premium = true, creatures = {"hellspawn"}, rewards = {
                                                                                                                                        {type = "exp", value = {25000}},
                                                                                                                                        {type = "achievement", value = {"Scorched Flames"}},
                                                                                                                                        {type = "storage", value = {35013, 1}}
                                                                                                                                    }},
 
    [30] = {killsRequired = 800, raceName = "High Class Lizards", level = {80, 129}, premium = true, creatures = {"lizard chosen", "lizard dragon priest", "lizard high guard", "lizard legionnaire"}, rewards = {
                                                                                                                                        {type = "exp", value = {30000}},
                                                                                                                                        {type = "achievement", value = {"Zzztill Zzztanding!"}},
                                                                                                                                        {type = "storage", value = {35014, 1}},
                                                                                                                                        {type = "points", value = {3}}
                                                                                                                                    }},
 
    [31] = {killsRequired = 600, raceName = "Stampors", level = {80, 129}, premium = true, creatures = {"stampor"}, rewards = {
                                                                                                                                        {type = "exp", value = {20000}},
                                                                                                                                        {type = "achievement", value = {"Stepped on a Big Toe"}},
                                                                                                                                        {type = "storage", value = {35015, 1}},
                                                                                                                                        {type = "points", value = {3}}
                                                                                                                                    }},        
 
    [32] = {killsRequired = 500, raceName = "Brimstone Bugs", level = {80, 129}, premium = true, creatures = {"brimstone bug"}, rewards = {
                                                                                                                                        {type = "exp", value = {15000}},
                                                                                                                                        {type = "achievement", value = {"Something Smells"}},
                                                                                                                                        {type = "storage", value = {35016, 1}},
                                                                                                                                        {type = "points", value = {3}}
                                                                                                                                    }},    
 
    [33] = {killsRequired = 400, raceName = "Mutated Bats", level = {80, 129}, premium = true, creatures = {"mutated bat"}, rewards = {
                                                                                                                                        {type = "exp", value = {20000}},
                                                                                                                                        {type = "achievement", value = {"Kapow!"}},
                                                                                                                                        {type = "storage", value = {35017, 1}},
                                                                                                                                        {type = "points", value = {2}}
                                                                                                                                    }},        
 
    --Tasks for level 130+                                                                                                    
    [34] = {killsRequired = 650, raceName = "Hydras", level = {130, 9999}, premium = true, creatures = {"hydra"}, rewards = {
                                                                                                                                        {type = "exp", value = {30000}},
                                                                                                                                        {type = "achievement", value = {"One Less"}},
                                                                                                                                        {type = "storage", value = {35018, 1}},
                                                                                                                                        {type = "points", value = {3}}
                                                                                                                                    }},    
 
    [35] = {killsRequired = 800, raceName = "Serpent Spawns", level = {130, 9999}, premium = true, creatures = {"serpent spawn"}, rewards = {
                                                                                                                                        {type = "exp", value = {30000}},
                                                                                                                                        {type = "achievement", value = {"Hissing Downfall"}},
                                                                                                                                        {type = "storage", value = {35019, 1}},
                                                                                                                                        {type = "points", value = {4}}
                                                                                                                                    }},        
 
    [36] = {killsRequired = 500, raceName = "Medusae", level = {130, 9999}, premium = true, creatures = {"medusa"}, rewards = {
                                                                                                                                        {type = "exp", value = {40000}},
                                                                                                                                        {type = "achievement", value = {"The Serpent's Bride"}},
                                                                                                                                        {type = "storage", value = {35020, 1}},
                                                                                                                                        {type = "points", value = {5}}
                                                                                                                                    }},    
 
    [37] = {killsRequired = 700, raceName = "Behemoths", level = {130, 9999}, premium = true, creatures = {"behemoth"}, rewards = {
                                                                                                                                        {type = "exp", value = {30000}},
                                                                                                                                        {type = "achievement", value = {"Just Cracked Me Up!"}},
                                                                                                                                        {type = "storage", value = {35021, 1}},
                                                                                                                                        {type = "points", value = {4}}
                                                                                                                                    }},    
 
    [38] = {killsRequired = 900, raceName = "Sea Serpents and Young Sea Serpents", level = {130, 9999}, premium = true, creatures = {"sea serpent", "young sea serpent"}, rewards = {
                                                                                                                                        {type = "exp", value = {30000}},
                                                                                                                                        {type = "achievement", value = {"The Drowned Sea God"}},
                                                                                                                                        {type = "storage", value = {35022, 1}},
                                                                                                                                        {type = "points", value = {4}}
                                                                                                                                    }},        
 
    [39] = {killsRequired = 250, raceName = "Hellhounds", level = {130, 9999}, premium = true, creatures = {"hellhound"}, rewards = {
                                                                                                                                        {type = "exp", value = {40000}},
                                                                                                                                        {type = "achievement", value = {"The Gates of Hell"}},
                                                                                                                                        {type = "storage", value = {35023, 1}},
                                                                                                                                        {type = "points", value = {5}}
                                                                                                                                    }},        
 
    [40] = {killsRequired = 500, raceName = "Ghastly Dragons", level = {130, 9999}, premium = true, creatures = {"ghastly dragon"}, rewards = {
                                                                                                                                        {type = "exp", value = {30000}},
                                                                                                                                        {type = "achievement", value = {"Beautiful Agony"}},
                                                                                                                                        {type = "storage", value = {35024, 1}},
                                                                                                                                        {type = "points", value = {5}}
                                                                                                                                    }},        
 
    [41] = {killsRequired = 900, raceName = "Drakens", level = {130, 9999}, premium = true, creatures = {"draken spellweaver", "draken warmaster", "draken abomination", "draken elite"} , rewards = {
                                                                                                                                        {type = "exp", value = {30000}},
                                                                                                                                        {type = "achievement", value = {"Enter zze Draken!"}},
                                                                                                                                        {type = "storage", value = {35025, 1}},
                                                                                                                                        {type = "points", value = {3}}
                                                                                                                                    }},    
 
    [42] = {killsRequired = 650, raceName = "Destroyers", level = {130, 9999}, premium = true, creatures = {"destroyer"}, rewards = {
                                                                                                                                        {type = "exp", value = {30000}},
                                                                                                                                        {type = "achievement", value = {"Best there was!"}},
                                                                                                                                        {type = "storage", value = {35026, 1}},
                                                                                                                                        {type = "points", value = {4}}
                                                                                                                                    }},            
 
    [43] = {killsRequired = 400, raceName = "Undead Dragons", level = {130, 9999}, premium = true, creatures = {"undead dragon"}, rewards = {
                                                                                                                                        {type = "exp", value = {50000}},
                                                                                                                                        {type = "achievement", value = {"Back from the Dead"}},
                                                                                                                                        {type = "storage", value = {35027, 1}},
                                                                                                                                        {type = "points", value = {6}}
                                                                                                                                    }},    
 
    --Special tasks.
 
    [44] = {killsRequired = 6666, raceName = "Demons", level = {130, 9999}, rank = RANK_ELITEHUNTER, premium = true, creatures = {"demon"}, rewards = {
                                                                                                                                        {type = "storage", value = {41300, 1}} --Storage that let's you to start Demon Oak
                                                                                                                                    }},
 
    [45] = {killsRequired = 500, raceName = "Green Djinns or Efreets", level = {1, 9999}, storage = {12500, 1}, premium = true, creatures = {"green djinn", "efreet"}, rewards = { --Requires an storage (Gained on The Djinn War - Marid Faction)
                                                                                                                                        {type = "exp", value = {10000}},
                                                                                                                                        {type = "money", value = {5000}},
                                                                                                                                        {type = "storage", value = {35028, 1}}
                                                                                                                                    }},
 
    [46] = {killsRequired = 500, raceName = "Blue Djinns or Marids", level = {1, 9999}, storage = {12501, 1}, premium = true, creatures = {"blue djinn", "marid"}, rewards = { --Requires an storage (Gained on The Djinn War - Efreet Faction)
                                                                                                                                        {type = "exp", value = {10000}},
                                                                                                                                        {type = "money", value = {5000}},
                                                                                                                                        {type = "storage", value = {35029, 1}}
                                                                                                                                    }},        
 
    [47] = {killsRequired = 3000, raceName = "Pirates", level = {1, 9999}, storage = {12600, 1}, premium = true, creatures = {"pirate ghost", "pirate marauder", "pirate cutthroad", "pirate buccaneer", "pirate corsair", "pirate skeleton"}, rewards = { --Requires an storage (Gained on The Shattered Isles Quest)
                                                                                                                                        {type = "exp", value = {10000}},
                                                                                                                                        {type = "money", value = {5000}},
                                                                                                                                        {type = "storage", value = {35030, 1}}
                                                                                                                                    }},    
 
    [48] = {killsRequired = 3000, raceName = "Pirates second task", level = {1, 9999}, storage = {REPEATSTORAGE_BASE + 47, 3}, norepeatable = true, premium = true, creatures = {"pirate ghost", "pirate marauder", "pirate cutthroad", "pirate buccaneer", "pirate corsair", "pirate skeleton"}, rewards = { --Requires an storage (Gained completing Raymond Striker's first task three times.) NOTE: The required storage to start this task is: base + first pirate task id (47)
                                                                                                                                        {type = "exp", value = {10000}},
                                                                                                                                        {type = "money", value = {5000}},
                                                                                                                                        {type = "storage", value = {35031, 1}}
                                                                                                                                    }},    
 
    [49] = {killsRequired = 5000, raceName = "Minotaurs", level = {1, 40}, storage = {12700, 1}, norepeatable = true, premium = false, creatures = {"minotaur", "minotaur mage", "minotaur archer"}, rewards = { --Requires an storage (Gained on To Outfox a Fox Quest)
                                                                                                                                        {type = "storage", value = {35032, 1}}
                                                                                                                                    }},
 
    [50] = {killsRequired = 4000, raceName = "Necromancers and Priestess", level = {60, 9999}, norepeatable = true, premium = true, creatures = {"necromancer", "priestess"}, rewards = { --Requires an storage (Gained on To Outfox a Fox Quest)
                                                                                                                                        {type = "storage", value = {35033, 1}},
                                                                                                                                        {type = "storage", value = {12800, 1}} --storage to stark the second Necromancers and Priestess task.
                                                                                                                                    }},    
 
    [49] = {killsRequired = 1000, name = "Necromancers and Priestess second task", raceName = "Necromancers and Priestess", level = {60, 9999}, storage = {12800, 1}, norepeatable = true, premium = true, creatures = {"necromancer", "priestess"}, rewards = { --Requires an storage (Gained on To Outfox a Fox Quest)
                                                                                                                                        {type = "exp", value = {40000}},
                                                                                                                                        {type = "storage", value = {35033, 1}}
                                                                                                                                    }},                                                                                                                                        
}
 
tasksByPlayer = 3
repeatTimes = 3
 
function getPlayerRank(cid)
    return (getPlayerStorageValue(cid, POINTSSTORAGE) >= 100 and RANK_ELITEHUNTER or getPlayerStorageValue(cid, POINTSSTORAGE) >= 70 and RANK_TROPHYHUNTER or getPlayerStorageValue(cid, POINTSSTORAGE) >= 40 and RANK_BIGGAMEHUNTER or getPlayerStorageValue(cid, POINTSSTORAGE) >= 20 and RANK_RANGER or getPlayerStorageValue(cid, POINTSSTORAGE) >= 10 and RANK_HUNTSMAN or getPlayerStorageValue(cid, JOIN_STOR) == 1 and RANK_JOIN or RANK_NONE)
end
 
function getTaskByName(name, table)
    local t = (table and table or tasks)
    for k, v in pairs(t) do
        if v.name then
            if v.name:lower() == name:lower() then
                return k
            end
        else
            if v.raceName:lower() == name:lower() then
                return k
            end
        end
    end
    return false
end
 
function getTasksByPlayer(cid)
    local canmake = {}
    local able = {}
    for k, v in pairs(tasks) do
        if getCreatureStorage(cid, QUESTSTORAGE_BASE + k) < 1 and getCreatureStorage(cid, REPEATSTORAGE_BASE + k) < repeatTimes then
            able[k] = true
            if getPlayerLevel(cid) < v.level[1] or getPlayerLevel(cid) > v.level[2] then
                able[k] = false
            end
            if v.storage and getCreatureStorage(cid, v.storage[1]) < v.storage[2] then
                able[k] = false
            end
 
            if v.rank then
                if getPlayerRank(cid) < v.rank then
                    able[k] = false
                end
            end
 
            if v.premium then
                if not isPremium(cid) then
                    able[k] = false
                end
            end
 
            if able[k] then
                table.insert(canmake, k)
            end
        end
    end
    return canmake
end
 
 
function canStartTask(cid, name, table)
    local v = ""
    local id = 0
    local t = (table and table or tasks)
    for k, i in pairs(t) do
        if i.name then
            if i.name:lower() == name:lower() then
                v = i
                id = k
                break
            end
        else
            if i.raceName:lower() == name:lower() then
                v = i
                id = k
                break
            end
        end
    end
    if v == "" then
        return false
    end
    if getCreatureStorage(cid, QUESTSTORAGE_BASE + id) > 0 then
        return false
    end
    if (getCreatureStorage(cid, REPEATSTORAGE_BASE +  id) >= repeatTimes) or (v.norepeatable and getCreatureStorage(cid, REPEATSTORAGE_BASE +  id) > 0) then
        return false
    end
    if getPlayerLevel(cid) >= v.level[1] and getPlayerLevel(cid) <= v.level[2] then
        if v.premium then
            if isPremium(cid) then
                if v.rank then
                    if getPlayerRank(cid) >= v.rank then
                        if v.storage then
                            if getCreatureStorage(cid, v.storage[1]) >= v.storage[2] then
                                return true
                            end
                        else
                            return true
                        end
                    end
                else
                    return true
                end
            end
        else
            return true
        end
    end
    return false
end
 
function getPlayerStartedTasks(cid)
 
    local tmp = {}
    for k, v in pairs(tasks) do
        if getCreatureStorage(cid, QUESTSTORAGE_BASE + k) > 0 and getCreatureStorage(cid, QUESTSTORAGE_BASE + k) < 2 then
            table.insert(tmp, k)
        end
    end
    return tmp
end
 
function isSummon(cid)
    return getCreatureMaster(cid) ~= nil or false
end

 

Em "Data/creaturescripts" abra o creaturescripts.xml e coloque a TAG:

<event type="kill" name="KillingInTheNameOf" event="script" value="killinginthenameof.lua"/>

E registre no login.lua:

registerCreatureEvent(cid, "KillingInTheNameOf")

Em "Data/creaturescripts/scripts" crie killinginthenameof.lua e cole:

function onKill(cid, target, lastHit)
 
    local started = getPlayerStartedTasks(cid)
    if isPlayer(target) or isSummon(target) then return true end
    if started and #started > 0 then
        for _, id in ipairs(started) do
            if isInArray(tasks[id].creatures, getCreatureName(target):lower()) then
                if getCreatureStorage(cid, KILLSSTORAGE_BASE + id) < 0 then
                    doCreatureSetStorage(cid, KILLSSTORAGE_BASE + id, 0)
                end
                if getCreatureStorage(cid, KILLSSTORAGE_BASE + id) < tasks[id].killsRequired then
                    doCreatureSetStorage(cid, KILLSSTORAGE_BASE + id, getCreatureStorage(cid, KILLSSTORAGE_BASE + id) + 1)
                    doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, getCreatureStorage(cid, KILLSSTORAGE_BASE + id) .. "/" .. tasks[id].killsRequired .. " " .. tasks[id].raceName .. " already killed.")
                end
            end
        end
    end
    return true
end

Link para o post
Compartilhar em outros sites

esse script ai legal ele, mas esse meu eu gosto porque tem o questlog, conssegui ageitar agora o npc da a task seta a storage pro player, ai registra no quest log, mas quando mato os bixo o numero de bixos mortos nao ta subindo, sempre no 0, o que poderia ser? e nao da nenhum erro no distro, simplesmente ele nao conta o numero de kill.



Link para o post
Compartilhar em outros sites
  • 4 years later...

Participe da conversa

Você pode postar agora e se cadastrar mais tarde. Se você tem uma conta, faça o login para postar com sua conta.

Visitante
Responder

×   Você colou conteúdo com formatação.   Remover formatação

  Apenas 75 emojis são permitidos.

×   Seu link foi automaticamente incorporado.   Mostrar como link

×   Seu conteúdo anterior foi restaurado.   Limpar o editor

×   Não é possível colar imagens diretamente. Carregar ou inserir imagens do URL.

  • Quem Está Navegando   0 membros estão online

    Nenhum usuário registrado visualizando esta página.

×
×
  • Criar Novo...

Informação Importante

Confirmação de Termo