• Vote in October Mapping Competition to select a winner!
  • 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!

RevScripts revscript train monk

Moody

New Member
Joined
Feb 8, 2020
Messages
46
Reaction score
1
hi i am use this train monk script by xikini and it no work 100%
say this msg random sometime no know why and no can go in tp wait 2h or 2 day and never work. say msg again always

Training tiles are still being populated by the server. Please wait 10 seconds.

and when iam make restart server i wait 2h for script work but sometime i wait more 10 h or 20 h for work and sometime never work
can any help and fix it?
 

4Nathu4

valoria.online
Premium User
Joined
Oct 27, 2009
Messages
101
Solutions
3
Reaction score
29
It seems that you've messed up the configuration.
Post your config from line 3 of Xikini's script.
 
OP
M

Moody

New Member
Joined
Feb 8, 2020
Messages
46
Reaction score
1
i am change script for make 2 scripts 1 vip and 1 to all
so i am make 2 script here
Lua:
local positionData = {}

local config = {
    actionids = {45001, 45002, 45003}, -- {entryTile, playerTile, exitTile}
    trainingPartner = "Training Monk",
    exitPosition = false, -- use Position(x, y, z) OR false -- false will teleport player to their home town.
   boundaries = {{x = 1015, y = 1015}, {x = 1515, y = 1515}, z = 7}, -- {{north_west_corner}, {south_east_corner}, floor_level}
    portalID = 1387
}

local moveEvent = MoveEvent()
moveEvent:type("stepin")

function moveEvent.onStepIn(player, item, position, fromPosition)
    if not player:isPlayer() then
        return true
    end

    local actionID = item:getActionId()

    -- if teleporting out of trainers
    if actionID == config.actionids[3] then
        -- teleport player out
        local exit_position = config.exitPosition
        if exit_position == false then
            exit_position = player:getTown():getTemplePosition()
        end
        player:teleportTo(exit_position)
     
        -- remove creatures
        local spec = Game.getSpectators(fromPosition, false, false, 3, 3, 3, 2)
        for i = 1, #spec do
            spec[i]:getPosition():sendMagicEffect(CONST_ME_POFF)
            spec[i]:remove()
        end
        return true
    -- if teleporting into trainers
    elseif actionID == config.actionids[1] then
        for i = 1, #positionData do
            local spec, players = Game.getSpectators(positionData[i][1], false, false, 2, 2, 2, 2), 0
         
            -- if creatures exist in training position, check if any are a player
            if #spec > 0 then
                for i = 1, #spec do
                    if spec[i]:isPlayer() then
                        if spec[i]:getIp() ~= 0 then -- if player is still online (not x-logged or disconnected)
                            players = 1
                        end
                        break
                    end
                end
            end
         
            -- if no online player found, and creatures exist, remove all creatures in training room.
            if players == 0 and #spec > 0 then
                for i = 1, #spec do
                    spec[i]:remove()
                end
                spec = {} -- clear spectator table
            end
         
            -- if empty, teleport in and create training creatures
            if #spec < 1 then
                player:teleportTo(positionData[i][1])
                for n = 1, 3 do
                    Game.createMonster(config.trainingPartner, positionData[i][n + 1])
                end
                return true
            end
        end
    end

    -- no locations available to teleport to
    local text = "Sorry, no training tiles are available. Try again later."
    if not positionData[1] then
        text = "Training tiles are still being populated by the server. Please wait 10 seconds."
    end
    player:sendTextMessage(MESSAGE_STATUS_WARNING, text)
    player:teleportTo(fromPosition, true)
    return true
end

moveEvent:aid(config.actionids[1], config.actionids[3])
moveEvent:register()


local direction = {
    {-1, 0, -1, 1, -1, -1, -3, 0}, -- west
    {1, 0, 1, 1, 1, -1, 3, 0}, -- east
    {0, -1, 1, -1, -1, -1, 0, -3}, -- north
    {0, 1, 1, 1, -1, 1, 0, 3} -- south
}

local function collect_positionData(current_x, current_y)
    local position = Position(current_x, current_y, config.boundaries.z)
    local tile = Tile(position)

    -- if tile exists
    if tile then
        -- if tile has actionid
        local item = Item(tile:getGround().uid)
        if item:getActionId() == config.actionids[2] then
            -- find positions to spawn training creatures
            for i = 1, 4 do -- 4 possible directions
                -- make sure tile exists
                local check_tile = Tile(Position(current_x + direction[i][1], current_y + direction[i][2], config.boundaries.z))
                if check_tile then
                    -- if teleport exists on tile
                    local teleport_count = check_tile:getItemCountById(config.portalID)
                    if teleport_count > 0 then
                        -- we know which direction to spawn training creatures
                        local pos_1 = Position(current_x + direction[i][3], current_y + direction[i][4], config.boundaries.z)
                        local pos_2 = Position(current_x + direction[i][5], current_y + direction[i][6], config.boundaries.z)
                        local pos_3 = Position(current_x + direction[i][7], current_y + direction[i][8], config.boundaries.z)
                         -- add positions into table
                        positionData[#positionData + 1] = {position, pos_1, pos_2, pos_3}
                        break
                    end
                end
            end
        end
    end

    -- calculate next tile
    if current_x == config.boundaries[2].x then
        current_x = config.boundaries[1].x
        current_y = current_y + 1
    else
        current_x = current_x + 1
    end

    -- check if next tile is within check area
    if config.boundaries[2].y + 1 ~= current_y then
        addEvent(collect_positionData, 1, current_x, current_y)
    end
end

local globalEvent = GlobalEvent("training_Monks_One")
globalEvent:type("startup")

function globalEvent.onStartup()
    addEvent(collect_positionData, 1000, config.boundaries[1].x, config.boundaries[1].y)
    return true
end

globalEvent:register()



local loginEvent = CreatureEvent("training_Monks_One")
loginEvent:type("login")

function loginEvent.onLogin(player)
    local north_west = Position(config.boundaries[1].x, config.boundaries[1].y, config.boundaries.z)
    local south_east = Position(config.boundaries[2].x, config.boundaries[2].y, config.boundaries.z)
    if player:getPosition():isInRange(north_west, south_east) then
        local exit_position = config.exitPosition
        if exit_position == false then
            exit_position = player:getTown():getTemplePosition()
        end
        player:teleportTo(exit_position)
    end
    return true
end

loginEvent:register()
and this 2
Lua:
local positionData2 = {}

local config = {
    actionids = {45004, 45005, 45006}, -- {entryTile, playerTile, exitTile}
    trainingPartner = "Target Monk",
    exitPosition = false, -- use Position(x, y, z) OR false -- false will teleport player to their home town.
    boundaries = {{x = 1015, y = 1015}, {x = 1515, y = 1515}, z = 8}, -- {{north_west_corner}, {south_east_corner}, floor_level}
    portalID = 1387
}

local moveEvent = MoveEvent()
moveEvent:type("stepin")

function moveEvent.onStepIn(player, item, position, fromPosition)
    if not player:isPlayer() then
        return true
    end

    local actionID = item:getActionId()

    -- if teleporting out of trainers
    if actionID == config.actionids[3] then
        -- teleport player out
        local exit_position = config.exitPosition
        if exit_position == false then
            exit_position = player:getTown():getTemplePosition()
        end
        player:teleportTo(exit_position)
     
        -- remove creatures
        local spec = Game.getSpectators(fromPosition, false, false, 2, 2, 2, 2)
        for i = 1, #spec do
            spec[i]:getPosition():sendMagicEffect(CONST_ME_POFF)
            spec[i]:remove()
        end
        return true
     
    -- if teleporting into trainers
    elseif actionID == config.actionids[1] then
        for i = 1, #positionData2 do
            local spec, players = Game.getSpectators(positionData2[i][1], false, false, 2, 2, 2, 2), 0
         
            -- if creatures exist in training position, check if any are a player
            if #spec > 0 then
                for i = 1, #spec do
                    if spec[i]:isPlayer() then
                        if spec[i]:getIp() ~= 0 then -- if player is still online (not x-logged or disconnected)
                            players = 1
                        end
                        break
                    end
                end
            end
         
            -- if no online player found, and creatures exist, remove all creatures in training room.
            if players == 0 and #spec > 0 then
                for i = 1, #spec do
                    spec[i]:remove()
                end
                spec = {} -- clear spectator table
            end
         
            -- if empty, teleport in and create training creatures
            if #spec < 1 then
                player:teleportTo(positionData2[i][1])
                for n = 1, 3 do
                    Game.createMonster(config.trainingPartner, positionData2[i][n + 1])
                end
                return true
            end
        end
    end

    -- no locations available to teleport to
    local text = "Sorry, no training tiles are available. Try again later."
    if not positionData2[1] then
        text = " Training tiles are still being populated by the server. Please wait 10 seconds."
    end
    player:sendTextMessage(MESSAGE_STATUS_WARNING, text)
    player:teleportTo(fromPosition, true)
    return true
end

moveEvent:aid(config.actionids[1], config.actionids[3])
moveEvent:register()


local direction = {
    {-1, 0, -1, 1, -1, -1, -3, 0}, -- west
    {1, 0, 1, 1, 1, -1, 3, 0}, -- east
    {0, -1, 1, -1, -1, -1, 0, -3}, -- north
    {0, 1, 1, 1, -1, 1, 0, 3} -- south
}

local function collect_positionData2(current_x, current_y)
    local position = Position(current_x, current_y, config.boundaries.z)
    local tile = Tile(position)

    -- if tile exists
    if tile then
        -- if tile has actionid
        local item = Item(tile:getGround().uid)
        if item:getActionId() == config.actionids[2] then
            -- find positions to spawn training creatures
            for i = 1, 4 do -- 4 possible directions
                -- make sure tile exists
                local check_tile = Tile(Position(current_x + direction[i][1], current_y + direction[i][2], config.boundaries.z))
                if check_tile then
                    -- if teleport exists on tile
                    local teleport_count = check_tile:getItemCountById(config.portalID)
                    if teleport_count > 0 then
                        -- we know which direction to spawn training creatures
                        local pos_1 = Position(current_x + direction[i][3], current_y + direction[i][4], config.boundaries.z)
                        local pos_2 = Position(current_x + direction[i][5], current_y + direction[i][6], config.boundaries.z)
                        local pos_3 = Position(current_x + direction[i][7], current_y + direction[i][8], config.boundaries.z)
                         -- add positions into table
                        positionData2[#positionData2 + 1] = {position, pos_1, pos_2, pos_3}
                        break
                    end
                end
            end
        end
    end

    -- calculate next tile
    if current_x == config.boundaries[2].x then
        current_x = config.boundaries[1].x
        current_y = current_y + 1
    else
        current_x = current_x + 1
    end

    -- check if next tile is within check area
    if config.boundaries[2].y + 1 ~= current_y then
        addEvent(collect_positionData2, 1, current_x, current_y)
    end
end

local globalEvent = GlobalEvent("Training_Monks_Two")
globalEvent:type("startup")

function globalEvent.onStartup()
    addEvent(collect_positionData2, 1000, config.boundaries[1].x, config.boundaries[1].y)
    return true
end

globalEvent:register()



local loginEvent = CreatureEvent("Training_Monks_Two")
loginEvent:type("login")

function loginEvent.onLogin(player)
    local north_west = Position(config.boundaries[1].x, config.boundaries[1].y, config.boundaries.z)
    local south_east = Position(config.boundaries[2].x, config.boundaries[2].y, config.boundaries.z)
    if player:getPosition():isInRange(north_west, south_east) then
        local exit_position = config.exitPosition
        if exit_position == false then
            exit_position = player:getTown():getTemplePosition()
        end
        player:teleportTo(exit_position)
    end
    return true
end

loginEvent:register()
 
Last edited:

Xikini

I whore myself out for likes
Premium User
Joined
Nov 17, 2010
Messages
4,590
Solutions
245
Reaction score
2,684
can any1 only try help?
I'm no longer active here, but I'd suggest for you to find the original script and test it / get it working properly before you make edits to it.

That way you know the original script worked properly and without errors.

After that, you can start making edits / modifying the script.
 

Landera

Advanced OT User
Joined
Nov 24, 2011
Messages
801
Solutions
1
Reaction score
241
I'm no longer active here, but I'd suggest for you to find the original script and test it / get it working properly before you make edits to it.

That way you know the original script worked properly and without errors.

After that, you can start making edits / modifying the script.
Ill miss you as much as i miss ur pikachu avatar
 
OP
M

Moody

New Member
Joined
Feb 8, 2020
Messages
46
Reaction score
1
I'm no longer active here, but I'd suggest for you to find the original script and test it / get it working properly before you make edits to it.

That way you know the original script worked properly and without errors.

After that, you can start making edits / modifying the script.
iam no know when problem happened for check 2 script.
problem happen any time any day
this my change for script only
Code:
boundaries = {{x = 70, y = 125}, {x = 74, y = 130}, z = 7}, -- {{north_west_corner}, {south_east_corner}, floor_level}
to this
boundaries = {{x = 1015, y = 1015}, {x = 1515, y = 1515}, z = 7}, -- {{north_west_corner}, {south_east_corner}, floor_level}


local spec = Game.getSpectators(fromPosition, false, false, 2, 2, 2, 2)
to this
local spec = Game.getSpectators(fromPosition, false, false, 3, 3, 3, 2)

    local direction = {   
   {-1, 0, -1, 1, -1, -1, -3, 0}, -- west   
   {1, 0, 1, 1, 1, -1, 3, 0}, -- east   
   {0, -1, 1, -1, -1, -1, 0, -3}, -- north   
   {0, 1, 1, 1, -1, 1, 0, 3} -- south   
}   

to this

    local direction = {
    {-1, 0, -1, 1, -1, -1, -3, 0}, -- west
    {1, 0, 1, 1, 1, -1, 3, 0}, -- east
    {0, -1, 1, -1, -1, -1, 0, -3}, -- north
    {0, 1, 1, 1, -1, 1, 0, 3} -- south
}


local globalEvent = GlobalEvent()
to this
local globalEvent = GlobalEvent("training_Monks_One")

local loginEvent = CreatureEvent("onLogin_trainingRoomTeleporter")
to this
local loginEvent = CreatureEvent("Training_Monks_One")
Post automatically merged:

and 1 other script for vip i am change all
Code:
positionData
to
positionData2
 
OP
M

Moody

New Member
Joined
Feb 8, 2020
Messages
46
Reaction score
1
iam now know when bug is happen
bug only is happen if iam make this command /reload scripts
need restart server for fix train tp again or is say this forever
Training tiles are still being populated by the server. Please wait 10 seconds.
 
Top