Solved {list1::*} or {list2::*} contains. How to correctly do it

  • 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.
like i said its not working on my version. at least it works if i do it with a single list variable. but when i use 2 of them and use AND or OR it wont work.
code_language.skript:
command /test1:
    trigger:
        add player to {test1::*}

command /test2:
    trigger:
        add player to {test2::*}

command /test3:
    trigger:
        if {test1::*} or {test2::*} contains player:
            broadcast "he is added"
 
pikachu said
code_language.skript:
if {test1::*} and {test2::*} contains player:
as pikachu said this works because for all intents and purposes its making 1 list out of the 2 so if either list has the value then it works
 
hm ya it doesnt i tested with
code_language.skript:
command /test:
    trigger:
        add "cool" to {test1::*}
        add "hey" to {test2::*}
        if {test1::*} and {test2::*} contains "cool":
            send "hi"
@Pikachu explain yourself
 
this works but it will have problems when a player has the name of another player in his name. like "OPgrindNoobXXXL" and "grindnoob"
code_language.skript:
if "%{test1::*}% %{test2::*}%" contains "%player%":
[doublepost=1525817806,1525817609][/doublepost]can do it with uuid's. but thats not recommended? its for a minigames server for in-game purpose. not stats or anything. the list variable will be deleted after the game is ended
 
i mean the function i posted in my second post or whatever will work if pikachu doesnt have a better idea
 
hm ya it doesnt i tested with
code_language.skript:
command /test:
    trigger:
        add "cool" to {test1::*}
        add "hey" to {test2::*}
        if {test1::*} and {test2::*} contains "cool":
            send "hi"
@Pikachu explain yourself
i guess the comparison is still broken on ExpressionLists
code_language.skript:
function contains(l: objects, v: object) :: boolean:
  loop {_l::*}:
    if loop-value is {_v}:
      return true
  return false

on script load:
  set {_123::*} to 1, 2 and 3
  set {_456::*} to 4, 5 and 6
  if contains(({_123::*} and {_456::*}), 4) is true:
    broadcast "contains dude"
works as expected
 
i guess the comparison is still broken on ExpressionLists
code_language.skript:
function contains(l: objects, v: object) :: boolean:
  loop {_l::*}:
    if loop-value is {_v}:
      return true
  return false

on script load:
  set {_123::*} to 1, 2 and 3
  set {_456::*} to 4, 5 and 6
  if contains(({_123::*} and {_456::*}), 4) is true:
    broadcast "contains dude"
works as expected
I will use this one. Thanks to both of you. appreciate the help. can you make this example so it will check if a player is added?
[doublepost=1525818082,1525817994][/doublepost]for the 2 list variables and not local ones.
 
I will use this one. Thanks to both of you. appreciate the help. can you make this example so it will check if a player is added?
[doublepost=1525818082,1525817994][/doublepost]for the 2 list variables and not local ones.
if contains(({test1::*} and {test2::*}), player) is true:
 
player? object? im confused. i dont think this part is correct
code_language.skript:
function contains(l: objects, v: object) :: boolean:
  loop {_l::*}:
    if loop-value is {_v}:
      return true
  return false
 
objects and object are just so the function is generic and you can put a list of any types and check if something of any type is in the list of any type when you call it, not just players. so you can input any list and any value, player or not
 
okay, i tried it but i keep getting this error
Schermafbeelding_2018_05_09_om_00_40_18.png
 
Status
Not open for further replies.