• 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 attempt to call method 'isVip' (a nil value)

darkmu

Active Member
Joined
Aug 26, 2007
Messages
249
Solutions
1
Reaction score
44
Location
Paraná,Brazil
I modified the boss levers so that if the character is VIP, the waiting time is shorter, however, I am suffering several errors of this type, can someone help me?

VIP SYSTEM:

TFS 1.3

error
Lua:
2020-11-22 19:40:15 -  Lua Script Error: [Action Interface]
2020-11-22 19:40:15 -  data/actions/scripts/bosses/scarlet.lua:onUse
2020-11-22 19:40:15 -  data/actions/scripts/bosses/scarlet.lua:86: attempt to call method 'isVip' (a nil value)
2020-11-22 19:40:15 -  stack traceback:
2020-11-22 19:40:15 -      [C]: in function 'isVip'
2020-11-22 19:40:15 -      data/actions/scripts/bosses/scarlet.lua:86: in function <data/actions/scripts/bosses/scarlet.lua:24>

Lua:
local config = {
    requiredLevel = 250,
    daily = true,
    BossPosition = Position(173, 900, 6),
    centerDemonRoomPosition = Position(173, 907, 6),
    playerPositions = {
        Position(172, 918, 6),
        Position(171, 919, 6),
        Position(172, 919, 6),
        Position(173, 919, 6),
        Position(172, 920, 6)

    },
    newPositions = {
        Position(170, 914, 6), -- Posição dos players 1,2,3,4,5
        Position(171, 914, 6),
        Position(172, 914, 6),
        Position(173, 914, 6),
        Position(174, 914, 6)
    },
}


function onUse(player, item, fromPosition, target, toPosition, monster, isHotkey)
        if player:getPosition() ~= Position(172, 918, 6) then          
            return true
        end  
        local storePlayers, playerTile = {}
        local exaustedSeconds = 1
        for i = 1, #config.playerPositions do
            playerTile = Tile(config.playerPositions[i]):getTopCreature()
            if not (player:getStorageValue(15365) <= os.time()) then
                player:say(string.format("You did this boss before %i hours.", player:isVip() == true and 8 or 12), TALKTYPE_MONSTER_SAY)
                player:sendTextMessage(MESSAGE_STATUS_CONSOLE_ORANGE, "Someone already did this room!")
                return true          
            end
            storePlayers[#storePlayers + 1] = playerTile
        end
       
        local specs, spec = Game.getSpectators(config.centerDemonRoomPosition, false, false, 10, 10, 10, 10)
        for i = 1, #specs do
            spec = specs[i]          
            if spec:isPlayer() then
                if item.itemid == 9826 then
                    if player:getPosition() ~= Position(169, 919, 6) then
                        item:transform(9826)
                        player:say("Someone is fighting with Scarlett Etzel.", TALKTYPE_MONSTER_SAY)
                        return true
                    end
                end
                return true
            end
        end      

        local specs, spec = Game.getSpectators(config.centerDemonRoomPosition, false, false, 10, 10, 10, 10)
        for i = 1, #specs do
            spec = specs[i]
            if spec:isPlayer() then
                player:say("Someone is fighting with Scarlett Etzel.", TALKTYPE_MONSTER_SAY)
                player:sendTextMessage(MESSAGE_STATUS_CONSOLE_ORANGE, "Someone is fighting with Scarlett Etzel.")
                return true
            end

            spec:remove()
        end
   
        local players
        local monster = Game.createMonster("Scarlett Etzel", Position(173, 900, 6))
        monster:setReward(true)
        for i = 1, #storePlayers do
            players = storePlayers[i]
       
            if not (players:getStorageValue(15365) <= os.time()) then
                players:sendTextMessage(TALKTYPE_MONSTER_SAY, string.format("You did this boss before %i hours.", player:isVip() == true and 8 or 12))
                player:say("Someone already did this room!", TALKTYPE_MONSTER_SAY)
                return
            end
        end
        for i = 1, #storePlayers do
            players = storePlayers[i]
            config.playerPositions[i]:sendMagicEffect(CONST_ME_POFF)
            players:teleportTo(config.newPositions[i])
            config.newPositions[i]:sendMagicEffect(CONST_ME_ENERGYAREA)
            players:setDirection(DIRECTION_NORTH)
           
            if players:isVip() then
                players:setStorageValue(15365, os.time()+exaustedSeconds*28800)
            else
                players:setStorageValue(15365, os.time()+exaustedSeconds*43200)
            end
        end
    return true
end
 

jonasu

Active Member
Joined
Nov 3, 2009
Messages
131
Solutions
1
Reaction score
32
Location
Stockholm, Sweden
is this in your global.lua?
dofile('data/vip-system.lua')

and is the vip-system.lua created at data/vip-system.lua?
If not it's trying to call the function isVip which it cant find
 
Top