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 Shop Teleporting System

Discussion in 'Skript' started by NCSGeek, Jul 27, 2017.

Tags:
Thread Status:
Not open for further replies.
  1. NCSGeek

    NCSGeek Member

    Joined:
    Jul 22, 2017
    Messages:
    19
    Likes Received:
    3
    Skript Version: 2.2-dev22g
    Skript Author: Me (Skript Version Author is bensku)
    Minecraft Version: 1.11.2
    ---
    Full Code:

    Code (Skript):
    1.  
    2. command /shops <string> [<string>]:
    3.     usage: &7/shops <&blist&7/&etp&7/&3create&7/&6remove&7> [&bNull&7/&eShop&7/&3ShopName&7/&6ShopName&7]
    4.     trigger:
    5.         if arg-1 is "list":
    6.             send "&9Shops:"
    7.             send "&7%{shop-name-cache::*}%"
    8.         else if arg-1 is "create":
    9.             if player's money is greater than 100:
    10.                 remove 100 from the player's account
    11.                 set {shop-loc-cache::%arg-2%} to the player's location
    12.                 add arg-2 to {shop-name-cache::*}
    13.                 add arg-2 to {shops.owned.%player%::*}
    14.             else:
    15.                 send "You do not have sufficient funds to create a shop!"
    16.         else if arg-1 is "remove" or "delete":
    17.             if {shops.owned.%player%::*} contains arg-2:
    18.                 add 30 to the player's balance
    19.                 remove arg-2 from {shop-name-cache::*}
    20.                 remove arg-2 from {shops.owned.%player%::*}
    21.                 delete {shop-loc-cache::%arg-2%}
    22.                 send "Shop '%arg-2%' deleted"
    23.             else:
    24.                 send "You do not own that shop!"
    25.         else if arg-1 is "tp" or "teleport":
    26.             if {shop-name-cache::*} contains arg-2:
    27.                 teleport player to {shop-loc-cache::%arg-2%}
    28.                 send "Welcome"
    29.             #else:
    30.                 #send "&4Unknown Shop"
    31.  
    32.  
    Errors on Reload: none

    Console Errors: none


    Addons using:
    Umbaska
    SkRayfall

    Troubleshooting:

    Have you tried searching the docs? Yes
    Have you tried searching the forums? No


    ----

    Hello! It's been a long time since I've been on these forums. I used to have an existing account but it must have gotten deleted. Anyway, I am trying to make a skript that lets players purchase a warp to their shops. My issue with my already mostly working skript is; when I create a new shop with my command it does not allow me to teleport to it. It does show up in the list of shops though.

    I am willing to do a rewrite of the skript, as I am not fluent in skripting and I am sure that there is a better way this could have been written. Thank you for anyone who is willing to lend a hand. Also I tried to follow all guidelines on forum posting, if I missed anything, let me know.
     
  2. Best Answer:
    Post #2 by ShaneBee, Jul 27, 2017
  3. ShaneBee

    Supporter + Addon Developer

    Joined:
    Sep 7, 2017
    Messages:
    2,184
    Likes Received:
    227
    i think its because checking if a list contains something is buggy (line 26)
    do this instead:
    Code (Skript):
    1. loop {shop-name-cache::*}:
    2.     if loop-value is arg-2:
    3.         #tp player
    4.         stop
    5. #unknown shop
     
    • Useful Useful x 1
  4. ShaneBee

    Supporter + Addon Developer

    Joined:
    Sep 7, 2017
    Messages:
    2,184
    Likes Received:
    227
    Yeah I've always had problems with lists in Skript. So use your code there instead of checking the list as I did?
     
  5. ShaneBee

    Supporter + Addon Developer

    Joined:
    Sep 7, 2017
    Messages:
    2,184
    Likes Received:
    227
    yep that should fix it
     
  6. ShaneBee

    Supporter + Addon Developer

    Joined:
    Sep 7, 2017
    Messages:
    2,184
    Likes Received:
    227
    I came to relize, The name list works fine. I cant teleport to it is the issue, so the location cache list has the problem, not the name cache
     
  7. ShaneBee

    Supporter + Addon Developer

    Joined:
    Sep 7, 2017
    Messages:
    2,184
    Likes Received:
    227
    oh ok. broadcast {shop-loc-cache::%arg-2%} or {shop-loc-cache::*} and see what it says
     
  8. ShaneBee

    Supporter + Addon Developer

    Joined:
    Sep 7, 2017
    Messages:
    2,184
    Likes Received:
    227
    Alright.

    It returns x: -212.84, y: 46.06, z: -377.14, x: 216.24, y: 79, z: 156.47 and x: -212.84, y: 46.06, z: -377.14

    One of the locations, I already had, which works for whatever reason. That is why there are multiple.
     
  9. ShaneBee

    Supporter + Addon Developer

    Joined:
    Sep 7, 2017
    Messages:
    2,184
    Likes Received:
    227
    so its sending "Welcome" but not teleporting them?
     
  10. ShaneBee

    Supporter + Addon Developer

    Joined:
    Sep 7, 2017
    Messages:
    2,184
    Likes Received:
    227
    No, it says unknown shop, from the last else statement. (Its commented out because I was testing, but it isnt when the error happens.)
     
  11. ShaneBee

    Supporter + Addon Developer

    Joined:
    Sep 7, 2017
    Messages:
    2,184
    Likes Received:
    227
    So the issue is with the list contain check.... using what i said above ^ doesnt fix it?
     
  12. ShaneBee

    Supporter + Addon Developer

    Joined:
    Sep 7, 2017
    Messages:
    2,184
    Likes Received:
    227
    Your loop interacts with the {shop-name-cache::*}: list, that list only handles the names of the shop, so it only handles what is seen when you use the command to list all shops.

    I have two lists, one for names, one for locations. So since you didnt interact with the location list, I dont think that loop fixes it?
     
  13. ShaneBee

    Supporter + Addon Developer

    Joined:
    Sep 7, 2017
    Messages:
    2,184
    Likes Received:
    227
    i dont think the problem is with the loc list. you said that it says unknown shop which would mean that its not detecting that {shop-name-cache::*} contains arg-2 which as i said before, is known to be buggy.
     
  14. ShaneBee

    Supporter + Addon Developer

    Joined:
    Sep 7, 2017
    Messages:
    2,184
    Likes Received:
    227
    Ok, i will try your loop,

    So you want it here
    ```
    1. else if arg-1 is "tp" or "teleport":
    2. if {shop-name-cache::*} contains arg-2:
    3. teleport player to {shop-loc-cache::%arg-2%}
    4. send "Welcome"
    5. #else:
    6. #send "&4Unknown Shop"
    ```
    in place of the if statement?
     
  15. ShaneBee

    Supporter + Addon Developer

    Joined:
    Sep 7, 2017
    Messages:
    2,184
    Likes Received:
    227
  16. ShaneBee

    Supporter + Addon Developer

    Joined:
    Sep 7, 2017
    Messages:
    2,184
    Likes Received:
    227
    Alright, I thought so, but I wanted to make sure. I will try it now.
    --- Double Post Merged, Jul 27, 2017, Original Post Date: Jul 27, 2017 ---
    Thank you! I really apreciate your help. Kudos to you! :emoji_smile:
     
Thread Status:
Not open for further replies.

Share This Page

Loading...