• 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 Script spawning wrong monsters when step in TP

Taurus

Texass
Joined
Jan 11, 2009
Messages
616
Solutions
2
Reaction score
30
Location
United States
I am attempting to copy this script to make a new warzone.
TFS 1.3 OTX - Client 10.99

This is the script I started with: (works like it should)

Lua:
if not warzoneConfig then
    warzoneConfig = {
        -- Warzone
        [45700] = {  -- action do movement
            center = Position(33117, 31956, 11),   -- centro da room do boss
            rangeX = 27, rangeY = 25,

            boss = "Gnomevil",   -- nome do boss
            teleportTo = Position(33106, 31955, 11),   -- Local onde o player será teleportado dentro da room
            locked = false,

            storage = 790014,    -- storage
            interval = 10 * 60 * 60,

            exit = Position(33001, 31900, 9)   -- Exit padrão
        },
     
     
        -- Warzone
        [45702] = {  -- action do movement
            center = Position(33110, 31965, 10), -- centro da room do boss
            rangeX = 26, rangeY = 25,

            boss = "Deathstrike",   -- nome do boss
            teleportTo = Position(33096, 31955, 10),   -- Local onde o player será teleportado dentro da room
            locked = false,

            storage = 790015,    -- storage
            interval = 10 * 60 * 60,

            exit = Position(33001, 31900, 9)   -- Exit padrão
        },
     
        -- Warzone
        [45701] = {  -- action do movement
            center = Position(33090, 31910, 12),
            rangeX = 20, rangeY = 20,

            boss = "Abyssador",   -- nome do boss
            teleportTo = Position(33083, 31904, 12),  -- Local onde o player será teleportado dentro da room
            locked = false,

            storage = 790016,    -- storage
            interval = 10 * 60 * 60,

            exit = Position(33001, 31900, 9)   -- Exit padrão
        }
     
     
    }

    warzoneConfig.findByName = function(name, last)
        local i, v = next(warzoneConfig, last)
        if type(v) == 'table' and v.boss == name then
            return v
        elseif not i then
            return nil
        end
        return warzoneConfig.findByName(name, i)
    end
end

local function filter(list, f, i)
    if i < #list then
        if f(list[i]) then
            return list[i], filter(list, f, i + 1)
        else
            return filter(list, f, i + 1)
        end
    elseif list[i] and f(list[i]) then
        return list[i]
    end
end

function onStepIn(creature, item, pos, fromPosition)
    if not creature:isPlayer() then
        creature:teleportTo(fromPosition)
        return false
    end

    local info = warzoneConfig[item:getActionId()]
    if not info then
        return false
    end

    if  creature:getStorageValue(info.storage) > os.time() then
        creature:sendTextMessage(MESSAGE_STATUS_CONSOLE_BLUE, "You have already cleared this warzone in the last ten hours.")
        creature:teleportTo(fromPosition)
        return false
    end

    if info.locked then
        creature:sendTextMessage(MESSAGE_STATUS_CONSOLE_BLUE, "Please, wait a minute until the room is cleared.")
        creature:teleportTo(fromPosition)
        return false
    end

    creature:teleportTo(info.teleportTo)
    local spectators = Game.getSpectators(info.center, false, false, 0, info.rangeX, 0, info.rangeY)
    if not filter(spectators, function(c) return c:isMonster() end, 1) then
        local boss = Game.createMonster(info.boss, info.center)
        boss:registerEvent('WarzoneBossDeath')
    end

    return true
end

No matter what when I step on the portal for my script it spawns Gnomevil. I can disable the spawn part of the script and nothing spawns... why is it spawning Gnomevil? ( I have tried several creatures.)

Here is what I have so far:
Lua:
if not dailyConfig then
    dailyConfig = {
        -- Daily
        [42052] = {  -- action do movement
            center = Position(32232, 32198, 7),           -- centr of boss room
            rangeX = 4, rangeY = 4,
         
            boss = "Rat",                           -- boss
            teleportTo = Position(32227, 32192, 7),       -- Location where the player will be teleported within the room
            locked = false,
         
            storage = 420123,                           -- storage
            interval = 10 * 60 * 60,
            exit = Position(33001, 31900, 9)               -- Exit
        }
    }
    dailyConfig.findByName = function(name, last)
        local i, v = next(dailyConfig, last)
        if type(v) == 'table' and v.boss == name then
            return v
        elseif not i then
            return nil
        end
        return dailyConfig.findByName(name, i)
    end
end
local function filter(list, f, i)
    if i < #list then
        if f(list[i]) then
            return list[i], filter(list, f, i + 1)
        else
            return filter(list, f, i + 1)
        end
    elseif list[i] and f(list[i]) then
        return list[i]
    end
end
function onStepIn(creature, item, pos, fromPosition)
    if not creature:isPlayer() then
        creature:sendTextMessage(MESSAGE_STATUS_CONSOLE_BLUE, "You are not a player")    
        creature:teleportTo(fromPosition)
        return false
    end
 
    local info = dailyConfig[item:getActionId()]
    if not info then
                creature:sendTextMessage(MESSAGE_STATUS_CONSOLE_BLUE, "No Action ID")
        return false
    end
 
    if  creature:getStorageValue(info.storage) > os.time() then
        creature:sendTextMessage(MESSAGE_STATUS_CONSOLE_BLUE, "You have already cleared this warzone in the last ten hours.")
        creature:teleportTo(fromPosition)
        return false
    end
    if info.locked then
        creature:sendTextMessage(MESSAGE_STATUS_CONSOLE_BLUE, "Please, wait a minute until the room is cleared.")
        creature:teleportTo(fromPosition)
        return false
    end
    creature:teleportTo(info.teleportTo)
 
    local spectators = Game.getSpectators(info.center, false, false, 0, info.rangeX, 0, info.rangeY)
 
    if not filter(spectators, function(c) return c:isMonster() end, 1) then
        local boss = Game.createMonster(info.boss, info.center)
        boss:registerEvent('DailyBossDeath')
    end
    return true
end
 
Lua:
function configureWarzone()
    warzoneConfig = {
        -- Warzone
        [45700] = {  -- action do movement
            center = Position(33117, 31956, 11),   -- centro da room do boss
            rangeX = 27, rangeY = 25,
            boss = "Gnomevil",   -- nome do boss
            teleportTo = Position(33106, 31955, 11),   -- Local onde o player será teleportado dentro da room
            locked = false,
            storage = 790014,    -- storage
            interval = 10 * 60 * 60,
            exit = Position(33001, 31900, 9)   -- Exit padrão
        },
   
  
        -- Warzone
        [45702] = {  -- action do movement
            center = Position(33110, 31965, 10), -- centro da room do boss
            rangeX = 26, rangeY = 25,
            boss = "Deathstrike",   -- nome do boss
            teleportTo = Position(33096, 31955, 10),   -- Local onde o player será teleportado dentro da room
            locked = false,
            storage = 790015,    -- storage
            interval = 10 * 60 * 60,
            exit = Position(33001, 31900, 9)   -- Exit padrão
        },
   
        -- Warzone
        [45701] = {  -- action do movement
            center = Position(33090, 31910, 12),
            rangeX = 20, rangeY = 20,
            boss = "Abyssador",   -- nome do boss
            teleportTo = Position(33083, 31904, 12),  -- Local onde o player será teleportado dentro da room
            locked = false,
            storage = 790016,    -- storage
            interval = 10 * 60 * 60,
            exit = Position(33001, 31900, 9)   -- Exit padrão
        },
      
        --ERU Warzone
        [42052] = {  -- action do movement
            center = Position(32232, 32198, 7),           -- centr of boss room
            rangeX = 4, rangeY = 4,
       
            boss = "Rat",                           -- boss
            teleportTo = Position(32227, 32192, 7),       -- Location where the player will be teleported within the room
            locked = false,
       
            storage = 420123,                           -- storage
            interval = 10 * 60 * 60,
            exit = Position(33001, 31900, 9)               -- Exit
        }
   
   
    }
    warzoneConfig.findByName = function(name, last)
        local i, v = next(warzoneConfig, last)
        if type(v) == 'table' and v.boss == name then
            return v
        elseif not i then
            return nil
        end
        return warzoneConfig.findByName(name, i)
    end
end

if not warzoneConfig then
creature:sendTextMessage(MESSAGE_STATUS_CONSOLE_BLUE, "configuring and testing")
    configureWarzone()  
end
local function filter(list, f, i)
    if i < #list then
        if f(list[i]) then
            return list[i], filter(list, f, i + 1)
        else
            return filter(list, f, i + 1)
        end
    elseif list[i] and f(list[i]) then
        return list[i]
    end
end
function onStepIn(creature, item, pos, fromPosition)
  
    --test start debug
    creature:sendTextMessage(MESSAGE_STATUS_CONSOLE_BLUE, "Starting")
    --end start debug
  
    if not creature:isPlayer() then
        --test player debug
        creature:sendTextMessage(MESSAGE_STATUS_CONSOLE_BLUE, "not player")
        --end player debug
        creature:teleportTo(fromPosition)
        return false
    end
    local info = warzoneConfig[item:getActionId()]
    if not info then
            --test info debug
            creature:sendTextMessage(MESSAGE_STATUS_CONSOLE_BLUE, "Error with warzone info. Attempting to reconfigure.")
            configureWarzone()
            --end info debug
        return false
    end
    if  creature:getStorageValue(info.storage) > os.time() then
        creature:sendTextMessage(MESSAGE_STATUS_CONSOLE_BLUE, "You have already cleared this warzone in the last ten hours.")
        creature:teleportTo(fromPosition)
        return false
    end
    if info.locked then
        creature:sendTextMessage(MESSAGE_STATUS_CONSOLE_BLUE, "Please, wait a minute until the room is cleared.")
        creature:teleportTo(fromPosition)
        return false
    end
    creature:teleportTo(info.teleportTo)
    local spectators = Game.getSpectators(info.center, false, false, 0, info.rangeX, 0, info.rangeY)
    if not filter(spectators, function(c) return c:isMonster() end, 1) then
        local boss = Game.createMonster(info.boss, info.center)
        boss:registerEvent('WarzoneBossDeath')
    end
    return true
end
 
Last edited:
He's not double/triple posting we are also PMing

Sorry I had to run.
That totally works.

I'll be able to look at it more later, but for the moment it spawned the rat, then it wouldn't let me repeat! Awesome!
 
Last edited:
Back
Top