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

TFS 1.X+ Lua script Error [Raid Interface]

kamals94

New Member
Joined
Jul 26, 2009
Messages
8
Reaction score
0
Hello.
I receive this error message.
Can anyone help me?

engine tfs 1.2


błąd raidu.JPG



rewardboss.lua
Lua:
if not globalBosses then
    globalBosses = {}
end

function Monster.setReward(self, enable)
    if enable then
        if not self:getType():isRewardBoss() then
            error("Rewards can only be enabled to rewards bosses.")
            return false
        end
        globalBosses[self:getId()] = {}
        self:registerEvent("BossDeath") 
        self:registerEvent("BossThink") 
    else
        globalBosses[self:getId()] = nil
        self:unregisterEvent("BossDeath")
        self:unregisterEvent("BossThink")
    end
    return true
end

local function pushValues(buffer, sep, ...)
    local argv = {...}
    local argc = #argv
    for k, v in ipairs(argv) do
        table.insert(buffer, v)
        if k < argc and sep then
            table.insert(buffer, sep)
        end
    end
end

function Item.getNameDescription(self)
    local subType = self:getSubType()
    local itemType = self:getType()

    local buffer = {}

    local name = self:getName() or ''
    if(#name ~= 0) then
        if(itemType:isStackable() and subType > 1) then
            pushValues(buffer, ' ', subType, self:getPluralName())
        else
            local article = self:getArticle() or ''
            pushValues(buffer, ' ', select(#article ~= 0 and 1 or 2, article, name))
        end
    else
        pushValues(buffer, ' ', 'an item of type', self:getId())
    end

    return table.concat(buffer)
end

function Container.getContentDescription(self, outputBuffer)
    local firstItem = true
    local buffer = outputBuffer or {}
    for i = 1, self:getSize() do
        local item = self:getItem(i - 1)

        if(firstItem) then
            firstItem = false
        else
            table.insert(buffer, ", ")
        end

        table.insert(buffer, item:getNameDescription())
    end

    if firstItem then
        table.insert(buffer, "nothing")
    end

    if not outputBuffer then
        return table.concat(buffer)
    end
end

function Player.getRewardChest(self, autocreate)
    return self:getDepotChest(99, autocreate)
end

function Player.inBossFight(self)
    if not next(globalBosses) then
        return false
    end
    local playerGuid = self:getGuid()

    for _, info in pairs(globalBosses) do
        local stats = info[playerGuid]
        if stats and stats.active then
            return stats
        end
    end
    return false
end

-- by https://otland.net/members/cbrm.25752/ with some modifications
function MonsterType.createLootItem(self, lootBlock, chance, lootTable)
    local lootTable, itemCount = lootTable or {}, 0
    local randvalue = math.random(0, 100000) / (getConfigInfo("rateLoot") * chance)
    if randvalue < lootBlock.chance then
        if (ItemType(lootBlock.itemId):isStackable()) then
            itemCount = randvalue % lootBlock.maxCount + 1
        else
            itemCount = 1
        end
    end

    while itemCount > 0 do
        local n = math.min(itemCount, 100)
        itemCount = itemCount - n
        table.insert(lootTable, {lootBlock.itemId, n})
    end

    return lootTable
end

function MonsterType.getBossReward(self, lootFactor, topScore)
    local result = {}
    if getConfigInfo("rateLoot") > 0 then
        for _, lootBlock in pairs(self:getLoot()) do
            if lootBlock.unique and not topScore then
                --continue
            else
                self:createLootItem(lootBlock, lootFactor, result)
            end
        end
    end
    return result
end

the pale count.lua

Lua:
function onRaid()
local monster = Game.createMonster("The Pale Count", Position(32969, 32420, 15))
monster:setReward(true)
end
 
Code:
attemp to call method 'isRewardBoss' (a nil value)

This error means that method 'isRewardBoss' is called on nil value which is result of 'getType' function, in your case then, type of 'monster' is nil.
If your 'monster' is nil then it is not properly created and/or assigned to variable on which you want to call 'setReward' function.

the pale count.lua

Lua:
function onRaid()
local monster = Game.createMonster("The Pale Count", Position(32969, 32420, 15))
monster:setReward(true)
end

Try to remove "monster:setReward(true)" line and check if your monster is even spawning,
Give as many details of your problem as You can.
 
This happens every time I call /raid
Two types of errors are displayed alternately (depending on the raid):

1.
1566326135611.png

2.
1566326164810.png
Two types of errors are displayed alternately (depending on the raid):
 

Attachments

Replace your raid scripts with:

Orshabaal.lua
Lua:
function onRaid()
local monster = Game.createMonster("Orshabaal", Position(33207, 31719, 7))
if monster then
    print("Created monster Orshabaal")
     monster:setReward(true)
else
     print("Could not create monster Orshabaal")
end
end

The pale count.lua
Lua:
function onRaid()
    local monster = Game.createMonster("The Pale Count", Position(32969, 32420, 15))
    if monster then
        print(monster:getType())
        monster:setReward(true)
    else
        print("Could not create monster The Pale Count")
    end
end

then call both raids and show the output of console
 
Replace your raid scripts with:

Orshabaal.lua
Lua:
function onRaid()
local monster = Game.createMonster("Orshabaal", Position(33207, 31719, 7))
if monster then
    print("Created monster Orshabaal")
     monster:setReward(true)
else
     print("Could not create monster Orshabaal")
end
end

The pale count.lua
Lua:
function onRaid()
    local monster = Game.createMonster("The Pale Count", Position(32969, 32420, 15))
    if monster then
        print(monster:getType())
        monster:setReward(true)
    else
        print("Could not create monster The Pale Count")
    end
end

then call both raids and show the output of console

Orsh did not appear and The Pale did the same :(

1566328353082.png

In the case of Orshabal, the (bbroadcast message) string appeared even before the script was changed to yours.
 
To check if the functions exist, just use this small print
Lua:
print(Monster.setReward)
print(MonsterType.isRewardBoss)
If you see nil values, it means that you have not implemented these functions in your sources.
 
Back
Top