1. Welcome to skUnity!

    Welcome to skUnity! This is a forum where members of the Skript community can communicate and interact. Skript Resource Creators can post their Resources for all to see and use.

    If you haven't done so already, feel free to join our official Discord server to expand your level of interaction with the comminuty!

    Now, what are you waiting for? Join the community now!

  2. LOOKING FOR A VERSION OF SKRIPT?

    You can always check out our Wiki for downloads and any other information about Skript!

Dismiss Notice
This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Solved Teleport player to random saved location

Discussion in 'Skript' started by Jerooski, Jun 6, 2020.

Thread Status:
Not open for further replies.
  1. Jerooski

    Jerooski Member

    Joined:
    Apr 19, 2020
    Messages:
    16
    Likes Received:
    0
    Code (Text):
    1. #--- TELEPORT LOCATIONS ---#
    2. options:
    3.     dungeon1: 0, 45, 0
    4.     dungeon2: 0, 100, 0
    5.     dungeon3: 0, 90, 0
    6.     dungeon4: 0, 30, 0
    7.     dungeon5: 0, 200, 0
    8.  
    9. on load:
    10.     add "{@dungeon1}" to {dungeonlist::*}
    11.     add "{@dungeon2}" to {dungeonlist::*}
    12.     add "{@dungeon3}" to {dungeonlist::*}
    13.     add "{@dungeon4}" to {dungeonlist::*}
    14.     add "{@dungeon5}" to {dungeonlist::*}
    15.  
    16. on rightclick on black concrete:
    17.     set {_dungeontp} to a random element out of {dungeonlist::*}
    18.     teleport player to location {_dungeontp} in world "dungeons"
    I cannot seem to make this work, it says on teleport line that "Variables cannot be used here" but if I use teleport player to {_dungeontp} no errors pop, but teleportation doesn't happen.
     
  2. Best Answer:
    Post #2 by Dave, Jun 6, 2020
  3. Dave

    Dave Active Member

    Joined:
    Jul 20, 2018
    Messages:
    228
    Likes Received:
    9
    It works.
    Code (Text):
    1.  
    2. on load:
    3.     loop 5 times:
    4.         if {spawn.dungeon%loop-number%} is set:
    5.             add {spawn.dungeon%loop-number%} to {dungeonlist::*}
    6. on unload:
    7.     delete {dungeonlist::*}
    8.  
    9. on rightclick on black concrete:
    10.     set {_dungeontp} to a random element out of {dungeonlist::*}
    11.     teleport player to {_dungeontp}
    12.     stop
    13.  
    14. command /setdungeon [<int>] [<text>]:
    15.     permission message: &cNo permissions.
    16.     permission: rank.admin
    17.     usage: /setdungeon <number>
    18.     aliases: sd
    19.     executable by: players
    20.     trigger:
    21.         if arg-1 is set:
    22.             if arg-2 is not set:
    23.                 set {spawn.dungeon%arg-1%} to player's location
    24.                 send "&aSpawn for dungeon %arg-1% set!"
    25.                 stop
    26.             else:
    27.                 stop
    28.         else:
    29.             send "&cUsage: /setdungeon <number>"
    30.  
     
    ZombiePigmanDude and Jerooski like this.
  4. zTak

    zTak Active Member

    Joined:
    Mar 3, 2018
    Messages:
    84
    Likes Received:
    6
    The Problem is that a location is more than just the coordinates. Its also C, E & F. You can see this if you press F3 in Minecraft.
    It would be better if you just create a command to set the location as @Dave said before.
     
    Jerooski likes this.
  5. Jerooski

    Jerooski Member

    Joined:
    Apr 19, 2020
    Messages:
    16
    Likes Received:
    0
    Thank you! This is great!
     
  6. Dave

    Dave Active Member

    Joined:
    Jul 20, 2018
    Messages:
    228
    Likes Received:
    9
    yea, th
    You're welcome! : )
     
Thread Status:
Not open for further replies.

Share This Page

Loading...