Permissions Variable List

  • 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.
Aug 19, 2017
10
0
0
34
Hi there,
I am creating a script which will tell you upon command what ranks the user has. Each rank has a permission "rank.(group)" and this is what I tried below.
code_language.skript:
on join:
    if player has permission "rank.member":
        set {test.list::%player%} to true
command /test [<offline player>]:
    trigger:
        if arg-1 is set:
            send  "&2&lMCM &8» &b%arg-1%'s &aRanks"
            send "&2&lMCM &8» &aHas Ranks: &b%{test::*}%"

But it shows up as "Has Ranks: <none>" and the permission is given to the player.

Can anyone help me please? Thank you in advance
 
In line 8 you need to send %{test.list::%player%}% or {test.list::*}, not sure what you're trying to do
I am trying to list all the ranks a player has. Example script below.
code_language.skript:
on join:
    if player has permission "rank.member":
        add "Member" to {test.list::%player%}
    if player has permission "rank.donator":
        add "Donator" to {test.list::%player%}
So when the script is "%{test.list::%player%}" is will show Member, Donator if the player has those 2 permissions
 
Here's how it should look
code_language.skript:
on join:
    delete {ranks::%player%::*} #so it gets rid of stuff from last time they joined
    if player has permission "rank.member":
        add "member" to {ranks::%player%::*}

command /test [<offline player>]:
    trigger:
        if arg-1 is set:
            send "%{ranks::%arg-1%::*}%"
however you might just wanna check the permissions when the command is executed because the permission could be given/taken away after they have joined and then just use a local list variable
 
@Donut @MrMonkeyPants34 this is how it should look if we're talking best practices
code_language.skript:
on script load:
  delete {ranks::ranks::*}
  call custom event "register ranks"
function contains(list: objects, value: object) :: boolean:
  if {_list::*} where [object input is {_value}] is set:
    return true
  return false
function registerRank(rank: string) :: boolean:
  if {ranks::ranks::%{_rank}%} is not set:
    set {ranks::ranks::%{_rank}%} to {_rank}
    return true
  return false
function getRanks(player: offline player) :: strings:
  set {_uuid} to uuid of {_player}
  loop {ranks::players::%{_uuid}%::*}:
    if {ranks::ranks::%loop-value%} is not set:
      delete {ranks::players::%{_uuid}%::%loop-index%}
  return {ranks::players::%{_uuid}%::*}
function getRank(player: offline player) :: strings:
  return getRanks({_player})
function addRanks(player: offline player, rank: strings):
  set {_uuid} to uuid of {_player}
  add ({_ranks::*} where [not (contains({ranks::players::%{_uuid}%::*}, string input)]) to {ranks::players::%{_uuid}%::*}
function addRank(player: offline player, ranks: strings):
  addRanks({_player}, {_ranks::*})
function deleteRanks(player: offline player):
  set {_uuid} to uuid of {_player}
  delete {ranks::players::%{_uuid}%::*}
function setRanks(player: offline player, ranks: strings):
  set {_uuid} to uuid of {_player}
  set {ranks::players::%{_uuid}%::*} to {_ranks::*}
function setRank(player: offline player, ranks: strings):
  setRanks({_player}, {_ranks::*})
function removeRanks(player: offline player, ranks: strings):
  set {_uuid} to uuid of {_player}
  remove all {_ranks::*} from {ranks::players::%{_uuid}%::*}
function removeRank(player: offline player, ranks: strings):
  removeRanks({_player}, {_ranks::*})
evt "register ranks":
  registerRank("Member")
  registerRank("Donator")
command /ranks <offline player>:
  trigger:
    set {_ranks::*} to getRanks(arg-1)
    set {_message} to check [{_ranks::*} is set] ? "the rank%(size of {_ranks::*}) == 1 ? """" : ""s""% %{_ranks::*}%" : "no ranks"
    message "%arg-1% has %{_message}%."
 
@Donut @MrMonkeyPants34 this is how it should look if we're talking best practices
code_language.skript:
on script load:
  delete {ranks::ranks::*}
  call custom event "register ranks"
function contains(list: objects, value: object) :: boolean:
  if {_list::*} where [object input is {_value}] is set:
    return true
  return false
function registerRank(rank: string) :: boolean:
  if {ranks::ranks::%{_rank}%} is not set:
    set {ranks::ranks::%{_rank}%} to {_rank}
    return true
  return false
function getRanks(player: offline player) :: strings:
  set {_uuid} to uuid of {_player}
  loop {ranks::players::%{_uuid}%::*}:
    if {ranks::ranks::%loop-value%} is not set:
      delete {ranks::players::%{_uuid}%::%loop-index%}
  return {ranks::players::%{_uuid}%::*}
function getRank(player: offline player) :: strings:
  return getRanks({_player})
function addRanks(player: offline player, rank: strings):
  set {_uuid} to uuid of {_player}
  add ({_ranks::*} where [not (contains({ranks::players::%{_uuid}%::*}, string input)]) to {ranks::players::%{_uuid}%::*}
function addRank(player: offline player, ranks: strings):
  addRanks({_player}, {_ranks::*})
function deleteRanks(player: offline player):
  set {_uuid} to uuid of {_player}
  delete {ranks::players::%{_uuid}%::*}
function setRanks(player: offline player, ranks: strings):
  set {_uuid} to uuid of {_player}
  set {ranks::players::%{_uuid}%::*} to {_ranks::*}
function setRank(player: offline player, ranks: strings):
  setRanks({_player}, {_ranks::*})
function removeRanks(player: offline player, ranks: strings):
  set {_uuid} to uuid of {_player}
  remove all {_ranks::*} from {ranks::players::%{_uuid}%::*}
function removeRank(player: offline player, ranks: strings):
  removeRanks({_player}, {_ranks::*})
evt "register ranks":
  registerRank("Member")
  registerRank("Donator")
command /ranks <offline player>:
  trigger:
    set {_ranks::*} to getRanks(arg-1)
    set {_message} to check [{_ranks::*} is set] ? "the rank%(size of {_ranks::*}) == 1 ? """" : ""s""% %{_ranks::*}%" : "no ranks"
    message "%arg-1% has %{_message}%."
this is how it should look if you want to kill a fly with a nuke
 
Uh, no this is how it should look if you want to write decent scripts and still maintain sanity
Right...

I definitely get less of a headache looking at this
code_language.skript:
on script load:
  delete {ranks::ranks::*}
  call custom event "register ranks"
function contains(list: objects, value: object) :: boolean:
  if {_list::*} where [object input is {_value}] is set:
    return true
  return false
function registerRank(rank: string) :: boolean:
  if {ranks::ranks::%{_rank}%} is not set:
    set {ranks::ranks::%{_rank}%} to {_rank}
    return true
  return false
function getRanks(player: offline player) :: strings:
  set {_uuid} to uuid of {_player}
  loop {ranks::players::%{_uuid}%::*}:
    if {ranks::ranks::%loop-value%} is not set:
      delete {ranks::players::%{_uuid}%::%loop-index%}
  return {ranks::players::%{_uuid}%::*}
function getRank(player: offline player) :: strings:
  return getRanks({_player})
function addRanks(player: offline player, rank: strings):
  set {_uuid} to uuid of {_player}
  add ({_ranks::*} where [not (contains({ranks::players::%{_uuid}%::*}, string input)]) to {ranks::players::%{_uuid}%::*}
function addRank(player: offline player, ranks: strings):
  addRanks({_player}, {_ranks::*})
function deleteRanks(player: offline player):
  set {_uuid} to uuid of {_player}
  delete {ranks::players::%{_uuid}%::*}
function setRanks(player: offline player, ranks: strings):
  set {_uuid} to uuid of {_player}
  set {ranks::players::%{_uuid}%::*} to {_ranks::*}
function setRank(player: offline player, ranks: strings):
  setRanks({_player}, {_ranks::*})
function removeRanks(player: offline player, ranks: strings):
  set {_uuid} to uuid of {_player}
  remove all {_ranks::*} from {ranks::players::%{_uuid}%::*}
function removeRank(player: offline player, ranks: strings):
  removeRanks({_player}, {_ranks::*})
evt "register ranks":
  registerRank("Member")
  registerRank("Donator")
command /ranks <offline player>:
  trigger:
    set {_ranks::*} to getRanks(arg-1)
    set {_message} to check [{_ranks::*} is set] ? "the rank%(size of {_ranks::*}) == 1 ? """" : ""s""% %{_ranks::*}%" : "no ranks"
    message "%arg-1% has %{_message}%."

Than this
code_language.skript:
on join:
    delete {ranks::%player%::*} #so it gets rid of stuff from last time they joined
    if player has permission "rank.member":
        add "member" to {ranks::%player%::*}

command /test [<offline player>]:
    trigger:
        if arg-1 is set:
            send "%{ranks::%arg-1%::*}%"
 
Status
Not open for further replies.