Solved Sorting into teams

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

Tom1222322

Member
Feb 5, 2021
19
0
1
23
Hello, I've been trying to create a basic skyflag minigame skript, but I ran into a problem. I don't know how to sort player 1 to team a and player 2 to team b and again player 3 to team a, etc.
Code:
every 20 ticks:
    if size of {sf.players::*} > 1:
        if {sf.running} is false:
            set {sf.running} to true 
            if {sf.teamred::*} is 0:
                add player to {sf.teamred::*}
            if {sf.teamblue::*} is 0:
                add player to {sf.teamblue::*}
 
Code:
every 20 ticks:
    if {sf.running} is false:
        if size of {sf.players::*} > 1:
            set {sf.running} to true
            loop {sf.players::*}:
                if {_red} is true:
                    delete {_red}
                    add loop-value to {sf.teamred::*}
                else:
                    set {_red} to true
                    add loop-value to {sf.teamblue::*}


Code:
every 20 ticks:
    if {sf.running} is false:
        set {_size} to size of {sf.players::*}
        if {_size} > 1:
            set {sf.running} to true
            loop {_size} times:
                if mod(loop-value,2) is not 0:
                    add {sf.players::%loop-value%} to {sf.teamred::*}
                else:
                    add {sf.players::%loop-value%} to {sf.teamblue::*}
 
Last edited:
Code:
[00:02:27 INFO]: Line 78: (skyflag.sk)
[00:02:27 INFO]:     The function 'mod' requires at least 2 arguments, but only 1 is given.
[00:02:27 INFO]:     Line: if mod(loop-value/2) is not 0:
[00:02:27 INFO]:
[00:02:27 INFO]: Line 82: (skyflag.sk)
[00:02:27 INFO]:     'else' has to be placed just after another 'if' or 'else if' section
[00:02:27 INFO]:     Line: else:
Code:
every 20 ticks:
    if {sf.running} is false:
        if size of {sf.players::*} > 1:
            set {sf.running} to true
            loop {sf.players::*}:
                if {_red} is true:
                    delete {_red}
                    add loop-value to {sf.teamred::*}
                else:
                    set {_red} to true
                    add loop-value to {sf.teamblue::*}


Code:
every 20 ticks:
    if {sf.running} is false:
        set {_size} to size of {sf.players::*}
        if {_size} > 1:
            set {sf.running} to true
            loop {_size} times:
                if mod(loop-value/2) is not 0:
                    add {sf.players::%loop-value%} to {sf.teamred::*}
                else:
                    add {sf.players::%loop-value%} to {sf.teamblue::*}
I keep getting this error, no idea why tho.
 
Code:
[00:02:27 INFO]: Line 78: (skyflag.sk)
[00:02:27 INFO]:     The function 'mod' requires at least 2 arguments, but only 1 is given.
[00:02:27 INFO]:     Line: if mod(loop-value/2) is not 0:
[00:02:27 INFO]:
[00:02:27 INFO]: Line 82: (skyflag.sk)
[00:02:27 INFO]:     'else' has to be placed just after another 'if' or 'else if' section
[00:02:27 INFO]:     Line: else:

I keep getting this error, no idea why tho.
oh,
Code:
mod(loop-value,2)
my mistake
 
Status
Not open for further replies.