choose 2 persons for 2 variables! [Difficult Question]

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

    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.

iStopcontact

Member
Feb 18, 2017
115
2
18
Hello guys,

I am wroking on a own murder gamemode for my server network

Now I have made a code that the skript randomly chose one person as murder and one person as gunner.

But no my question is...
How can i skript that the murder can't be chosen als gunner so a player can only has one role.

This is my code for when the game starts:
code_language.skript:
            set {murder:murder} to random element out of {murderlist::*}
            set {murder:murder:%{murder:murder}%} to true
            remove {murder:murder} from {murder::innocent::*}
            set {murder:gunner} to random element out of {murderlist::*}
            set {murder:gunner:%{murder:gunner}%} to true
            remove {murder:gunner} from {murder::innocent::*}
            send "{@MD} &7You are the &4&lMurder" to {murder:murder}
            send "{@MD} &7You are the &6&lGunner" to {murder:gunner}
            send "{@MD} &7You are an &3Innocent" to {murder::innocent::*}

EXTRA: {murder::innocent::*} is the variable a player getsa added in when he joines the game
 
Your script is a bit confusing out of context, but I think I have a solution for you:

code_language.skript:
            set {murder:murder} to random element out of {murderlist::*}
            remove {murder:murder} from {murderlist::*} #added code
            set {murder:murder:%{murder:murder}%} to true
            remove {murder:murder} from {murder::innocent::*}
            set {murder:gunner} to random element out of {murderlist::*}
            set {murder:gunner:%{murder:gunner}%} to true
            remove {murder:gunner} from {murder::innocent::*}
            add {murder:murder} to {murderlist::*} #added code
            send "{@MD} &7You are the &4&lMurder" to {murder:murder}
            send "{@MD} &7You are the &6&lGunner" to {murder:gunner}
            send "{@MD} &7You are an &3Innocent" to {murder::innocent::*}

What I did was temporarily remove the player chosen as {murder:murder} from {murderlist::*} so that they will not be chosen when getting a random element out that list the second time. The murder player is then readded to {murderlist::*} since I assume you want them to remain on it.
 
Status
Not open for further replies.