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.

Homes GUI teleport

Discussion in 'Skript' started by Mattllama987, Jun 18, 2020.

  1. Mattllama987

    Mattllama987 Well-Known Member

    Joined:
    Aug 5, 2018
    Messages:
    199
    Likes Received:
    2
    Hello, im working on a homes GUI, and im having a little trouble with the teleporting part. Im use to using Tuske, and i updated my server, and it no longer works. So, im remaking it in vanilla skript now. How can i get the name of the slot the player picks, and then teleport them to that home? Here is the whole code. If anyone knows how to get this to work, please let me know ASAP.

    Thanks!
    ~Matt


    Code (Text):
    1. on first join:
    2.     set {maxhomes::%player%} to 0
    3. command /sethome [<text>]:
    4.     trigger:
    5.         if arg-1 isn't set:
    6.             send "&7[&aHomes&7] &7You must have a home name!"
    7.         else:
    8.             if {HOME::%player%::*} contains arg-1:
    9.                 send "&7[&aHomes&7] &7You already have a home named that!"
    10.             set {LOC::HOME::%player%::%arg 1%} to player's location
    11.             add arg-1 to {HOME::%player%::*}
    12.             set {HCOL::%player%::%arg 1%} to "&c&l"
    13.             send "&7[&aHomes&7] &7You set a home named %arg-1%&7!"
    14. command /delhome [<offlineplayer>]:
    15.     trigger:
    16.         if player has permission "%{SKHOME::DB::PERM::DELH}%":
    17.             if arg-1 is set:
    18.                 delete {HOME::%arg-1%::*}
    19.                 send "&7[&aHomes&7] &7You deleted all of %arg-1%&7's homes!"
    20. command /homes:
    21.     trigger:
    22.         open chest inventory with 6 rows named "&c&lHomes(s)" to player
    23.         set {_o} to 0
    24.         loop 55 times:
    25.             set slot {_o} of player's current inventory to gray glass pane named ""
    26.             add 1 to {_o}
    27.         if size of {HOME::%player%::*} is bigger than 0:
    28.             set {_home} to 0
    29.             loop {HOME::%player%::*}:
    30.                 set {_ahome} to loop-value
    31.                 set slot {_home} of player's current inventory to chest named "%{HCOL::%player%::%{_ahome}%}%%{_ahome}%"
    32.                 add 1 to {_home}
    33. on inventory click:
    34.     if "%event.getView().getTitle()%" = "&c&lHomes(s)":
    35.         cancel event
    36.         set {_var} to 0
    37.         loop 66 times:
    38.             add 1 to {_var}
    39.             set {_name} to loop-value
    40.             teleport player to {LOC::HOME::%player%::%{_name}%}
     
  2. Goose

    Goose Well-Known Member

    Joined:
    Nov 23, 2019
    Messages:
    400
    Likes Received:
    28
    You can get the name of the slot the player clicked by using "event-item's name"
     
  3. Nikd0

    Nikd0 Well-Known Member

    Joined:
    May 30, 2020
    Messages:
    81
    Likes Received:
    7
    Also I would NOT recommend you using "on first join" event, there may be problems with it. I would rather do something like this:
    Code (Text):
    1. variables:
    2.     {maxhomes::%player%} = 0
    or
    Code (Text):
    1. on join:
    2.     if {maxhomes::%player%} is not set:
    3.         set {maxhomes::%player%} to 0
     
  4. Mattllama987

    Mattllama987 Well-Known Member

    Joined:
    Aug 5, 2018
    Messages:
    199
    Likes Received:
    2
    Thank you both for responding to me! But how would i actually do the teleporting part? I tried this, and it might be wrong because its not working xD


    Code (Text):
    1. on inventory click:
    2.     if "%event.getView().getTitle()%" = "&c&lHomes(s)":
    3.         cancel event
    4.         teleport player to {LOC::HOME::%player%::%event-item's name%}
    --- Double Post Merged, Jun 21, 2020, Original Post Date: Jun 19, 2020 ---
    bump
     
  5. Nikd0

    Nikd0 Well-Known Member

    Joined:
    May 30, 2020
    Messages:
    81
    Likes Received:
    7
    Have you tried debugging?
    Have you tried upgrading/downgrading your Skript?
    Have you tried upgrading all of your addons?
     
  6. Mattllama987

    Mattllama987 Well-Known Member

    Joined:
    Aug 5, 2018
    Messages:
    199
    Likes Received:
    2
    Ive tried all of them. I debugged, and all the debug messages go through, its just not teleporting the player
     
  7. Nikd0

    Nikd0 Well-Known Member

    Joined:
    May 30, 2020
    Messages:
    81
    Likes Received:
    7
    I think it's because you are naming the item like this: "&c&lHOME".
    Because of that, it searches for "{LOC::HOME::%player%::&c&lHOME}" which does not exist, instead of "{LOC::HOME::%player%::HOME}"

    I think the easiest way is to remove the color code (= {HCOL::%player%::%arg 1%}) but if you want to keep it, use spliting:
    Code (Text):
    1. set {_name} to "%event-item's name%"
    2. set {_nameparts::*} to {_name} split at "&l"
    3. teleport player to {LOC::HOME::%player%::%{_nameparts::2}%}
     
  8. Mattllama987

    Mattllama987 Well-Known Member

    Joined:
    Aug 5, 2018
    Messages:
    199
    Likes Received:
    2
    I tried that, and its doing nothing when i click the slot xD I also tried something similar
     
  9. Nikd0

    Nikd0 Well-Known Member

    Joined:
    May 30, 2020
    Messages:
    81
    Likes Received:
    7
    Have you tried just removing the color code from the "set slot ..." in the /homes command?
    Try putting something like " broadcast "%{LOC::HOME::%thenamevariable%}%" ".
    Doesn't that display <none>?

    I would like to help you, but if you response like "I did something similar", I dunno what you did, what happened etc... :emoji_confused::emoji_wink:
     
  10. Mattllama987

    Mattllama987 Well-Known Member

    Joined:
    Aug 5, 2018
    Messages:
    199
    Likes Received:
    2
    I tried to set a var to the name of the event-slot, and then teleport to that var lol. But i tried what you said, and it broadcast <none>
     
  11. memes

    memes Member

    Joined:
    Jun 24, 2018
    Messages:
    23
    Likes Received:
    2
    Just do
    Code (Text):
    1. %uncolored name of event-item%
    or something of the sort
     
    • Informative Informative x 1
  12. Mattllama987

    Mattllama987 Well-Known Member

    Joined:
    Aug 5, 2018
    Messages:
    199
    Likes Received:
    2
    Its still coming back with <none>. I have this here:

    Code (Text):
    1. on inventory click:
    2.     if "%event.getView().getTitle()%" = "&c&lHomes(s)":
    3.         cancel event
    4.         teleport player to {LOC::HOME::%player%::%uncolored name of event-item%}
    5.         broadcast "%{LOC::HOME::%player%::%uncolored name of event-item%}%"
     
  13. memes

    memes Member

    Joined:
    Jun 24, 2018
    Messages:
    23
    Likes Received:
    2
    Try a basic command to set the var, and see. If you set the var and then it broadcasts fine when you click on the slot, it fails when you save the location.
    Code (Text):
    1.  
    2. command /test [<text>]:
    3.     trigger:
    4.         set {LOC::HOME::%player%::%arg%} to arg
    5.  
    Edit: or your variables file is corrupted. it happens to me sometimes.
     
  14. Mattllama987

    Mattllama987 Well-Known Member

    Joined:
    Aug 5, 2018
    Messages:
    199
    Likes Received:
    2
    Here is what i found out. When i have this, it broadcast the correct message. It doesnt send <none>, it sends "test". Test is just the name of my home. It only sends the message if it doesnt have "%uncolored name of event-item%". If it has that, it sends <none>. But what i have now sends "test" in chat. But its the colors &c&ltest. It also still doesnt teleport the player. xD

    Code (Text):
    1. on inventory click:
    2.     if "%event.getView().getTitle()%" = "&c&lHomes(s)":
    3.         cancel event
    4.         set {_var} to name of event-slot
    5.         teleport player to {HOME::%player%::%name of event-item%}
    6.         broadcast "%{_var}%"
     
  15. memes

    memes Member

    Joined:
    Jun 24, 2018
    Messages:
    23
    Likes Received:
    2
    Why do you need to color it? It seems that you're always making it the same color so just do it later on.
     
  16. oHeckGage

    oHeckGage Well-Known Member

    Joined:
    Mar 24, 2020
    Messages:
    61
    Likes Received:
    1
    You guys are stupid xD It's because you need to do
    Code (Text):
    1.  teleport player to location at
    not
    Code (Text):
    1.  teleport player to


    Edit 2 seconds later: Lol sorry about saying "stupid" :emoji_grinning: Just saying because you needed 15 comments to solve it
     
  17. Nikd0

    Nikd0 Well-Known Member

    Joined:
    May 30, 2020
    Messages:
    81
    Likes Received:
    7
    No stupidity's going on: https://docs.skunity.com/syntax/search/id:3897
     
  18. Mattllama987

    Mattllama987 Well-Known Member

    Joined:
    Aug 5, 2018
    Messages:
    199
    Likes Received:
    2
    Not working. :/

    Code (Text):
    1. on inventory click:
    2.     if "%event.getView().getTitle()%" = "&c&lHomes(s)":
    3.         cancel event
    4.         set {_var} to name of event-slot
    5.         teleport player to location at {LOC::HOME::%player%::%uncolored name of event-item%}
    6.         broadcast "%{_var}%"
     
  19. Juffix

    Juffix Member

    Joined:
    Apr 7, 2019
    Messages:
    18
    Likes Received:
    3
    Code (Text):
    1. teleport player to
    Should work, check if the location is set
     
  20. Mattllama987

    Mattllama987 Well-Known Member

    Joined:
    Aug 5, 2018
    Messages:
    199
    Likes Received:
    2
    Ive tried that, and it doesnt work. I made a command to teleport the player, and it does work. So it has to do with something with the GUI part. Im not sure about that?


    Code (Text):
    1. command /test <text>:
    2.     trigger:
    3.         teleport player to {LOC::HOME::%player%::%arg-1%}
     
Loading...