• There is NO official Otland's Discord server and NO official Otland's server list. The Otland's Staff does not manage any Discord server or server list. Moderators or administrator of any Discord server or server lists have NO connection to the Otland's Staff. Do not get scammed!

Lua TFS 0.4 Task System Problem

marekbuum

New Member
Joined
Jul 31, 2012
Messages
7
Reaction score
2
Hello, I have a problem with the Task System, namely the task system works fine, but when I enter the command !Task Info crashes me with an error.
bład.png

Then he types !Task info and there is such an error in the console
bład 1.png
bład 2.png
blad 3.png


source file

XML:
    <talkaction words="!task" event="script">
        <![CDATA[
            domodlib('task_config')

            function onSay(cid, words, param)
                local currentTask, tasks = '', {}
                for k, v in pairs(taskMonsters) do
                    if getCreatureStorage(cid, taskConfig.taskStorage) == k then
                        currentTask = k
                    end
                    table.insert(tasks, k)
                end
               
                param = param:lower()

                if param == '' then
                    doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, '[TASK]\n"!task info" - check your current task\n"!task TaskName" - start new task\n"!task off" - stop current task')
                elseif param == 'info' then
                    local t = (getPlayerVocation(cid) - 4 > 0) and taskConfig.potion[getPlayerVocation(cid)-4] or taskConfig.potion[getPlayerVocation(cid)]  
                    if currentTask ~= '' then
                        local task, text = taskMonsters[currentTask], ''
                        if getCreatureStorage(cid, t.doneStorage) == 0 and getCreatureStorage(cid, t.storage) >= 0 then
                            doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, '[TASK INFO] You are doing potion task and you have used them '..getCreatureStorage(cid, t.storage)..' of '..t.uses..'.')
                        end
                        doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, '[TASK INFO] You are doing '..currentTask..' task. You killed '..getCreatureStorage(cid, task.storage)..' of '..task.kills..' this kind of monsters.'..text)
                    else
                        if getCreatureStorage(cid, t.doneStorage) == 0 and getCreatureStorage(cid, t.storage) >= 0 then
                            return true, doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, '[TASK INFO] You are doing potion task and you have used them '..getCreatureStorage(cid, t.storage)..' of '..t.uses..'.')
                        end
                        doPlayerSendCancel(cid, 'You are not in any task.')
                    end
                elseif param == 'off' then
                    if currentTask == '' then
                        return doPlayerSendCancel(cid, 'You are not in any task.')
                    end

                    doCreatureSetStorage(cid, taskConfig.taskStorage, '')
                    doCreatureSetStorage(cid, taskMonsters[currentTask].storage, 0)
                    doCreatureSetStorage(cid, taskMonsters[currentTask].doneStorage, 0)
                    doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, '[TASK] You stopped currently '..currentTask..' task. You can now start other task.')
                elseif param == 'potion' then
                    local p = (getPlayerVocation(cid) - 4 > 0) and taskConfig.potion[getPlayerVocation(cid)-4] or taskConfig.potion[getPlayerVocation(cid)]
                   
                    if getCreatureStorage(cid, p.doneStorage) == 1 then
                        return doPlayerSendCancel(cid, 'You arleady done this kind of tasks.')
                    elseif p.minLevel > getPlayerLevel(cid) then
                        return doPlayerSendCancel(cid, 'You don\'t have enough level.')
                    end
                   
                    if getCreatureStorage(cid, p.storage) < 0 then
                        doCreatureSetStorage(cid, p.storage, 0)
                        doCreatureSetStorage(cid, p.doneStorage, 0)
                        doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, '[TASK] You have started potion task. You have to use '..p.uses..' potions. Good luck!')
                    else
                        doCreatureSetStorage(cid, p.storage, -1)
                        doPlayerSendCancel(cid, 'Currently you are doing this task.')
                    end
                elseif param == 'superpotion' then
                    local p = (getPlayerVocation(cid) - 4 > 0) and taskConfig.superPotion[getPlayerVocation(cid)-4] or taskConfig.superPotion[getPlayerVocation(cid)]
                    local normal_p = (getPlayerVocation(cid) - 4 > 0) and taskConfig.potion[getPlayerVocation(cid)-4] or taskConfig.potion[getPlayerVocation(cid)]
                   
                    if getCreatureStorage(cid, normal_p.doneStorage) < 1 then
                        return doPlayerSendCancel(cid, 'You have to finish normal potion task until you start new one.')
                    elseif getCreatureStorage(cid, p.doneStorage) == 1 then
                        return doPlayerSendCancel(cid, 'You arleady done this kind of tasks.')
                    elseif p.minLevel > getPlayerLevel(cid) then
                        return doPlayerSendCancel(cid, 'You don\'t have enough level.')
                    end
                   
                    if getCreatureStorage(cid, p.storage) < 0 then
                        doCreatureSetStorage(cid, p.storage, 0)
                        doCreatureSetStorage(cid, p.doneStorage, 0)
                        doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, '[TASK] You have started super potion task. You have to use '..p.uses..' potions. Good luck!')
                    else
                        doCreatureSetStorage(cid, p.storage, -1)
                        doPlayerSendCancel(cid, 'Currently you are doing this task.')
                    end              
                elseif isInArray(tasks, param) then
                    if currentTask ~= '' then
                        return doPlayerSendCancel(cid, 'Currently you are doing '..currentTask..' task. You can stop it typing "!taskoff".')
                    elseif taskMonsters[param].minLevel > getPlayerLevel(cid) then
                        return doPlayerSendCancel(cid, 'You do not have required '..taskMonsters[param].minLevel..' level to start this task.')
                    elseif taskMonsters[param].vip and getCreatureStorage(cid, taskConfig.vipStorage) < 1 then
                        return doPlayerSendCancel(cid, 'You have to be vip to start this task.')
                    elseif getCreatureStorage(cid, taskMonsters[param].doneStorage) == 1 then
                        return doPlayerSendCancel(cid, 'You arleady done task with '..param..'s.')
                    end
                   
                    doCreatureSetStorage(cid, taskConfig.taskStorage, param)
                    doCreatureSetStorage(cid, taskMonsters[param].storage, 0)
                    doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, '[TASK] You have started '..param..' task. You have to kill '..taskMonsters[param].kills..' '..param..'s. Good luck!')
                else
                    doPlayerSendCancel(cid, 'Type your param propely or type: "!task".')
                end
                return true
            end
        ]]>
    </talkaction>

    <event type="kill" name="task_kill" event="script">
        <![CDATA[
            domodlib('task_config')

            function onKill(cid, target, damage, flags)
                if bit.band(flags, 1) == 1 and isMonster(target) then
                    if isPlayer(cid) then
                        if getCreatureStorage(cid, taskConfig.taskStorage) == getCreatureName(target):lower() then
                            local task = taskMonsters[getCreatureName(target):lower()]
                            if getCreatureStorage(cid, task.storage) + 1 >= task.kills then
                                doCreatureSetStorage(cid, taskConfig.taskStorage, '')
                                doCreatureSetStorage(cid, task.storage, task.kills)
                                doCreatureSetStorage(cid, task.doneStorage, 1)
                                doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, '[TASK] You have finished task. You have killed enough '..getCreatureName(target):lower()..'s and you got a reward.')
                               
                                doPlayerAddExperience(cid, task.exp)
                                local backpack = doPlayerAddItem(cid, 11244, 1)
                                for k, v in ipairs(task.items) do
                                    doAddContainerItem(backpack, v[1], v[2])
                                end
                            else
                                doCreatureSetStorage(cid, task.storage, math.max(0, getCreatureStorage(cid, task.storage)) + 1)
                                doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, '[TASK] You killed '..getCreatureStorage(cid, task.storage)..'/'..task.kills..' '..getCreatureName(target):lower()..'s.')
                            end
                        end
                    end
                end
                return true
            end
        ]]>
    </event>
   
    <event type="login" name="task_login" event="buffer">
        <![CDATA[
            registerCreatureEvent(cid, 'task_kill')
        ]]>
    </event>
</mod>
 
Solution
how you give reputation points because I admit that I never gave because I had no problem with anything
'reaction score' is the reputation system.

Liking a person's post gives them reaction score.

Specifically in support & request boards, hitting the 'checkmark' beside a person's post (when you are the thread creator) will mark that post as a solution to your thread.

----
E I still have a question of this type, if I want to remove the potion and super potion functions, what to remove.

Below is without potion and super potion
XML:
<config name="task_config">
    <![CDATA[
        taskConfig = {
            taskStorage = 5469, -- wolne storage
            vipStorage = 11551
        }
   
        taskMonsters = {...
This makes me grateful that we stopped doing XML mods and adopted Revscriptsys instead....

In that screenshot, what appears to matter is the first line and last couple lines, first line [Error - Talkaction interface]
And last line: attempt to index local 't'

As far as I can see, in the talkaction portion, you declare t in (buffer line 17):
Lua:
local t = (getPlayerVocation(cid) - 4 > 0) and taskConfig.potion[getPlayerVocation(cid)-4] or taskConfig.potion[getPlayerVocation(cid)]

Which loads in taskConfig.potion for a given vocation.

Then in the conditional statement in buffer line 20, it tries to access t.doneStorage and t.storage index of t.
However, it seems these indexes are not set, because t is null.

So it appears t failed to set any data from taskConfig.potion.

So what is in taskConfig? This mod files load domodlib('task_config'), could you post it so we can have a look into it?
And are you using custom vocations?
 
Yes i am using non standard custom vocations.

To be honest I would remove this action with potion ... just throw away what?

do you want the entire script?
 
Yeah, I need to see this file: (I think taskConfig.potion is in here somewhere)
Lua:
domodlib('task_config')

And I need to know your data/XML/vocations.xml file to accomodate your custom vocations.
 
XML:
<?xml version="1.0" encoding="UTF-8"?>
<vocations>
    <vocation id="0" name="None" description="none" needpremium="0" gaincap="5" gainhp="5" gainmana="5" gainhpticks="6" gainhpamount="1" gainmanaticks="6" gainmanaamount="2" manamultiplier="4.0" attackspeed="1000" soulmax="100" gainsoulticks="120" fromvoc="0" attackable="no">
        <formula meleeDamage="1.0" distDamage="1.0" wandDamage="1.0" magDamage="1.0" magHealingDamage="1.0" defense="1.0" magDefense="1.0" armor="1.0"/>
        <skill fist="1.5" club="2.0" sword="2.0" axe="2.0" distance="2.0" shielding="1.5" fishing="1.1" experience="1.0"/>
    </vocation>
    <vocation id="1" name="Sorcerer" description="a sorcerer" needpremium="0" gaincap="10" gainhp="5" gainmana="30" gainhpticks="12" gainhpamount="1" gainmanaticks="3" gainmanaamount="2" manamultiplier="1.1" attackspeed="1000" soulmax="100" gainsoulticks="120" fromvoc="1">
        <formula meleeDamage="1.0" distDamage="1.0" wandDamage="1.0" magDamage="1.0" magHealingDamage="1.0" defense="1.0" magDefense="1.0" armor="1.0"/>
        <skill fist="1.5" club="2.0" sword="2.0" axe="2.0" distance="2.0" shielding="1.5" fishing="1.1" experience="1.0"/>
    </vocation>
    <vocation id="2" name="Druid" description="a druid" needpremium="0" gaincap="10" gainhp="5" gainmana="30" gainhpticks="12" gainhpamount="1" gainmanaticks="3" gainmanaamount="2" manamultiplier="1.1" attackspeed="1000" soulmax="100" gainsoulticks="120" fromvoc="2">
        <formula meleeDamage="1.0" distDamage="1.0" wandDamage="1.0" magDamage="1.0" magHealingDamage="1.0" defense="1.0" magDefense="1.0" armor="1.0"/>
        <skill fist="1.5" club="1.8" sword="1.8" axe="1.8" distance="1.8" shielding="1.5" fishing="1.1" experience="1.0"/>
    </vocation>
    <vocation id="3" name="Paladin" description="a paladin" needpremium="0" gaincap="20" gainhp="10" gainmana="15" gainhpticks="8" gainhpamount="1" gainmanaticks="4" gainmanaamount="2" manamultiplier="1.4" attackspeed="1000" soulmax="100" gainsoulticks="120" fromvoc="3">
        <formula meleeDamage="1.0" distDamage="1.0" wandDamage="1.0" magDamage="1.0" magHealingDamage="1.0" defense="1.0" magDefense="1.0" armor="1.0"/>
        <skill fist="1.2" club="1.2" sword="1.2" axe="1.2" distance="1.1" shielding="1.1" fishing="1.1" experience="1.0"/>
    </vocation>
    <vocation id="4" name="Knight" description="a knight" needpremium="0" gaincap="25" gainhp="15" gainmana="5" gainhpticks="6" gainhpamount="1" gainmanaticks="6" gainmanaamount="2" manamultiplier="3.0" attackspeed="1000" soulmax="100" gainsoulticks="120" fromvoc="4">
        <formula meleeDamage="1.0" distDamage="1.0" wandDamage="1.0" magDamage="1.0" magHealingDamage="1.0" defense="1.0" magDefense="1.0" armor="1.0"/>
        <skill fist="1.1" club="1.1" sword="1.1" axe="1.1" distance="1.4" shielding="1.1" fishing="1.1" experience="1.0"/>
    </vocation>
    <vocation id="5" name="Master Sorcerer" description="a master sorcerer" needpremium="1" gaincap="10" gainhp="5" gainmana="30" gainhpticks="12" gainhpamount="1" gainmanaticks="2" gainmanaamount="2" manamultiplier="1.1" attackspeed="1000" soulmax="200" gainsoulticks="15" fromvoc="1" lessloss="30">
        <formula meleeDamage="1.0" distDamage="1.0" wandDamage="1.0" magDamage="1.0" magHealingDamage="1.0" defense="1.0" magDefense="1.0" armor="1.0"/>
        <skill fist="1.5" club="2.0" sword="2.0" axe="2.0" distance="2.0" shielding="1.5" fishing="1.1" experience="1.0"/>
    </vocation>
    <vocation id="6" name="Elder Druid" description="an elder druid" needpremium="1" gaincap="10" gainhp="5" gainmana="30" gainhpticks="12" gainhpamount="1" gainmanaticks="2" gainmanaamount="2" manamultiplier="1.1" attackspeed="1000" soulmax="200" gainsoulticks="15" fromvoc="2" lessloss="30">
        <formula meleeDamage="1.0" distDamage="1.0" wandDamage="1.0" magDamage="1.0" magHealingDamage="1.0" defense="1.0" magDefense="1.0" armor="1.0"/>
        <skill fist="1.5" club="1.8" sword="1.8" axe="1.8" distance="1.8" shielding="1.5" fishing="1.1" experience="1.0"/>
    </vocation>
    <vocation id="7" name="Royal Paladin" description="a royal paladin" needpremium="1" gaincap="20" gainhp="10" gainmana="15" gainhpticks="6" gainhpamount="1" gainmanaticks="3" gainmanaamount="2" manamultiplier="1.4" attackspeed="1000" soulmax="200" gainsoulticks="15" fromvoc="3" lessloss="30">
        <formula meleeDamage="1.0" distDamage="1.0" wandDamage="1.0" magDamage="1.0" magHealingDamage="1.0" defense="1.0" magDefense="1.0" armor="1.0"/>
        <skill fist="1.2" club="1.2" sword="1.2" axe="1.2" distance="1.1" shielding="1.1" fishing="1.1" experience="1.0"/>
    </vocation>
    <vocation id="8" name="Elite Knight" description="an elite knight" needpremium="1" gaincap="25" gainhp="15" gainmana="5" gainhpticks="4" gainhpamount="1" gainmanaticks="6" gainmanaamount="2" manamultiplier="3.0" attackspeed="1000" soulmax="200" gainsoulticks="15" fromvoc="4" lessloss="30">
        <formula meleeDamage="1.0" distDamage="1.0" wandDamage="1.0" magDamage="1.0" magHealingDamage="1.0" defense="1.0" magDefense="1.0" armor="1.0"/>
        <skill fist="1.1" club="1.1" sword="1.1" axe="1.1" distance="1.4" shielding="1.1" fishing="1.1" experience="1.0"/>
    </vocation>
    <vocation id="9" name="Wizard" description="an wizard" needpremium="0" gaincap="10" gainhp="5" gainmana="30" gainhpticks="12" gainhpamount="1" gainmanaticks="1" gainmanaamount="2" manamultiplier="1.1" attackspeed="2000" soulmax="200" gainsoulticks="15" fromvoc="5" lessloss="50">
        <formula meleeDamage="1.0" distDamage="1.0" wandDamage="1.0" magDamage="1.0" magHealingDamage="1.0" defense="1.0" magDefense="1.0" armor="1.0"/>
        <skill fist="1.5" club="2.0" sword="2.0" axe="2.0" distance="2.0" shielding="1.5" fishing="1.1" experience="1.0"/>
    </vocation>
    <vocation id="10" name="Pirset" description="an pirset" needpremium="0" gaincap="10" gainhp="5" gainmana="30" gainhpticks="12" gainhpamount="1" gainmanaticks="1" gainmanaamount="2" manamultiplier="1.1" attackspeed="2000" soulmax="200" gainsoulticks="15" fromvoc="6" lessloss="50">
        <formula meleeDamage="1.0" distDamage="1.0" wandDamage="1.0" magDamage="1.0" magHealingDamage="1.0" defense="1.0" magDefense="1.0" armor="1.0"/>
        <skill fist="1.5" club="1.8" sword="1.8" axe="1.8" distance="1.8" shielding="1.5" fishing="1.1" experience="1.0"/>
    </vocation>
    <vocation id="11" name="Assassin" description="an assassin" needpremium="0" gaincap="20" gainhp="10" gainmana="15" gainhpticks="3" gainhpamount="1" gainmanaticks="2" gainmanaamount="2" manamultiplier="1.4" attackspeed="2000" soulmax="200" gainsoulticks="15" fromvoc="7" lessloss="50">
        <formula meleeDamage="1.0" distDamage="1.0" wandDamage="1.0" magDamage="1.0" magHealingDamage="1.0" defense="1.0" magDefense="1.0" armor="1.0"/>
        <skill fist="1.2" club="1.2" sword="1.2" axe="1.2" distance="1.1" shielding="1.1" fishing="1.1" experience="1.0"/>
    </vocation>
    <vocation id="12" name="Gladiator" description="an gladiator" needpremium="0" gaincap="25" gainhp="15" gainmana="5" gainhpticks="2" gainhpamount="1" gainmanaticks="6" gainmanaamount="2" manamultiplier="3.0" attackspeed="2000" soulmax="200" gainsoulticks="15" fromvoc="8" lessloss="50">
        <formula meleeDamage="1.0" distDamage="1.0" wandDamage="1.0" magDamage="1.0" magHealingDamage="1.0" defense="1.0" magDefense="1.0" armor="1.0"/>
        <skill fist="1.1" club="1.1" sword="1.1" axe="1.1" distance="1.4" shielding="1.1" fishing="1.1" experience="1.0"/>
    </vocation>
-->
</vocations>
Post automatically merged:

XML:
<config name="task_config">
        <![CDATA[
            taskConfig = {
                taskStorage = 5469, -- wolne storage
                vipStorage = 11551,
                
                potion = {
                    [1] = {storage = 11093, doneStorage = 11094, uses = 36000, minLevel = 200, exp = 10000, items = {{2160, 5}, {7488, 1}}},
                    [2] = {storage = 11095, doneStorage = 11096, uses = 36000, minLevel = 200, exp = 10000, items = {{2160, 5}, {7488, 1}}},
                    [3] = {storage = 11097, doneStorage = 11098, uses = 36000, minLevel = 200, exp = 10000, items = {{2160, 5}, {8205, 1}}},
                    [4] = {storage = 11099, doneStorage = 11100, uses = 36000, minLevel = 200, exp = 10000, items = {{2160, 5}, {8474, 1}}}
                },
                
                superPotion = {
                    [1] = {storage = 111101, doneStorage = 111102, uses = 200000, minLevel = 300, exp = 10000000, potion = 9930},
                    [2] = {storage = 111103, doneStorage = 111104, uses = 200000, minLevel = 300, exp = 10000000, potion = 9930},
                    [3] = {storage = 111105, doneStorage = 111106, uses = 200000, minLevel = 300, exp = 10000000, potion = 9930},
                    [4] = {storage = 111107, doneStorage = 111108, uses = 200000, minLevel = 300, exp = 10000000, potion = 9930}               
                }
            }
            

            
            taskMonsters = {
                ["pro demon"] = {storage = 11101, doneStorage = 11102, kills = 5000, minLevel = 1, exp = 15000000, items = {{2160, 40}, {2346, 2}}, vip = false},
                ["dragon"] = {storage = 11103, doneStorage = 11104, kills = 2500, minLevel = 1, exp = 1070100, items = {{2160, 50}, {2498, 1}, {2492, 1}}, vip = false},
                ["dragon lord"] = {storage = 11105, doneStorage = 11106, kills = 4000, minLevel = 1, exp = 3605100, items = {{2160, 80}, {6132, 1}, {8300, 1}}, vip = false},
                ["hero"] = {storage = 11107, doneStorage = 11108, kills = 5000, minLevel = 1, exp = 1070100, items = {{2160, 30}, {2491, 1}, {2487, 1}, {2488, 1}, {2519, 1}}, vip = false},
                ["black knight"] = {storage = 11109, doneStorage = 11110, kills = 5000, minLevel = 1, exp = 1605100, items = {{2160, 80}, {8931, 1}, {2496, 1}}, vip = false},
                ["behemoth"] = {storage = 11111, doneStorage = 11112, kills = 3000, minLevel = 1, exp = 3605100, items = {{2160, 80}, {6132, 1}, {8300, 1}}, vip = false},
                ["pro hellhound"] = {storage = 11113, doneStorage = 11114, kills = 5000, minLevel = 1, exp = 15000000, items = {{2160, 40}, {2346, 2}}, vip = false},
                ["pro fury"] = {storage = 11115, doneStorage = 11116, kills = 5000, minLevel = 1, exp = 15000000, items = {{2160, 40}, {2346, 2}}, vip = false},
                ["pro hydra"] = {storage = 11117, doneStorage = 11118, kills = 5000, minLevel = 1, exp = 15000000, items = {{2160, 40}, {2346, 2}}, vip = false},
                ["destroyer"] = {storage = 11119, doneStorage = 11120, kills = 1050, minLevel = 1, exp = 2000000, items = {{2160, 15}, {8300, 3}}, vip = false},
                ["ferumbras"] = {storage = 11127, doneStorage = 11128, kills = 60, minLevel = 1, exp = 3451000, items = {{2160, 35}, {8300, 3}}, vip = false},
                ["fury"] = {storage = 11129, doneStorage = 11130, kills = 4600, minLevel = 1, exp = 4456000, items = {{2160, 25}, {8918, 1}}, vip = false},
                ["grim reaper"] = {storage = 11135, doneStorage = 11136, kills = 5550, minLevel = 1, exp = 8685450, items = {{2160, 80}, {7735, 1}}, vip = false},
                ["giant spider"] = {storage = 11137, doneStorage = 11138, kills = 15000, minLevel = 1, exp = 3605100, items = {{2160, 80}, {6132, 1}, {8300, 1}}, vip = false},
                ["hellfire fighter"] = {storage = 11141, doneStorage = 11142, kills = 5000, minLevel = 1, exp = 7500000, items = {{2160, 40}, {9776, 1}, {9693, 1}}, vip = false},
                ["hydra"] = {storage = 11145, doneStorage = 11146, kills = 9000, minLevel = 1, exp = 5550000, items = {{2160, 30}, {2507, 1}, {2469, 1}}, vip = false},
                ["ice golem"] = {storage = 11147, doneStorage = 11148, kills = 1000, minLevel = 1, exp = 3605100, items = {{2160, 60}, {8300, 1}, {8300, 1}}, vip = false},
                ["infernalist"] = {storage = 11149, doneStorage = 11150, kills = 2550, minLevel = 1, exp = 6000000, items = {{2160, 20}, {8300, 1}}, vip = false},
                ["juggernaut"] = {storage = 11151, doneStorage = 11152, kills = 500, minLevel = 200, exp = 11000000, items = {{2160, 80}, {7422, 1}, {2390, 1}}, vip = true},
                ["morgaroth"] = {storage = 11153, doneStorage = 11154, kills = 50, minLevel = 200, exp = 12500000, items = {{2160, 90}, {5907, 1}, {8300, 2}}, vip = true},
                ["medusa"] = {storage = 11155, doneStorage = 11156, kills = 7000, minLevel = 1, exp = 5550000, items = {{2160, 20}, {8850, 1}}, vip = false},
                ["hellhound"] = {storage = 11159, doneStorage = 11160, kills = 5500, minLevel = 1, exp = 8000000, items = {{2160, 40}, {8300, 1}}, vip = false},
                ["plaguesmith"] = {storage = 11161, doneStorage = 11162, kills = 2500, minLevel = 1, exp = 6355000, items = {{2160, 15}, {8925, 1}}, vip = false},
                ["serpent spawn"] = {storage = 11167, doneStorage = 11168, kills = 2000, minLevel = 1, exp = 7605100, items = {{2160, 10}, {8300, 1}}, vip = false},

                ["undead dragon"] = {storage = 11169, doneStorage = 11170, kills = 3000, minLevel = 1, exp = 8500000, items = {{2160, 75}, {8300, 2}}, vip = true},
                ["warlock"] = {storage = 11171, doneStorage = 11172, kills = 3000, minLevel = 1, exp = 6000000, items = {{2160, 20}, {9996, 1}}, vip = false},
                ["demon"] = {storage = 11173, doneStorage = 11174, kills = 5000, minLevel = 1, exp = 9505100, items = {{2160, 80}, {6529, 1}, {10518, 1}, {2346, 1}}, vip = false},
                ["yeti"] = {storage = 11175, doneStorage = 11176, kills = 2500, minLevel = 1, exp = 11000000, items = {{2160, 30}, {9778,1}}, vip = false},
                ["azerus"] = {storage = 11177, doneStorage = 11178, kills = 250, minLevel = 1, exp = 15000000, items = {{2160, 10}, {2346, 1}}, vip = false},


                ["nightmare"] = {storage = 11183, doneStorage = 11184, kills = 8000, minLevel = 1, exp = 8000000, items = {{2160, 35}, {6391, 1}}, vip = false}
                
            }
        ]]>
    </config>
 
I'm under the assumption that this problem only occurs when any of your new vocations attempt to access that command?
(wizard, pirset, assassin, gladiator) --> Is it supposed to be 'Priest'? Should fix that spelling error.

----
If the issue only occurs with the above vocations, then my following questions should be answered.

Are your new vocations an additional promotion?

Sorc -> master sorc -> wizard
druid -> elder druid -> pirset
paladin -> royal paladin -> assassin
knight -> elite knight ->gladiator

and should they have access to potion and super potion?

If yes and yes, then use the below code.

I've changed all lines similar to this...
Lua:
local t = (getPlayerVocation(cid) - 4 > 0) and taskConfig.potion[getPlayerVocation(cid)-4] or taskConfig.potion[getPlayerVocation(cid)]
into this..
Lua:
local baseVocation = getPlayerVocation(cid)
while baseVocation > 4 do
    baseVocation = baseVocation - 4
end
Lua:
local t = taskConfig.potion[baseVocation]

Effectively, this will get the characters base vocation (1,2,3,4), and allow it to be used with the table correctly.
Where before you'd get a wizard (vocation = 9 - 4) -> which equaled 5, which is not in the potion table. (1-4)

Please note, that I think a portion of the original post's code is missing as normally it starts with some sort of 'mod' code?

So ensure you copy-paste it correctly into your current code.

XML:
    <talkaction words="!task" event="script">
        <![CDATA[
            domodlib('task_config')
 
            function onSay(cid, words, param)
                local currentTask, tasks = '', {}
                for k, v in pairs(taskMonsters) do
                    if getCreatureStorage(cid, taskConfig.taskStorage) == k then
                        currentTask = k
                    end
                    table.insert(tasks, k)
                end
         
                param = param:lower()
             
                local baseVocation = getPlayerVocation(cid)
                while baseVocation > 4 do
                    baseVocation = baseVocation - 4
                end
 
                if param == '' then
                    doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, '[TASK]\n"!task info" - check your current task\n"!task TaskName" - start new task\n"!task off" - stop current task')
                elseif param == 'info' then
                    local t = taskConfig.potion[baseVocation]
                    if currentTask ~= '' then
                        local task, text = taskMonsters[currentTask], ''
                        if getCreatureStorage(cid, t.doneStorage) == 0 and getCreatureStorage(cid, t.storage) >= 0 then
                            doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, '[TASK INFO] You are doing potion task and you have used them '..getCreatureStorage(cid, t.storage)..' of '..t.uses..'.')
                        end
                        doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, '[TASK INFO] You are doing '..currentTask..' task. You killed '..getCreatureStorage(cid, task.storage)..' of '..task.kills..' this kind of monsters.'..text)
                    else
                        if getCreatureStorage(cid, t.doneStorage) == 0 and getCreatureStorage(cid, t.storage) >= 0 then
                            return true, doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, '[TASK INFO] You are doing potion task and you have used them '..getCreatureStorage(cid, t.storage)..' of '..t.uses..'.')
                        end
                        doPlayerSendCancel(cid, 'You are not in any task.')
                    end
                elseif param == 'off' then
                    if currentTask == '' then
                        return doPlayerSendCancel(cid, 'You are not in any task.')
                    end
 
                    doCreatureSetStorage(cid, taskConfig.taskStorage, '')
                    doCreatureSetStorage(cid, taskMonsters[currentTask].storage, 0)
                    doCreatureSetStorage(cid, taskMonsters[currentTask].doneStorage, 0)
                    doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, '[TASK] You stopped currently '..currentTask..' task. You can now start other task.')
                elseif param == 'potion' then
                    local p = taskConfig.potion[baseVocation]
             
                    if getCreatureStorage(cid, p.doneStorage) == 1 then
                        return doPlayerSendCancel(cid, 'You arleady done this kind of tasks.')
                    elseif p.minLevel > getPlayerLevel(cid) then
                        return doPlayerSendCancel(cid, 'You don\'t have enough level.')
                    end
             
                    if getCreatureStorage(cid, p.storage) < 0 then
                        doCreatureSetStorage(cid, p.storage, 0)
                        doCreatureSetStorage(cid, p.doneStorage, 0)
                        doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, '[TASK] You have started potion task. You have to use '..p.uses..' potions. Good luck!')
                    else
                        doCreatureSetStorage(cid, p.storage, -1)
                        doPlayerSendCancel(cid, 'Currently you are doing this task.')
                    end
                elseif param == 'superpotion' then
                    local p = taskConfig.superPotion[baseVocation]
                    local normal_p = taskConfig.potion[baseVocation]
             
                    if getCreatureStorage(cid, normal_p.doneStorage) < 1 then
                        return doPlayerSendCancel(cid, 'You have to finish normal potion task until you start new one.')
                    elseif getCreatureStorage(cid, p.doneStorage) == 1 then
                        return doPlayerSendCancel(cid, 'You arleady done this kind of tasks.')
                    elseif p.minLevel > getPlayerLevel(cid) then
                        return doPlayerSendCancel(cid, 'You don\'t have enough level.')
                    end
             
                    if getCreatureStorage(cid, p.storage) < 0 then
                        doCreatureSetStorage(cid, p.storage, 0)
                        doCreatureSetStorage(cid, p.doneStorage, 0)
                        doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, '[TASK] You have started super potion task. You have to use '..p.uses..' potions. Good luck!')
                    else
                        doCreatureSetStorage(cid, p.storage, -1)
                        doPlayerSendCancel(cid, 'Currently you are doing this task.')
                    end           
                elseif isInArray(tasks, param) then
                    if currentTask ~= '' then
                        return doPlayerSendCancel(cid, 'Currently you are doing '..currentTask..' task. You can stop it typing "!taskoff".')
                    elseif taskMonsters[param].minLevel > getPlayerLevel(cid) then
                        return doPlayerSendCancel(cid, 'You do not have required '..taskMonsters[param].minLevel..' level to start this task.')
                    elseif taskMonsters[param].vip and getCreatureStorage(cid, taskConfig.vipStorage) < 1 then
                        return doPlayerSendCancel(cid, 'You have to be vip to start this task.')
                    elseif getCreatureStorage(cid, taskMonsters[param].doneStorage) == 1 then
                        return doPlayerSendCancel(cid, 'You arleady done task with '..param..'s.')
                    end
             
                    doCreatureSetStorage(cid, taskConfig.taskStorage, param)
                    doCreatureSetStorage(cid, taskMonsters[param].storage, 0)
                    doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, '[TASK] You have started '..param..' task. You have to kill '..taskMonsters[param].kills..' '..param..'s. Good luck!')
                else
                    doPlayerSendCancel(cid, 'Type your param propely or type: "!task".')
                end
                return true
            end
        ]]>
    </talkaction>
 
    <event type="kill" name="task_kill" event="script">
        <![CDATA[
            domodlib('task_config')
 
            function onKill(cid, target, damage, flags)
                if bit.band(flags, 1) == 1 and isMonster(target) then
                    if isPlayer(cid) then
                        if getCreatureStorage(cid, taskConfig.taskStorage) == getCreatureName(target):lower() then
                            local task = taskMonsters[getCreatureName(target):lower()]
                            if getCreatureStorage(cid, task.storage) + 1 >= task.kills then
                                doCreatureSetStorage(cid, taskConfig.taskStorage, '')
                                doCreatureSetStorage(cid, task.storage, task.kills)
                                doCreatureSetStorage(cid, task.doneStorage, 1)
                                doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, '[TASK] You have finished task. You have killed enough '..getCreatureName(target):lower()..'s and you got a reward.')
                         
                                doPlayerAddExperience(cid, task.exp)
                                local backpack = doPlayerAddItem(cid, 11244, 1)
                                for k, v in ipairs(task.items) do
                                    doAddContainerItem(backpack, v[1], v[2])
                                end
                            else
                                doCreatureSetStorage(cid, task.storage, math.max(0, getCreatureStorage(cid, task.storage)) + 1)
                                doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, '[TASK] You killed '..getCreatureStorage(cid, task.storage)..'/'..task.kills..' '..getCreatureName(target):lower()..'s.')
                            end
                        end
                    end
                end
                return true
            end
        ]]>
    </event>
 
    <event type="login" name="task_login" event="buffer">
        <![CDATA[
            registerCreatureEvent(cid, 'task_kill')
        ]]>
    </event>
</mod>

I might also suggest that you disable these commands from being used by 'rookgaardians', aka vocation 0, if they exist in your server, as you'll run into the same problem again.
 
Everything works fine, thank you. yes pirset, wizard, galdiator and assassin these are new promotions and the error was only with new promotions. Thank you very much
Post automatically merged:

with the vocation of 0 no problem because they do not exist. I still have a question of this type, if I want to remove the potion and super potion functions, what to remove. and how you give reputation points because I admit that I never gave because I had no problem with anything
 
Last edited:
how you give reputation points because I admit that I never gave because I had no problem with anything
'reaction score' is the reputation system.

Liking a person's post gives them reaction score.

Specifically in support & request boards, hitting the 'checkmark' beside a person's post (when you are the thread creator) will mark that post as a solution to your thread.

----
E I still have a question of this type, if I want to remove the potion and super potion functions, what to remove.

Below is without potion and super potion
XML:
<config name="task_config">
    <![CDATA[
        taskConfig = {
            taskStorage = 5469, -- wolne storage
            vipStorage = 11551
        }
   
        taskMonsters = {
            ["pro demon"] = {storage = 11101, doneStorage = 11102, kills = 5000, minLevel = 1, exp = 15000000, items = {{2160, 40}, {2346, 2}}, vip = false},
            ["dragon"] = {storage = 11103, doneStorage = 11104, kills = 2500, minLevel = 1, exp = 1070100, items = {{2160, 50}, {2498, 1}, {2492, 1}}, vip = false},
            ["dragon lord"] = {storage = 11105, doneStorage = 11106, kills = 4000, minLevel = 1, exp = 3605100, items = {{2160, 80}, {6132, 1}, {8300, 1}}, vip = false},
            ["hero"] = {storage = 11107, doneStorage = 11108, kills = 5000, minLevel = 1, exp = 1070100, items = {{2160, 30}, {2491, 1}, {2487, 1}, {2488, 1}, {2519, 1}}, vip = false},
            ["black knight"] = {storage = 11109, doneStorage = 11110, kills = 5000, minLevel = 1, exp = 1605100, items = {{2160, 80}, {8931, 1}, {2496, 1}}, vip = false},
            ["behemoth"] = {storage = 11111, doneStorage = 11112, kills = 3000, minLevel = 1, exp = 3605100, items = {{2160, 80}, {6132, 1}, {8300, 1}}, vip = false},
            ["pro hellhound"] = {storage = 11113, doneStorage = 11114, kills = 5000, minLevel = 1, exp = 15000000, items = {{2160, 40}, {2346, 2}}, vip = false},
            ["pro fury"] = {storage = 11115, doneStorage = 11116, kills = 5000, minLevel = 1, exp = 15000000, items = {{2160, 40}, {2346, 2}}, vip = false},
            ["pro hydra"] = {storage = 11117, doneStorage = 11118, kills = 5000, minLevel = 1, exp = 15000000, items = {{2160, 40}, {2346, 2}}, vip = false},
            ["destroyer"] = {storage = 11119, doneStorage = 11120, kills = 1050, minLevel = 1, exp = 2000000, items = {{2160, 15}, {8300, 3}}, vip = false},
            ["ferumbras"] = {storage = 11127, doneStorage = 11128, kills = 60, minLevel = 1, exp = 3451000, items = {{2160, 35}, {8300, 3}}, vip = false},
            ["fury"] = {storage = 11129, doneStorage = 11130, kills = 4600, minLevel = 1, exp = 4456000, items = {{2160, 25}, {8918, 1}}, vip = false},
            ["grim reaper"] = {storage = 11135, doneStorage = 11136, kills = 5550, minLevel = 1, exp = 8685450, items = {{2160, 80}, {7735, 1}}, vip = false},
            ["giant spider"] = {storage = 11137, doneStorage = 11138, kills = 15000, minLevel = 1, exp = 3605100, items = {{2160, 80}, {6132, 1}, {8300, 1}}, vip = false},
            ["hellfire fighter"] = {storage = 11141, doneStorage = 11142, kills = 5000, minLevel = 1, exp = 7500000, items = {{2160, 40}, {9776, 1}, {9693, 1}}, vip = false},
            ["hydra"] = {storage = 11145, doneStorage = 11146, kills = 9000, minLevel = 1, exp = 5550000, items = {{2160, 30}, {2507, 1}, {2469, 1}}, vip = false},
            ["ice golem"] = {storage = 11147, doneStorage = 11148, kills = 1000, minLevel = 1, exp = 3605100, items = {{2160, 60}, {8300, 1}, {8300, 1}}, vip = false},
            ["infernalist"] = {storage = 11149, doneStorage = 11150, kills = 2550, minLevel = 1, exp = 6000000, items = {{2160, 20}, {8300, 1}}, vip = false},
            ["juggernaut"] = {storage = 11151, doneStorage = 11152, kills = 500, minLevel = 200, exp = 11000000, items = {{2160, 80}, {7422, 1}, {2390, 1}}, vip = true},
            ["morgaroth"] = {storage = 11153, doneStorage = 11154, kills = 50, minLevel = 200, exp = 12500000, items = {{2160, 90}, {5907, 1}, {8300, 2}}, vip = true},
            ["medusa"] = {storage = 11155, doneStorage = 11156, kills = 7000, minLevel = 1, exp = 5550000, items = {{2160, 20}, {8850, 1}}, vip = false},
            ["hellhound"] = {storage = 11159, doneStorage = 11160, kills = 5500, minLevel = 1, exp = 8000000, items = {{2160, 40}, {8300, 1}}, vip = false},
            ["plaguesmith"] = {storage = 11161, doneStorage = 11162, kills = 2500, minLevel = 1, exp = 6355000, items = {{2160, 15}, {8925, 1}}, vip = false},
            ["serpent spawn"] = {storage = 11167, doneStorage = 11168, kills = 2000, minLevel = 1, exp = 7605100, items = {{2160, 10}, {8300, 1}}, vip = false},
   
            ["undead dragon"] = {storage = 11169, doneStorage = 11170, kills = 3000, minLevel = 1, exp = 8500000, items = {{2160, 75}, {8300, 2}}, vip = true},
            ["warlock"] = {storage = 11171, doneStorage = 11172, kills = 3000, minLevel = 1, exp = 6000000, items = {{2160, 20}, {9996, 1}}, vip = false},
            ["demon"] = {storage = 11173, doneStorage = 11174, kills = 5000, minLevel = 1, exp = 9505100, items = {{2160, 80}, {6529, 1}, {10518, 1}, {2346, 1}}, vip = false},
            ["yeti"] = {storage = 11175, doneStorage = 11176, kills = 2500, minLevel = 1, exp = 11000000, items = {{2160, 30}, {9778,1}}, vip = false},
            ["azerus"] = {storage = 11177, doneStorage = 11178, kills = 250, minLevel = 1, exp = 15000000, items = {{2160, 10}, {2346, 1}}, vip = false},
   
   
            ["nightmare"] = {storage = 11183, doneStorage = 11184, kills = 8000, minLevel = 1, exp = 8000000, items = {{2160, 35}, {6391, 1}}, vip = false}
           
        }
    ]]>
</config>
XML:
        <talkaction words="!task" event="script">
        <![CDATA[
            domodlib('task_config')
   
            function onSay(cid, words, param)
                local currentTask, tasks = '', {}
                for k, v in pairs(taskMonsters) do
                    if getCreatureStorage(cid, taskConfig.taskStorage) == k then
                        currentTask = k
                    end
                    table.insert(tasks, k)
                end
       
                param = param:lower()
   
                if param == '' then
                    doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, '[TASK]\n"!task info" - check your current task\n"!task TaskName" - start new task\n"!task off" - stop current task')
                elseif param == 'info' then
                    if currentTask ~= '' then
                        local task, text = taskMonsters[currentTask], ''
                        doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, '[TASK INFO] You are doing '..currentTask..' task. You killed '..getCreatureStorage(cid, task.storage)..' of '..task.kills..' this kind of monsters.'..text)
                    else
                        doPlayerSendCancel(cid, 'You are not in any task.')
                    end
                elseif param == 'off' then
                    if currentTask == '' then
                        return doPlayerSendCancel(cid, 'You are not in any task.')
                    end
   
                    doCreatureSetStorage(cid, taskConfig.taskStorage, '')
                    doCreatureSetStorage(cid, taskMonsters[currentTask].storage, 0)
                    doCreatureSetStorage(cid, taskMonsters[currentTask].doneStorage, 0)
                    doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, '[TASK] You stopped currently '..currentTask..' task. You can now start other task.')         
                elseif isInArray(tasks, param) then
                    if currentTask ~= '' then
                        return doPlayerSendCancel(cid, 'Currently you are doing '..currentTask..' task. You can stop it typing "!taskoff".')
                    elseif taskMonsters[param].minLevel > getPlayerLevel(cid) then
                        return doPlayerSendCancel(cid, 'You do not have required '..taskMonsters[param].minLevel..' level to start this task.')
                    elseif taskMonsters[param].vip and getCreatureStorage(cid, taskConfig.vipStorage) < 1 then
                        return doPlayerSendCancel(cid, 'You have to be vip to start this task.')
                    elseif getCreatureStorage(cid, taskMonsters[param].doneStorage) == 1 then
                        return doPlayerSendCancel(cid, 'You arleady done task with '..param..'s.')
                    end
           
                    doCreatureSetStorage(cid, taskConfig.taskStorage, param)
                    doCreatureSetStorage(cid, taskMonsters[param].storage, 0)
                    doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, '[TASK] You have started '..param..' task. You have to kill '..taskMonsters[param].kills..' '..param..'s. Good luck!')
                else
                    doPlayerSendCancel(cid, 'Type your param propely or type: "!task".')
                end
                return true
            end
        ]]>
    </talkaction>
   
    <event type="kill" name="task_kill" event="script">
        <![CDATA[
            domodlib('task_config')
   
            function onKill(cid, target, damage, flags)
                if bit.band(flags, 1) == 1 and isMonster(target) then
                    if isPlayer(cid) then
                        if getCreatureStorage(cid, taskConfig.taskStorage) == getCreatureName(target):lower() then
                            local task = taskMonsters[getCreatureName(target):lower()]
                            if getCreatureStorage(cid, task.storage) + 1 >= task.kills then
                                doCreatureSetStorage(cid, taskConfig.taskStorage, '')
                                doCreatureSetStorage(cid, task.storage, task.kills)
                                doCreatureSetStorage(cid, task.doneStorage, 1)
                                doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, '[TASK] You have finished task. You have killed enough '..getCreatureName(target):lower()..'s and you got a reward.')
                       
                                doPlayerAddExperience(cid, task.exp)
                                local backpack = doPlayerAddItem(cid, 11244, 1)
                                for k, v in ipairs(task.items) do
                                    doAddContainerItem(backpack, v[1], v[2])
                                end
                            else
                                doCreatureSetStorage(cid, task.storage, math.max(0, getCreatureStorage(cid, task.storage)) + 1)
                                doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, '[TASK] You killed '..getCreatureStorage(cid, task.storage)..'/'..task.kills..' '..getCreatureName(target):lower()..'s.')
                            end
                        end
                    end
                end
                return true
            end
        ]]>
    </event>
   
    <event type="login" name="task_login" event="buffer">
        <![CDATA[
            registerCreatureEvent(cid, 'task_kill')
        ]]>
    </event>
</mod>
 
Solution
Thank you, everything works as it should now. I can't find it to mark as closed post, I still have a problem with zombie event but I'll do a separate post. unless I can write a personal message to you?
 
Thank you, everything works as it should now. I can't find it to mark as closed post, I still have a problem with zombie event but I'll do a separate post. unless I can write a personal message to you?
It's best to make a new forum post, so others can help and benefit from the solution.
 
Back
Top