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 our 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 How to teleport to a location defined in a yaml file?

Discussion in 'Skript' started by SamDFL, Mar 2, 2018.

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

    SamDFL Member

    Joined:
    Mar 2, 2018
    Messages:
    7
    Likes Received:
    0
    Skript Version: Skript (Latest Version)
    Skript Author: SamDFL
    Minecraft Version: 1.8.9

    I've been trying to find a fix for this for ages, but I can't find it. Basically, I'm trying to teleport a player to a random location when they type /sw-join <arena>, which has been defined in a yaml file (see below for code). But it simply doesn't work for some reason, nothing happens. Any help would be much appreciated! Oh and also, I'm using WildSkript for yaml and not SkUtilites, I wont be switching, so please don't tell me to go to SkUtilites unless necessary.

    ---

    Yaml Code:
    Code (Skript):
    1. arenas:
    2.   arena:
    3.     spawn:
    4.       '1': 'x: -697.39, y: 64, z: 807.93''
    5.       '2': 'x: -698.39, y: 64, z: 808.93'

    Full Code:
    Code (Skript):
    1.  
    2. variables:
    3.     {ingame} = false
    4.    
    5. options:  
    6.     Prefix: &3[&bCometCraft&3]&f
    7.     Perm: skywars.staff
    8.     Config: plugins/SkyWars/skywars.yml
    9.    
    10. on skript load:
    11.     if file "{@Config}" doesn't exists:
    12.         create file "{@Config}"
    13.         set "" to "arenas" in yaml file "{@Config}"
    14.    
    15. command /skywars-create [<text>]:
    16.     aliases: /sw-create
    17.     usage: /skywars-create <arena name>
    18.     permission: {@Perm}
    19.     trigger:
    20.         if arg 1 isn't set:
    21.             message "{@Prefix} &cTo create an arena, select the arena with a worldedit wand and type &a&l/sw-create <map-name>&c!"
    22.         if arg 1 is set:
    23.             set "arenas" to "%arg 1%" in yaml file "{@Config}"
    24.             execute console command "/rg define %arg 1%"
    25.             execute console command "/rg flag %arg 1% passthrough allow"
    26.             execute console command "/rg flag %arg 1% mob-spawning deny"
    27.             execute console command "/rg flag %arg 1% pvp allow"
    28.             message "{@Prefix} &aSkywars match &c%arg 1% &acreated! Now, use &c/skywars-setspawn <arena> <spawn-number>&a to set the spawn islands of the map!"
    29.             stop trigger
    30.  
    31. command /skywars-setspawn <text> <int>:
    32.     aliases: /sw-setspawn
    33.     usage: /skywars-setspawn <arena name> <spawn number>
    34.     permission: {@Perm}
    35.     trigger:
    36.         set {_arena.%arg 1%} to single value "arenas.%arg 1%" get of "{@Config}"
    37.         set "arenas.%arg 1%.spawn.%arg 2%" to "%player's location%" in yaml file "{@Config}"
    38.         wait 1 tick
    39.         set {_spawn.%arg 1%.%arg 2%} to single value "arenas.%arg 1%.spawn.%arg 2%" get of "{@Config}"
    40.         wait 1 tick
    41.         message "{@Prefix} &aSkywars match &c%arg 1%&a's spawn number &c%arg 2% &ahas been set at &c%{_spawn.%arg 1%.%arg 2%}%!"
    42.         stop trigger
    43.  
    44. command /skywars-join <text>:
    45.     aliases: /sw-join
    46.     usage: /skywars-join <arena name>
    47.     permission: {@Perm}
    48.     trigger:
    49.         set {_spawns::*} to value list "arenas.%arg 1%.spawn" get of "{@Config}"
    50.         set {spawn-area} to random location out of {_spawns::*}
    51.         teleport player to {spawn-area}
    52.         stop trigger

    Errors on Reload:
    None

    Console Errors: None

    Addons using (including versions):
    Umbaska 2.0, WildSkript

    Troubleshooting:

    Have you tried searching the docs? Yes
    Have you tried searching the forums? Yes
    What other methods have you tried to fix it? I've tried many other methods on the skripting side of things, for example, I tried change the
    Code (Skript):
    1. set {spawn-area} to random location out of {_spawns::*}
    to
    Code (Skript):
    1. set {spawn-area} to random text out of {_spawns::*}
     
  2. Best Answer:
    Post #2 by TPGamesNL, Mar 2, 2018
  3. TPGamesNL

    TPGamesNL Well-Known Member

    Joined:
    Jan 20, 2018
    Messages:
    1,311
    Likes Received:
    73
    Medals:
    I think the problem is that it isn't parsed as a location when it's in the YAML file, so I think you have to do something like this in the YAML file:
    Code (Skript):
    1. arenas:
    2.   arena:
    3.     spawn:
    4.       1:
    5.         x: -697.39
    6.         y: 64
    7.         z: 807.93
    8.       2:
    9.         x: -698.39
    10.         y: 64
    11.         z: 808.93
    and I don't know much about YAML in Skript, but get the x, y and z coordinate in temporary variable, then use
    Code (Skript):
    1. set {_loc} to location({_x} parsed as a int, {_y} parsed as a int, {_z} parsed as a int, world "%arg-1%")
     
  4. SamDFL

    SamDFL Member

    Joined:
    Mar 2, 2018
    Messages:
    7
    Likes Received:
    0
    Thanks dude! After some further tinkering, I've got it to work, thanks for the help! :emoji_slight_smile:
     
    • Friendly Friendly x 1
  5. TPGamesNL

    TPGamesNL Well-Known Member

    Joined:
    Jan 20, 2018
    Messages:
    1,311
    Likes Received:
    73
    Medals:
    No problem! :emoji_slight_smile:
     
    #4 TPGamesNL, Mar 2, 2018
    Last edited: Mar 3, 2018
    • Friendly Friendly x 2
Thread Status:
Not open for further replies.
Loading...