Help regarding list variables

  • 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!

code_language.skript:
If {variable} contains player:
#Do stuff
Well, that wouldn't work such as it's a single variable and not a list variable (although the OP might get the idea), also, the contains acts weird the most part of the time and that's why I do it like this:
code_language.skript:
set {yourVar::%player's uuid%} to player's name #I use the player's uuid just because it's a good practice, you can use whatever you want.
and then when I want to check it:
code_language.skript:
if {yourVar::%player's uuid%} is set:
#do stuff
or other way is do this:
code_language.skript:
loop {yourVar::*}:
      if loop-value = player:
            set {_check} to true
{_check} is set
#do stuff
but that is going to be annoying with the time so that's why I would use this function:
code_language.skript:
function listContains(check: object, list: objects) :: boolean:
      loop {_list::*}:
            if loop-value = {_check}:
                 return true
      return false
and then do:
code_language.skript:
if listContains(player, {yourVar::*}): #if you have skQuery this will work, if not you'll have to put "is true" after the function.
      #do stuff