Solved Getting roles

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

Aralwen

Active Member
May 26, 2017
164
14
18
25
Hello everyone ! I am looking to make a selection of random roles. I have a problem : That is the role does not get deleted once it is distributed to a player. So, another player can get the same role.
I'm trying to do that once the role is obtained by one player, a other player can't not get it

Code:

code_language.skript:
function BroadcastRoles(p: player):
    add "Knight" to {_roles::*}
    add "Villager" to {_roles::*}
    add "Shepherdess" to {_roles::*}
    while {searching_roles.%{_p}%} is true:
        set {_r} to random object out of {_roles::*}
        set {Game.Role::%{_p}%} to {_r}
        remove {_r} from {_roles::*} #It does not work
        send {_p} title "" with subtitle "&7&oYou got your role..." for 5 seconds
        skellett play skellett sound "LEVEL_UP " to {_p} with volume 1.5 and pitch 3
          
          
        send "&e&lYou are : %{Game.Role::%{_p}%}%" to {_p}
        set {searching_roles.%{_p}%} to false 
          
command /rolesdefine:
    trigger:
        loop all players:
            set {searching_roles.%loop-player%} to true
            BroadcastRoles(loop-player)

Thank's ! :emoji_blush:
 
Last edited:
because you're removing from a non existant list variable "{_rolespossible::*}"

code_language.skript:
function BroadcastRoles(p: player):
    add "Knight", "Villager" and "Sheperdess" to {_roles::*}
    set {_r} to random object out of {_roles::*}
    set {Game.Role::%{_p}%} to {_r}
    remove {_r} from {_roles::*}

    send {_p} title "" with subtitle "&7&oYou got your role..." for 5 seconds
    skellett play skellett sound "LEVEL_UP " to {_p} with volume 1.5 and pitch 3
    send "&e&lYou are : %{Game.Role::%{_p}%}%" to {_p}
          
command /rolesdefine:
    trigger:
        loop all players:
            BroadcastRoles(loop-player)
 
because you're removing from a non existant list variable "{_rolespossible::*}"

code_language.skript:
function BroadcastRoles(p: player):
    add "Knight", "Villager" and "Sheperdess" to {_roles::*}
    set {_r} to random object out of {_roles::*}
    set {Game.Role::%{_p}%} to {_r}
    remove {_r} from {_roles::*}

    send {_p} title "" with subtitle "&7&oYou got your role..." for 5 seconds
    skellett play skellett sound "LEVEL_UP " to {_p} with volume 1.5 and pitch 3
    send "&e&lYou are : %{Game.Role::%{_p}%}%" to {_p}
       
command /rolesdefine:
    trigger:
        loop all players:
            BroadcastRoles(loop-player)
Hello, first of all thank you for your help! I just tried and it does not work, I have two accounts connected and my account 2 can get the villager role even if my account 1 already has .

(actually it was not good values on my code, it's fixed, but still does not work) :emoji_frowning:
 
Last edited:
youre re-adding all the roles to the list variable every time you call the function for each player
 
Can you give me an example, please?
code_language.skript:
function BroadcastRoles():
    add "Knight", "Villager" and "Sheperdess" to {_roles::*}
    loop all players:
        set {_p} to loop-player
        set {_r} to random object out of {_roles::*}
        set {Game.Role::%{_p}%} to {_r}
        remove {_r} from {_roles::*}
   
        send {_p} title "" with subtitle "&7&oYou got your role..." for 5 seconds
        skellett play skellett sound "LEVEL_UP " to {_p} with volume 1.5 and pitch 3
        send "&e&lYou are : %{Game.Role::%{_p}%}%" to {_p}
       
command /rolesdefine:
    trigger:
        BroadcastRoles()
 
code_language.skript:
function BroadcastRoles():
    add "Knight", "Villager" and "Sheperdess" to {_roles::*}
    loop all players:
        set {_p} to loop-player
        set {_r} to random object out of {_roles::*}
        set {Game.Role::%{_p}%} to {_r}
        remove {_r} from {_roles::*}
  
        send {_p} title "" with subtitle "&7&oYou got your role..." for 5 seconds
        skellett play skellett sound "LEVEL_UP " to {_p} with volume 1.5 and pitch 3
        send "&e&lYou are : %{Game.Role::%{_p}%}%" to {_p}
      
command /rolesdefine:
    trigger:
        BroadcastRoles()

Oh ok ! Thanks a lot for your help ! (and Donut).
My problem is now solved

Solved
 
Ahh you should've tagged donuts post as best answer because he was the one to spot the error :emoji_grinning:
You're welcome, it's nice to help if you make it easy for one
 
Status
Not open for further replies.