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

IsInRange how to use?

damix

New Member
Joined
Dec 16, 2017
Messages
28
Reaction score
1
Hello. I need to do a script that will teleport players from a given position to the temple after entering the command / shift lever. I am using otx 3.
I have something like that, but it only works for players who pronounce the command. I need the script to transfer everyone in this area.

Code:
local arena = {
     from = {x=1000, y=1000, z=7}, -- left top corner of  arena
     to = {x=1010, y=1010, z=7}, -- right bottom corner of  arena
     temple = { x = 500, y = 500, z = 7 } -- change it to temple pos
}

function onSay(player, words, param)

        broadcastMessage("Test teleportacji grupowej.", MESSAGE_STATUS_CONSOLE_RED)


       if isInRange(getPlayerPosition(player), arena.from,arena.to) then

        player:teleportTo(player:getTown():getTemplePosition())

     end

   return true


end
 
margoh I changed but still teleports only the player who uses the lever, not everyone who is in the position.
Aeronix I did something like this, but it does not teleport all, only the player who uses the lever.
Code:
local spectators = Game.getSpectators(Position(1000, 1000, 7), false, false, 10,10,10,10)





function onUse(player, item, fromPosition, target, toPosition, isHotkey)

        broadcastMessage("Test teleportacji grupowej.", MESSAGE_STATUS_CONSOLE_RED)


       for i = 1, #spectators do
        local spectator = spectators[i]
        if spectator:isPlayer() then
        
     broadcastMessage("Test czy dziala petla.", MESSAGE_STATUS_CONSOLE_RED)
    player:teleportTo(player:getTown():getTemplePosition())

        end
    end


   return true


end

249a8573e67d5.jpg.html


I mean exactly something like that. The player uses the lever, and all players from the red square are teleported to the temple.
Zapodaj.Net - Darmowy hosting zdjęć i obrazków bez rejestracji! - 249a8573e67d5.jpg
a>
 
margoh I changed but still teleports only the player who uses the lever, not everyone who is in the position.
Aeronix I did something like this, but it does not teleport all, only the player who uses the lever.
Code:
local spectators = Game.getSpectators(Position(1000, 1000, 7), false, false, 10,10,10,10)





function onUse(player, item, fromPosition, target, toPosition, isHotkey)

        broadcastMessage("Test teleportacji grupowej.", MESSAGE_STATUS_CONSOLE_RED)


       for i = 1, #spectators do
        local spectator = spectators[i]
        if spectator:isPlayer() then
      
     broadcastMessage("Test czy dziala petla.", MESSAGE_STATUS_CONSOLE_RED)
    player:teleportTo(player:getTown():getTemplePosition())

        end
    end


   return true


end

249a8573e67d5.jpg.html


I mean exactly something like that. The player uses the lever, and all players from the red square are teleported to the temple.
Zapodaj.Net - Darmowy hosting zdjęć i obrazków bez rejestracji! - 249a8573e67d5.jpg
a>
Because you're still teleporting yourself instead of spectators.
Also bring 'local spectators' into the function.
 
Back
Top