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.

List Variables -- Not working

Discussion in 'Skript' started by SoMuchWessel, May 24, 2017.

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

    SoMuchWessel Active Member

    Joined:
    Apr 3, 2017
    Messages:
    140
    Likes Received:
    2
    Hey guys, i did some testing, and i came up with this:
    Code (Skript):
    1. on rightclick on sign:
    2.     line 2 of the clicked block is "test":
    3.         line 3 of the clicked block is "1":
    4.             add player to {team::blue::*} #blue
    5.             execute console command "warp test1 %player%"
    6.        
    7. on rightclick on sign:
    8.     line 2 of the clicked block is "test":
    9.         line 3 of the clicked block is "2":
    10.             add player to {team::red::*} #red
    11.             execute console command "warp test2 %player%"
    12.            
    13.            
    14. command /tleave:
    15.     trigger:
    16.         if player is in {team::red::*}:
    17.             message "&4Red"
    18.             remove player from {team::red::*}
    19.        
    20.         else if player is in {team::blue::*}:
    21.             message "&1Blue"
    22.             remove player from {team::blue::*}
    23.        
    24.         else:
    25.             message "&cYou are not in a team!"
    It doesnt give me errors or something, but if i do /tleave, it says that im not in a team, but i joined via the sign method.

    Can someone make this work?
     
  2. ShaneBee

    Moderator Resource Staff Supporter + Addon Developer

    Joined:
    Sep 7, 2017
    Messages:
    2,173
    Likes Received:
    199
    do

    Code (Skript):
    1. if  "%player%" contains "%{team::red::*}%":
    2.  
    3.  
    4. #or use the functions list.
    5.  
    6.  
     
  3. ShaneBee

    Moderator Resource Staff Supporter + Addon Developer

    Joined:
    Sep 7, 2017
    Messages:
    2,173
    Likes Received:
    199

    Now if i join red, it works, but if i join blue then it is saying that im not in a team

    Code (Skript):
    1.  
    2. on rightclick on sign:
    3.     line 2 of the clicked block is "test":
    4.         line 3 of the clicked block is "1":
    5.             add player to {team::blue::*} #blue
    6.             execute console command "warp test1 %player%"
    7.      
    8. on rightclick on sign:
    9.     line 2 of the clicked block is "test":
    10.         line 3 of the clicked block is "2":
    11.             add player to {team::red::*} #red
    12.             execute console command "warp test2 %player%"
    13.          
    14.          
    15. command /tleave:
    16.     trigger:
    17.         if "%player%" contains "%{team::red::*}%":
    18.             message "&4Red"
    19.             remove player from {team::red::*}
    20.      
    21.         else if "%player%" contains "%{team::blue::*}%":
    22.             message "&1Blue"
    23.             remove player from {team::blue::*}
    24.      
    25.         else:
    26.             message "&cYou are not in a team!"
    27. !"
     
  4. ShaneBee

    Moderator Resource Staff Supporter + Addon Developer

    Joined:
    Sep 7, 2017
    Messages:
    2,173
    Likes Received:
    199
    The issue is contains on lists is unreliable. Use this:
    Code (Skript):
    1. function contains(l: objects, v: object) :: boolean:
    2.   loop {_l::*}:
    3.     if loop-value is {_v}:
    4.       return true
    5.   return false
     
    • Useful Useful x 1
  5. ShaneBee

    Moderator Resource Staff Supporter + Addon Developer

    Joined:
    Sep 7, 2017
    Messages:
    2,173
    Likes Received:
    199
    Im kinda new to Skript, so i dont really understand they way you wrote it now, can you make an example of it using my code?
     
  6. ShaneBee

    Moderator Resource Staff Supporter + Addon Developer

    Joined:
    Sep 7, 2017
    Messages:
    2,173
    Likes Received:
    199
    That wouldn't be an example then. Theres a functions tutorial in the tutorials section of this forum.
     
  7. ShaneBee

    Moderator Resource Staff Supporter + Addon Developer

    Joined:
    Sep 7, 2017
    Messages:
    2,173
    Likes Received:
    199
    I dont really follow that tutorial, as i said before, im pretty new at Skript coding
     
  8. ShaneBee

    Moderator Resource Staff Supporter + Addon Developer

    Joined:
    Sep 7, 2017
    Messages:
    2,173
    Likes Received:
    199
    use Pikachu Function and then this way:

    Code (Skript):
    1. if contains({Team::Red::*}, player) is true:
    2.     send "&2Red"
    3. else if contains({Team::Blue::*}, player) is true:
    4.     send "&bBlue"
    5. else:
    6.     send "Youre not in a team."
    7.  
    8. #Maybe you need add quotes in function ("%{Team::red::*}%", %player%)
     
Thread Status:
Not open for further replies.
Loading...