Solved Teleport player to random saved location

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

  • LOOKING FOR A VERSION OF SKRIPT?

    You can always check out skUnity Downloads for downloads and any other information about Skript!

Status
Not open for further replies.

Jerooski

Member
Apr 19, 2020
16
0
0
25
Code:
#--- TELEPORT LOCATIONS ---#
options:
    dungeon1: 0, 45, 0
    dungeon2: 0, 100, 0
    dungeon3: 0, 90, 0
    dungeon4: 0, 30, 0
    dungeon5: 0, 200, 0

on load:
    add "{@dungeon1}" to {dungeonlist::*}
    add "{@dungeon2}" to {dungeonlist::*}
    add "{@dungeon3}" to {dungeonlist::*}
    add "{@dungeon4}" to {dungeonlist::*}
    add "{@dungeon5}" to {dungeonlist::*}

on rightclick on black concrete:
    set {_dungeontp} to a random element out of {dungeonlist::*}
    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.
 
It works.
Code:
on load:
    loop 5 times:
        if {spawn.dungeon%loop-number%} is set:
            add {spawn.dungeon%loop-number%} to {dungeonlist::*}
on unload:
    delete {dungeonlist::*}

on rightclick on black concrete:
    set {_dungeontp} to a random element out of {dungeonlist::*}
    teleport player to {_dungeontp}
    stop

command /setdungeon [<int>] [<text>]:
    permission message: &cNo permissions.
    permission: rank.admin
    usage: /setdungeon <number>
    aliases: sd
    executable by: players
    trigger:
        if arg-1 is set:
            if arg-2 is not set:
                set {spawn.dungeon%arg-1%} to player's location
                send "&aSpawn for dungeon %arg-1% set!"
                stop
            else:
                stop
        else:
            send "&cUsage: /setdungeon <number>"
 
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.
 
  • Like
Reactions: Jerooski
It works.
Code:
on load:
    loop 5 times:
        if {spawn.dungeon%loop-number%} is set:
            add {spawn.dungeon%loop-number%} to {dungeonlist::*}
on unload:
    delete {dungeonlist::*}

on rightclick on black concrete:
    set {_dungeontp} to a random element out of {dungeonlist::*}
    teleport player to {_dungeontp}
    stop

command /setdungeon [<int>] [<text>]:
    permission message: &cNo permissions.
    permission: rank.admin
    usage: /setdungeon <number>
    aliases: sd
    executable by: players
    trigger:
        if arg-1 is set:
            if arg-2 is not set:
                set {spawn.dungeon%arg-1%} to player's location
                send "&aSpawn for dungeon %arg-1% set!"
                stop
            else:
                stop
        else:
            send "&cUsage: /setdungeon <number>"
Thank you! This is great!
 
Status
Not open for further replies.