• 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 Task Script cant load (attempt to index local 'target' (a number value))

Deepling

Just a spammer
Joined
Jun 29, 2015
Messages
1,835
Solutions
1
Reaction score
555
Location
Poland
Hello
As title say, I cant load task script (created by Limos)
Client Version 10.82 TFS 1.2

Code:
local config = {
     ['rotworm'] = {amount = 100, storage = 19000, startstorage = 5010, startvalue = 1}
}
function onKill(player, target)
     local monster = config[target:getName():lower()]
     if target:isPlayer() or not monster or target:getMaster() then
         return true
     end
     local stor = player:getStorageValue(monster.storage)+1
     if stor < monster.amount and player:getStorageValue(monster.startstorage) >= monster.startvalue then
         player:setStorageValue(monster.storage, stor)
         player:sendTextMessage(MESSAGE_STATUS_CONSOLE_ORANGE, 'Task message: '..(stor +1)..' of '..monster.amount..' '..target:getName()..'s killed.')
     end
     if (stor +1) == monster.amount then
         player:sendTextMessage(MESSAGE_INFO_DESCR, 'Congratulations, you have killed '..(stor +1)..' '..target:getName()..'s and completed the '..target:getName()..'s mission.')
         player:setStorageValue(monster.storage, stor +1)
     end
     return true
end

Could someone help me to fix this issue? :(
Thanks
 
Hello
As title say, I cant load task script (created by Limos)
Client Version 10.82 TFS 1.2

Code:
local config = {
     ['rotworm'] = {amount = 100, storage = 19000, startstorage = 5010, startvalue = 1}
}
function onKill(player, target)
     local monster = config[target:getName():lower()]
     if target:isPlayer() or not monster or target:getMaster() then
         return true
     end
     local stor = player:getStorageValue(monster.storage)+1
     if stor < monster.amount and player:getStorageValue(monster.startstorage) >= monster.startvalue then
         player:setStorageValue(monster.storage, stor)
         player:sendTextMessage(MESSAGE_STATUS_CONSOLE_ORANGE, 'Task message: '..(stor +1)..' of '..monster.amount..' '..target:getName()..'s killed.')
     end
     if (stor +1) == monster.amount then
         player:sendTextMessage(MESSAGE_INFO_DESCR, 'Congratulations, you have killed '..(stor +1)..' '..target:getName()..'s and completed the '..target:getName()..'s mission.')
         player:setStorageValue(monster.storage, stor +1)
     end
     return true
end

Could someone help me to fix this issue? :(
Thanks

Code:
local config = {
     ['rotworm'] = {amount = 100, storage = 19000, startstorage = 5010, startvalue = 1}
}
function onKill(player, target)
    local target = type(target) == "userdata" and target or Creature(target)
    if target and target:isMonster() then
        local monster = config[target:getName():lower()]
        if target:isPlayer() or not monster or target:getMaster() then
            return true
        end
        local stor = player:getStorageValue(monster.storage)+1
        if stor < monster.amount and player:getStorageValue(monster.startstorage) >= monster.startvalue then
            player:setStorageValue(monster.storage, stor)
            player:sendTextMessage(MESSAGE_STATUS_CONSOLE_ORANGE, 'Task message: '..(stor +1)..' of '..monster.amount..' '..target:getName()..'s killed.')
        end
        if (stor +1) == monster.amount then
            player:sendTextMessage(MESSAGE_INFO_DESCR, 'Congratulations, you have killed '..(stor +1)..' '..target:getName()..'s and completed the '..target:getName()..'s mission.')
            player:setStorageValue(monster.storage, stor +1)
        end
    end
    return true
end

Try this
 
Code:
local config = {
     ['rotworm'] = {amount = 100, storage = 19000, startstorage = 5010, startvalue = 1}
}
function onKill(player, target)
    local target = type(target) == "userdata" and target or Creature(target)
    if target and target:isMonster() then
        local monster = config[target:getName():lower()]
        if target:isPlayer() or not monster or target:getMaster() then
            return true
        end
        local stor = player:getStorageValue(monster.storage)+1
        if stor < monster.amount and player:getStorageValue(monster.startstorage) >= monster.startvalue then
            player:setStorageValue(monster.storage, stor)
            player:sendTextMessage(MESSAGE_STATUS_CONSOLE_ORANGE, 'Task message: '..(stor +1)..' of '..monster.amount..' '..target:getName()..'s killed.')
        end
        if (stor +1) == monster.amount then
            player:sendTextMessage(MESSAGE_INFO_DESCR, 'Congratulations, you have killed '..(stor +1)..' '..target:getName()..'s and completed the '..target:getName()..'s mission.')
            player:setStorageValue(monster.storage, stor +1)
        end
    end
    return true
end

Try this

Still doesn't work :/

Code:
Lua Script Error: [CreatureScript Interface]
data/creaturescripts/scripts/killtasks.lua:OnKill
data/creaturescripts/scripts/killtasks.lua:50: attempt to index local 'player' (
a number value)
stack traceback:
        [C]: in function '__index'
        data/creaturescripts/scripts/killtasks.lua:50: in function <data/creatur
escripts/scripts/killtasks.lua:43>

43th line is FunctionOnKill...
 
Last edited:
Still doesn't work :/

Code:
local config = {
     ['rotworm'] = {amount = 100, storage = 19000, startstorage = 5010, startvalue = 1}
}
function onKill(player, target)
    local target = type(target) == "userdata" and target or Creature(target)
    if target and target:isMonster() then
        local monster = config[target:getName():lower()]
        if target:isPlayer() or not monster or target:getMaster() then
            return true
        end
        local stor = player:getStorageValue(monster.storage)+1
        if stor < monster.amount and player:getStorageValue(monster.startstorage) >= monster.startvalue then
            player:setStorageValue(monster.storage, stor)
            player:sendTextMessage(MESSAGE_STATUS_CONSOLE_ORANGE, 'Task message: '..(stor +1)..' of '..monster.amount..' '..target:getName()..'s killed.')
        end
        if (stor +1) == monster.amount then
            player:sendTextMessage(MESSAGE_INFO_DESCR, 'Congratulations, you have killed '..(stor +1)..' '..target:getName()..'s and completed the '..target:getName()..'s mission.')
            player:setStorageValue(monster.storage, stor +1)
        end
    end
    return true
end
data/creaturescripts/scripts/killtasks.lua:OnKill
data/creaturescripts/scripts/killtasks.lua:50: attempt to index local 'player' (
a number value)
stack traceback:
[C]: in function '__index'
data/creaturescripts/scripts/killtasks.lua:50: in function <data/creatur
escripts/scripts/killtasks.lua:43>[/code]

43th line is FunctionOnKill...

Your TFS is not 1.2
Code:
local config = {
     ['rotworm'] = {amount = 100, storage = 19000, startstorage = 5010, startvalue = 1}
}
function onKill(player, target)
    local player = type(player) == "userdata" and player or Player(player)
    local target = type(target) == "userdata" and target or Creature(target)
    if target and target:isMonster() then
        local monster = config[target:getName():lower()]
        if target:isPlayer() or not monster or target:getMaster() then
            return true
        end
        local stor = player:getStorageValue(monster.storage)+1
        if stor < monster.amount and player:getStorageValue(monster.startstorage) >= monster.startvalue then
            player:setStorageValue(monster.storage, stor)
            player:sendTextMessage(MESSAGE_STATUS_CONSOLE_ORANGE, 'Task message: '..(stor +1)..' of '..monster.amount..' '..target:getName()..'s killed.')
        end
        if (stor +1) == monster.amount then
            player:sendTextMessage(MESSAGE_INFO_DESCR, 'Congratulations, you have killed '..(stor +1)..' '..target:getName()..'s and completed the '..target:getName()..'s mission.')
            player:setStorageValue(monster.storage, stor +1)
        end
    end
    return true
end
 
Code:
local config = {
     ['rotworm'] = {amount = 100, storage = 19000, startstorage = 5010, startvalue = 1}
}
function onKill(player, target)
    local player = type(player) == "userdata" and player or Player(player)
    local target = type(target) == "userdata" and target or Creature(target)
    if target and target:isMonster() then
        local monster = config[target:getName():lower()]
        if target:isPlayer() or not monster or target:getMaster() then
            return true
        end
        local stor = player:getStorageValue(monster.storage)+1
        if stor < monster.amount and player:getStorageValue(monster.startstorage) >= monster.startvalue then
            player:setStorageValue(monster.storage, stor)
            player:sendTextMessage(MESSAGE_STATUS_CONSOLE_ORANGE, 'Task message: '..(stor +1)..' of '..monster.amount..' '..target:getName()..'s killed.')
        end
        if (stor +1) == monster.amount then
            player:sendTextMessage(MESSAGE_INFO_DESCR, 'Congratulations, you have killed '..(stor +1)..' '..target:getName()..'s and completed the '..target:getName()..'s mission.')
            player:setStorageValue(monster.storage, stor +1)
        end
    end
    return true
end

Thanks, I will check it out in a moment. :)
18:53 Task message: 1 of 100 Rotworms killed.
Thanks @MatheusMkalo!
^_^
 
Last edited:
Back
Top