Solved list variable contains

  • 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 thought i got a working code to mute people:

code_language.skript:
command /mute [<player>]:
    permission: mute.mute
    trigger:
        if arg-1 is set:
            if {mutes::*} contain arg-1:
                send "&b%arg-1% is already muted!" to player
                stop
            else:
                add arg-1 to {mutes::*}
                send "&b%arg-1% is now muted!" to player
                send "&bYou are muted by %player%!" to arg-1
                send "&b%player% muted %arg-1%!" to console
                stop
        else:
            send "&bPlease define a player." to player
            stop

This code doesn't give an error, but it doesn't work.
It a player is in {mutes::*}, but he can still talk.

Help?
 
So you need to have an event that cancels you from chatting let me give you an example.
This is a raw sketch btw so it will not work with how ur code is right now.
Code:
on chat:
    if {Mutes.%player%} is set true:
        cancel event
        send "&7You are muted! You are not allowed to talk!"
 
So you need to have an event that cancels you from chatting let me give you an example.
This is a raw sketch btw so it will not work with how ur code is right now.
Code:
on chat:
    if {Mutes.%player%} is set true:
        cancel event
        send "&7You are muted! You are not allowed to talk!"

i already got that piece of code working, but you can still chat when you are muted.
And i want to use a list variable so that i can unmute everyone with /unmute by deleting the list variable
 
So unmuting everyone is simple enough you just do this.
However with the other thing i can not help sorry
Code:
command /unmute:
    trigger:
 
i already got that piece of code working, but you can still chat when you are muted.
And i want to use a list variable so that i can unmute everyone with /unmute by deleting the list variable
code_language.skript:
command /mute [<player>]:
    permission: mute.mute
    trigger:
        if argument is set:
            if {mutes::*} contains argument:
                send "&b%arg-1% is already muted!" to player
            else:
                add argument to {mutes::*}
                send "&b%argument% is now muted!" to player
                send "&bYou are muted by %player%!" to arg-1
                send "&b%player% muted %arg-1%!" to console
        else:
            send "&bPlease define a player." to player
           
command /unmute {<player>]:
    trigger:
        if {mutes::*} contains argument:
            remove argument from {mutes::*}
        else:
            send "&7Please define a player"
           
on chat:
    if {mutes::*} contains player:
        cancel event
        send "&7You are muted"
 
I think 'contains' is buggy (?) in Skript. Try using

This function
code_language.skript:
function contains(list: objects, testo: object) :: boolean:
    loop {mutes::*}:
        if loop-value is {_testo}:
            return true
    return false

on chat:
  if contains({mutes::*}, "%player%") is true:
    cancel event
    send "You're muted" to player

or this
code_language.skript:
on chat:
  loop {mutes::*}:
    "%loop-value%" = "%player%"
    cancel event
    send "You're muted" to player
 
I think 'contains' is buggy (?) in Skript. Try using

This function
code_language.skript:
function contains(list: objects, testo: object) :: boolean:
    loop {mutes::*}:
        if loop-value is {_testo}:
            return true
    return false

on chat:
  if contains({mutes::*}, "%player%") is true:
    cancel event
    send "You're muted" to player

or this
code_language.skript:
on chat:
  loop {mutes::*}:
    "%loop-value%" = "%player%"
    cancel event
    send "You're muted" to player
For me its not buggy. It's useless to loop it
 
you have to loop, contains for lists is broken. that being said the function that finalplayer gave you isnt quite correct
code_language.skript:
function contains(list: objects, testo: object) :: boolean:
    loop {_objects::*}:
        if loop-value is {_testo}:
            return true
    return false

on chat:
  if contains({mutes::*}, player) is true:
    cancel event
    send "You're muted" to player
 
Status
Not open for further replies.