variables not working properly

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

SoMuchWessel

Active Member
Apr 3, 2017
147
3
18
47
Hey guys,
I got a team arena like system with this code for each team:

Blue:
code_language.skript:
on rightclick on sign:
    line 2 of the clicked block is "Sandbox":
        line 3 of the clicked block is "&1Blue":
            if {sandbox.game.started} = 0: #notstarted
                set {%player%.game} to 1 #sandbox
                add player to {sandbox::team::blue::*} #blue
                add 1 to {sandbox.players}
                execute console command "warp test1 %player%"
                send "&1%player% &bjoined the game!" to {sandbox::team::blue::*} and {sandbox::team::red::*}
            else:
                message "&bGame has already started!"

Red:

code_language.skript:
on rightclick on sign:
    line 2 of the clicked block is "Sandbox":
        line 3 of the clicked block is "&4Red":
            if {sandbox.game.started} = 0:
                set {%player%.game} to 1 #sandbox
                add player to {sandbox::team::red::*} #red
                add 1 to {sandbox.players}
                execute console command "warp test2 %player%"
                send "&4%player% &bjoined the game!" to {sandbox::team::blue::*} and {sandbox::team::red::*}
            else:
                message "&bGame has already started!"

Well then i got this Ready system:

code_language.skript:
on rightclick on sign:
    line 2 of the clicked block is "Sandbox":
        line 3 of the clicked block is "&a&lReady":
            if {sandbox.game.started} = 0: #not started
                if {sandbox.countdown} is false:
                    if "%player%" contains "%{sandbox::team::blue::*}%":
                        if {%player%.ready} = 0:
                            send "&1%player% &bis ready!" to {sandbox::team::blue::*} and {sandbox::team::red::*}
                            add 1 to {sandbox.ready}
                            set {%player%.ready} to 1
                        else:
                            message "&bYou are already ready!"
                        loop 1 times:
                            if {sandbox.players} > 1:
                                if {sandbox.ready} - {sandbox.players} = 0:
                                    execute console command "startsandbox"
                                exit loop
                            else:
                                message "&bYou are alone in the arena!"
                                exit loop
                    
                    else if "%player%" contains "%{sandbox::team::red::*}%":
                        if {%player%.ready} = 0:
                            send "&4%player% &bis ready!" to {sandbox::team::blue::*} and {sandbox::team::red::*}
                            add 1 to {sandbox.ready}
                            set {%player%.ready} to 1
                        else:
                            message "&bYou are already ready!"
                        loop 1 times:
                            if {sandbox.players} > 1:
                                if {sandbox.ready} - {sandbox.players} = 0:
                                    execute console command "startsandbox"
                                exit loop
                            else:
                                message "&bYou are alone in the arena!"
                                exit loop
                else:
                    message "&bThe countdown is already started!"

Which works, but the thing is: it only works with one player on each side.
If there are 2 people on the blue team, nothing happens when i click on that ready sign.
Also everything which uses if "%player%" contains "%{sandbox::team::red::*}%":
is not working with 2 people on one side. Is there a way to fix this?
 
code_language.skript:
if "%player%" contains "%{sandbox::team::blue::*}%":

the "contains" syntax doesn't work properly with lists. This issue is already known.

code_language.skript:
loop {sandbox::team::blue::*}:
    loop-value is player:
        set {_contains} to true
{_contains} is true:
    # do stuff
 
The reason the contains doesn't work, is because you have two instances of the same player in the list or similar names. This is when the contains condition doesn't work.

Lets say I have "Lime" and "LimeGlass" in the list.

If I test for "Lime" and "Lime" isn't in the list but "LimeGlass" is. The list will still trigger.
 
Status
Not open for further replies.