IsInRange how to use?

Discussion in 'Support' started by damix, Jun 13, 2018 at 4:19 PM.

  1. damix

    damix New Member

    Joined:
    Dec 16, 2017
    Messages:
    15
    Likes Received:
    1
    Best Answers:
    0
    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 (Text):
    1. local arena = {
    2.      from = {x=1000, y=1000, z=7}, -- left top corner of  arena
    3.      to = {x=1010, y=1010, z=7}, -- right bottom corner of  arena
    4.      temple = { x = 500, y = 500, z = 7 } -- change it to temple pos
    5. }
    6.  
    7. function onSay(player, words, param)
    8.  
    9.         broadcastMessage("Test teleportacji grupowej.", MESSAGE_STATUS_CONSOLE_RED)
    10.  
    11.  
    12.        if isInRange(getPlayerPosition(player), arena.from,arena.to) then
    13.  
    14.         player:teleportTo(player:getTown():getTemplePosition())
    15.  
    16.      end
    17.  
    18.    return true
    19.  
    20.  
    21. end
     
  2. margoh

    margoh {{ user.title }}

    Joined:
    Apr 1, 2013
    Messages:
    636
    Likes Received:
    205
    Best Answers:
    8
    Instead of command make an action script.
     
    damix likes this.
  3. Aeronx

    Aeronx Active Member

    Joined:
    Dec 17, 2015
    Messages:
    641
    Likes Received:
    74
    Best Answers:
    9
    use Game.getSpectators({x=1000, y=1000, z=7}, false, false, 10,10,10,10)
     
    damix likes this.
  4. damix

    damix New Member

    Joined:
    Dec 16, 2017
    Messages:
    15
    Likes Received:
    1
    Best Answers:
    0
    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 (Text):
    1. local spectators = Game.getSpectators(Position(1000, 1000, 7), false, false, 10,10,10,10)
    2.  
    3.  
    4.  
    5.  
    6.  
    7. function onUse(player, item, fromPosition, target, toPosition, isHotkey)
    8.  
    9.         broadcastMessage("Test teleportacji grupowej.", MESSAGE_STATUS_CONSOLE_RED)
    10.  
    11.  
    12.        for i = 1, #spectators do
    13.         local spectator = spectators[i]
    14.         if spectator:isPlayer() then
    15.        
    16.      broadcastMessage("Test czy dziala petla.", MESSAGE_STATUS_CONSOLE_RED)
    17.     player:teleportTo(player:getTown():getTemplePosition())
    18.  
    19.         end
    20.     end
    21.  
    22.  
    23.    return true
    24.  
    25.  
    26. end
    [​IMG]

    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
    [​IMG]
     
  5. 2Rec

    2Rec Well-Known Member

    Joined:
    Jul 31, 2013
    Messages:
    376
    Likes Received:
    380
    Best Answers:
    39
    Because you're still teleporting yourself instead of spectators.
    Also bring 'local spectators' into the function.
     
    damix likes this.
  6. damix

    damix New Member

    Joined:
    Dec 16, 2017
    Messages:
    15
    Likes Received:
    1
    Best Answers:
    0
    It works! Thank you guys very much for your help.
     

Share This Page

Loading...