• 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] Boss Room

helviio

Member
Joined
Apr 30, 2019
Messages
42
Solutions
1
Reaction score
7
Hello Otland People ... I come through this publication Ask for help to edit my script for [Boss Room] OTX2, TFS 0.X ... He does more or less what I want to be done ... as in this GIF he can enter alone or with more 1/2/3 players


OTCv8 - Admin 2021-02-26 23-31-56.gif

However, he does not summon the monster. I would like you to summon I would also like to add a check if there is a player in the room making the boss so that other players cannot enter. only enter when the other players leave And the same player who made this boss cannot make the boss again for 12 hours and also add the following if the player enters alone. example boss, 1 player "Rat" // 2 players "Cave Rat" // 3 Players "Spider" // 4 Players "poison Spider" and after killing the Boss the monster drops the loot and opens a portal so that the player can leave ... and then immediately clean the room so that another player can enter ...
and set a time for him to kill the boss ... and if he doesn't, he'll be kicked out of the room so that other people can enter the room


My script is here, remembering that it is for OTX2, TFS 0.X


Lua:
   local PosicionesDeLosJugadores = {
      { x = 32249, y = 31585, z = 7, stackpos = 253 }, -- ultimo sempre sem virgula
      { x = 32249, y = 31586, z = 7, stackpos = 253 },
      { x = 32249, y = 31587, z = 7, stackpos = 253 },
      { x = 32249, y = 31588, z = 7, stackpos = 253 }
   }
   local DestinoDeLosJugadores = {
      { x = 32250, y = 31600, z = 8 }, -- ultimo sempre sem virgula
      { x = 32250, y = 31600, z = 8 },
      { x = 32250, y = 31600, z = 8 },
      { x = 32250, y = 31600, z = 8 }

   }
   --# Cantidad minima de jugadores que pueden entrar.
   local JugadoresMinimosParaEntrar = 1
   local NivelMinimoRequerido = 1

   --# Esta funcion solo se puede modificar si usara otro tipo de palanca.
   local function onUseLever(item)
      doTransformItem(item.uid, (item.itemid == 1945 and 1946 or 1945))
      return true
   end

   --# Funcion principal, no necesitas editarla solo configurar las variables al comienzo del script!!!
   function onUse(cid, item, fromPosition, target, toPosition)
   local _errorLvl = 0
   local GrupoDeJugadores = {}
   local index = 1
   local _errorInfo = ''
   for _, position in pairs(PosicionesDeLosJugadores) do
      local Jugador = getThingfromPos(position)
      if isPlayer(Jugador.uid) then
         if getPlayerLevel(Jugador.uid) >= NivelMinimoRequerido then
         GrupoDeJugadores[index] = Jugador
         index = index + 1
         else
         _errorLvl = _errorLvl + 1
         end
      end
   end
   if _errorLvl > 0 then
      _errorInfo = ' (The minimum level is ' .. NivelMinimoRequerido .. ' and some players do not meet this requirement.)'
   end
   if ((index * 2) > (#PosicionesDeLosJugadores + #DestinoDeLosJugadores)) then
      if getPlayerAccess(cid) then
      doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_RED, 'A symmetry error has been detected in the code, check the console for more details.')
      end
      print('ERROR: The variables do not comply with a correct symmetry.')
      --!!! Solution: reparar las tablas de posiciones...
      return false
   end
   if #GrupoDeJugadores == 0 then
      doPlayerSendCancel(cid, 'There is no player in his starting position.' .. _errorInfo)
      return onUseLever(item)
   end
   if #GrupoDeJugadores < JugadoresMinimosParaEntrar then
      doPlayerSendCancel(cid, 'To start, there must be at least ' .. JugadoresMinimosParaEntrar .. ' players.' .. _errorInfo)
      return onUseLever(item)
   end
   for _, Jugador in pairs(GrupoDeJugadores) do
      doSendMagicEffect(getCreaturePosition(Jugador.uid), CONST_ME_POFF)
      doTeleportThing(Jugador.uid, DestinoDeLosJugadores[_])
      doSendMagicEffect(DestinoDeLosJugadores[_], CONST_ME_TELEPORT)
      doPlayerSendCancel(cid, 'You are welcome!')
   end
   return onUseLever(item)
   end



I appreciate the understanding of all of you I apologize for my English and I sincerely hope you can help me
 
Last edited:

Indahouse

Member
Joined
May 13, 2015
Messages
79
Reaction score
10
Hello, i dont know a loot, but what i do, just copy same as Anihilator script, is Teleport from X pos, to X post, delete lines of all Angry Demons, and just left 1 Line for 1 Boss, then just Add the name where is Angry demon to the name of Boss, add a the ID In remeres and on lua, and then you will have your teleport working, with all.
I Can give you the script, but the problem is a revscript, so i dont know for another OTS, but is looks like same, ( just copy your own anihilator script and change name )

I have added lines where you need configure:

Lua:
local setting = {
    -- At what level can do the quest?
    requiredLevel = 100,
    -- Can it be done daily? true = yes, false = no
    daily = true,
    -- Do not change from here down
    centerDemonRoomPosition = {x = 33221, y = 31659, z = 13}, -- CENTER ROOM
    demonsPositions = {
        {x = 33219, y = 31657, z = 13}, -- Save this line for 1 boss and delete the 5 others
        {x = 33221, y = 31657, z = 13},
        {x = 33223, y = 31659, z = 13},
        {x = 33224, y = 31659, z = 13},
        {x = 33220, y = 31661, z = 13},
        {x = 33222, y = 31661, z = 13}
    },
    playersPositions = {
        {fromPos = {x = 33225, y = 31671, z = 13}, toPos = {x = 33222, y = 31659, z = 13}}, -- The 4 Players positions, first where lever and second where teleport
        {fromPos = {x = 33224, y = 31671, z = 13}, toPos = {x = 33221, y = 31659, z = 13}},
        {fromPos = {x = 33223, y = 31671, z = 13}, toPos = {x = 33220, y = 31659, z = 13}},
        {fromPos = {x = 33222, y = 31671, z = 13}, toPos = {x = 33219, y = 31659, z = 13}},
    }
}

local lever = Action()

function lever.onUse(player, item, fromPosition, target, toPosition, isHotkey)
    if item.itemid == 1945 then
        -- Checks if you have the 4 players and if they have the required level
        for i = 1, #setting.playersPositions do
            local creature = Tile(setting.playersPositions[i].fromPos):getTopCreature()
            if not creature then
                player:sendTextMessage(MESSAGE_EVENT_ADVANCE, "Four players are required to start the quest.")
                return true
            end
            if creature and creature:getLevel() < setting.requiredLevel then
                player:sendTextMessage(MESSAGE_STATUS_SMALL, "All the players need to be level ".. setting.requiredLevel .." or higher.")
                return true
            end
        end

        -- Checks if there are still players inside the room, if so, return true
        if Position.hasPlayer(setting.centerDemonRoomPosition, 4, 4) then
            player:sendTextMessage(MESSAGE_STATUS_SMALL, "A team is already inside the quest room.")
            return true
        end

        -- Create monsters
        for i = 1, #setting.demonsPositions do
            Game.createMonster("Angry Demon", setting.demonsPositions[i]) -- Name of boss on angry demon
        end

        -- Get players from the tiles "playersPositions" and teleport to the demons room if all of the above requirements are met
        for i = 1, #setting.playersPositions do
            local creature = Tile(setting.playersPositions[i].fromPos):getTopCreature()
            if creature and creature:isPlayer() then
                creature:teleportTo(setting.playersPositions[i].toPos)
                creature:getPosition():sendMagicEffect(CONST_ME_TELEPORT)
            else
                return false
            end
        end
        item:transform(1946)
    elseif item.itemid == 1946 then
        -- If it has "daily = true" then it will execute this function
        if setting.daily then
            player:sendCancelMessage(RETURNVALUE_NOTPOSSIBLE)
            return true
        end
        -- Not be able to push the lever back if someone is still inside the monsters room
        if Position.hasPlayer(setting.centerDemonRoomPosition, 4, 4) then
            player:sendTextMessage(MESSAGE_STATUS_SMALL, "A team is already inside the quest room.")
            return true
        end
        -- Removes all monsters so that the next team can enter
        if Position.removeMonster(setting.centerDemonRoomPosition, 4, 4) then
            return true
        end
        item:transform(1945) -- ID Of the Lever in Remeres
    end
    return true
end

lever:uid(30025) -- Obviously is a revscript so the Unique ID on the lever added on remeres but in your case is add a line on actions.xml if im right
lever:register()
 
OP
OP
helviio

helviio

Member
Joined
Apr 30, 2019
Messages
42
Solutions
1
Reaction score
7
Hello, i dont know a loot, but what i do, just copy same as Anihilator script, is Teleport from X pos, to X post, delete lines of all Angry Demons, and just left 1 Line for 1 Boss, then just Add the name where is Angry demon to the name of Boss, add a the ID In remeres and on lua, and then you will have your teleport working, with all.
I Can give you the script, but the problem is a revscript, so i dont know for another OTS, but is looks like same, ( just copy your own anihilator script and change name )

I have added lines where you need configure:

Lua:
local setting = {
    -- At what level can do the quest?
    requiredLevel = 100,
    -- Can it be done daily? true = yes, false = no
    daily = true,
    -- Do not change from here down
    centerDemonRoomPosition = {x = 33221, y = 31659, z = 13}, -- CENTER ROOM
    demonsPositions = {
        {x = 33219, y = 31657, z = 13}, -- Save this line for 1 boss and delete the 5 others
        {x = 33221, y = 31657, z = 13},
        {x = 33223, y = 31659, z = 13},
        {x = 33224, y = 31659, z = 13},
        {x = 33220, y = 31661, z = 13},
        {x = 33222, y = 31661, z = 13}
    },
    playersPositions = {
        {fromPos = {x = 33225, y = 31671, z = 13}, toPos = {x = 33222, y = 31659, z = 13}}, -- The 4 Players positions, first where lever and second where teleport
        {fromPos = {x = 33224, y = 31671, z = 13}, toPos = {x = 33221, y = 31659, z = 13}},
        {fromPos = {x = 33223, y = 31671, z = 13}, toPos = {x = 33220, y = 31659, z = 13}},
        {fromPos = {x = 33222, y = 31671, z = 13}, toPos = {x = 33219, y = 31659, z = 13}},
    }
}

local lever = Action()

function lever.onUse(player, item, fromPosition, target, toPosition, isHotkey)
    if item.itemid == 1945 then
        -- Checks if you have the 4 players and if they have the required level
        for i = 1, #setting.playersPositions do
            local creature = Tile(setting.playersPositions[i].fromPos):getTopCreature()
            if not creature then
                player:sendTextMessage(MESSAGE_EVENT_ADVANCE, "Four players are required to start the quest.")
                return true
            end
            if creature and creature:getLevel() < setting.requiredLevel then
                player:sendTextMessage(MESSAGE_STATUS_SMALL, "All the players need to be level ".. setting.requiredLevel .." or higher.")
                return true
            end
        end

        -- Checks if there are still players inside the room, if so, return true
        if Position.hasPlayer(setting.centerDemonRoomPosition, 4, 4) then
            player:sendTextMessage(MESSAGE_STATUS_SMALL, "A team is already inside the quest room.")
            return true
        end

        -- Create monsters
        for i = 1, #setting.demonsPositions do
            Game.createMonster("Angry Demon", setting.demonsPositions[i]) -- Name of boss on angry demon
        end

        -- Get players from the tiles "playersPositions" and teleport to the demons room if all of the above requirements are met
        for i = 1, #setting.playersPositions do
            local creature = Tile(setting.playersPositions[i].fromPos):getTopCreature()
            if creature and creature:isPlayer() then
                creature:teleportTo(setting.playersPositions[i].toPos)
                creature:getPosition():sendMagicEffect(CONST_ME_TELEPORT)
Mais
retorno falso
Final
Final
        item:transform(1946)
elseif item.itemid == 1946 então
-- Se ele tem "diariamente = verdade" então ele executará esta função
se configuração.diariamente, então
player:sendCancelMessage (RETURNVALUE_NOTPOSSIBLE)
retorno verdadeiro
Final
- Não ser capaz de empurrar a alavanca para trás se alguém ainda está dentro da sala dos monstros
se position.hasPlayer (setting.centerDemonRoomPosition, 4, 4) em seguida
player:sendTextMessage (MESSAGE_STATUS_SMALL: "Uma equipe já está dentro da sala de busca.")
retorno verdadeiro
Final
- Remove todos os monstros para que a próxima equipe possa entrar
se position.removeMonster (setting.centerDemonRoomPosition, 4, 4) em seguida
retorno verdadeiro
Final
item:transform(1945) - ID of the Lever in Remeres
Final
retorno verdadeiro
Final

alavanca:uid(30025) -- Obviamente é um revscript para que o ID Unique na alavanca adicionada em remeres, mas no seu caso é adicionar uma linha em ações.xml se eu estiver certo
alavanca:registro()
[/CÓDIGO]
[/QUOTE]



hello my friend thank you so much for answering me ... i'm grateful for trying to help me ... i already managed to do this part ... now i'm stuck in clearing the boss area ... why when i enter the boss room and if I haven't killed the boss he summons 2 bosses ... and I also can't add a check so that the player can't do it before 12 hrs ... an example if he did the boss now he can only do in another 12 hours
 

Attachments

  • OTCv8 - Admin 2021-02-27 18-54-00.gif
    OTCv8 - Admin 2021-02-27 18-54-00.gif
    13.7 MB · Views: 6 · VirusTotal
Last edited:

Indahouse

Member
Joined
May 13, 2015
Messages
79
Reaction score
10
Well, you are looking for a 'timer' , this i dont know i dont have working with this , try find anything in you ot, similar, a boss can be do it in X Time, and copy this script .. I like this im trying to learn, for sure is there anyone know more than me can answer you about this :)
 

Indahouse

Member
Joined
May 13, 2015
Messages
79
Reaction score
10
Lua:
local t = {
players = { -- PLAYERS POSITIONS
[1] = Position(XXXX,XXXX,X),
[2] = Position(XXXXX,XXXX,X),
[3] = Position(XXXX,XXXX,X),
[4] = Position(XXXX,XXXX,X)
},

boss = {name = "RAT", create_pos = Position(33396,32642,6)},

destination = Position(XXXX,XXX,X), -- POSITION TELEPORT PLAYERS

cooldown = {0, "sec"}, -- TIME FOR USE IT AGAIN : {2, "sec"}, {5, "min"}, {10, "hour"}, {3, "day"}

storage = 56482 -- STORAGE USED ON SERVER
}

function onUse(player, item, fromPosition, target, toPosition, isHotkey) -- If revscript : function ( name of ur revscript example RatBoss.onUse )
local players, tab = {}, t.players
for i = 1, #tab do
local tile = Tile(tab)
if tile then
local p = Player(tile:getTopCreature())
if p then
if p:getStorageValue(t.storage) <= os.time() then
players[#players + 1] = p:getId()
end
end
end
end
if #players == 0 then
player:sendCancelMessage("One or all players did not wait " .. getStrTime(t.cooldown) .. " to go again.")
return true
end
for i = 1, #tab do
local playerTile = Tile(tab)
local playerToGo = Player(playerTile:getTopCreature())
if playerToGo then
if isInArray(players, playerToGo:getId()) then
playerToGo:setStorageValue(t.storage, mathtime(t.cooldown) + os.time())
playerTile:relocateTo(t.destination)
tab:sendMagicEffect(CONST_ME_POFF)
end
end
end
t.destination:sendMagicEffect(CONST_ME_TELEPORT)
Game.createMonster(t.boss.name, t.boss.create_pos)
item:transform(item.itemid == 36319 or 1946 or 1945) -- Item 1945 is simple lever
return true
end

local boss_room = {fromPos = Position(33386, 32639, 6), toPos = Position(33405, 32659, 6)}
local bossplayer = Player(cid)
local exit = Position(33395, 32659, 6)

if bossplayer and isInRange(bossplayer:getPosition(), boss_room.fromPos, boss_room.toPos) then
   bossplayer:teleportTo(exit)
        end

function mathtime(table) -- by dwarfer
local unit = {"sec", "min", "hour", "day"}
for i, v in pairs(unit) do
if v == table[2] then
return table[1](60^(v == unit[4] and 2 or i-1))(v == unit[4] and 24 or 1)
end
end
return error("Bad declaration in mathtime function.")
end

function getStrTime(table) -- by dwarfer
local unit = {["sec"] = "second",["min"] = "minute",["hour"] = "hour",["day"] = "day"}
return tostring(table[1].." "..unit[table[2]]..(table[1] > 1 and "s" or ""))
end
 
OP
OP
helviio

helviio

Member
Joined
Apr 30, 2019
Messages
42
Solutions
1
Reaction score
7
Lua:
local t = {
players = { -- PLAYERS POSITIONS
[1] = Position(XXXX,XXXX,X),
[2] = Position(XXXXX,XXXX,X),
[3] = Position(XXXX,XXXX,X),
[4] = Position(XXXX,XXXX,X)
},

boss = {name = "RAT", create_pos = Position(33396,32642,6)},

destination = Position(XXXX,XXX,X), -- POSITION TELEPORT PLAYERS

cooldown = {0, "sec"}, -- TIME FOR USE IT AGAIN : {2, "sec"}, {5, "min"}, {10, "hour"}, {3, "day"}

storage = 56482 -- STORAGE USED ON SERVER
}

function onUse(player, item, fromPosition, target, toPosition, isHotkey) -- If revscript : function ( name of ur revscript example RatBoss.onUse )
local players, tab = {}, t.players
for i = 1, #tab do
local tile = Tile(tab)
if tile then
local p = Player(tile:getTopCreature())
if p then
if p:getStorageValue(t.storage) <= os.time() then
players[#players + 1] = p:getId()
end
end
end
end
if #players == 0 then
player:sendCancelMessage("One or all players did not wait " .. getStrTime(t.cooldown) .. " to go again.")
return true
end
for i = 1, #tab do
local playerTile = Tile(tab)
local playerToGo = Player(playerTile:getTopCreature())
if playerToGo then
if isInArray(players, playerToGo:getId()) then
playerToGo:setStorageValue(t.storage, mathtime(t.cooldown) + os.time())
playerTile:relocateTo(t.destination)
tab:sendMagicEffect(CONST_ME_POFF)
end
end
end
t.destination:sendMagicEffect(CONST_ME_TELEPORT)
Game.createMonster(t.boss.name, t.boss.create_pos)
item:transform(item.itemid == 36319 or 1946 or 1945) -- Item 1945 is simple lever
return true
end

local boss_room = {fromPos = Position(33386, 32639, 6), toPos = Position(33405, 32659, 6)}
local bossplayer = Player(cid)
local exit = Position(33395, 32659, 6)

if bossplayer and isInRange(bossplayer:getPosition(), boss_room.fromPos, boss_room.toPos) then
   bossplayer:teleportTo(exit)
        end

function mathtime(table) -- by dwarfer
local unit = {"sec", "min", "hour", "day"}
for i, v in pairs(unit) do
if v == table[2] then
return table[1](60^(v == unit[4] and 2 or i-1))(v == unit[4] and 24 or 1)
end
end
return error("Bad declaration in mathtime function.")
end

function getStrTime(table) -- by dwarfer
local unit = {["sec"] = "second",["min"] = "minute",["hour"] = "hour",["day"] = "day"}
return tostring(table[1].." "..unit[table[2]]..(table[1] > 1 and "s" or ""))
end
didn't work :/
 
Top