StaffChat Skript

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

SlackPlaysMC

Member
Jul 18, 2017
20
0
0
29
code_language.skript:
options:
    scprefix:&8[&4StaffChat&8]&7
    
command /sc [<text>]:
    trigger:
        if player has permission "is.staff":
            if arg-1 is set:
                if arg-1 is "toggle":
                    if {sc.%player%} is "false":
                        set {sc.%player%} to "true"
                        send "{@scprefix} Staff chat enabled." to player
                    if {sc.%player%} is "true":
                        set {sc.%player%} to "false"
                        send "{@scprefix} Staff chat disabled." to player
                else:
                    loop all players:
                        if loop-player has permission "is.staff":
                            send "{@scprefix} &c%player's display name%&f: &f%arg-1%" to loop-players
    
on chat:
    if {sc.%player%} is "true":
        loop all players:
            if loop-player has permission "is.staff":
                send "{@scprefix} &c%player's display name%&f: &f%message%"



So I've been trying to make a staff chat script for my server for 2 hours now, in which i kindof succeeded but not exactly. I made it so they can send messages directly and recieve too, but I can't make them able to toggle it. Please help me.
 
code_language.skript:
command /sc [<text>]:
    permission: sc.staff
    trigger:
        if arg-1 is set:
            if {staffchat::%player%} is set:
                delete {staffchat::%player%}
                send "&7Disabled"
            else:
                set {staffchat::%player%} to true
                send "&7enabled"
               
on chat:
    if {staffchat::%player%} is set:
        loop all players:
            loop-player has permission "see.chat":
                send "&c%player's display name%&f: &f%message%" to loop-player
 
I think it would be usefull to explain you why i didn't work.

code_language.skript:
if {sc.%player%} is "false":
 set {sc.%player%} to "true"
 send "{@scprefix} Staff chat enabled." to player
if {sc.%player%} is "true":
 set {sc.%player%} to "false"
 send "{@scprefix} Staff chat disabled." to player

if you look at this part it will start checking if {sc.%player%} is "false":. Lats say it is false. It will set {sc.%player%} to "true". then you would say its done but it isn't. What happens is it will continue to if {sc.%player%} is "true":. And because you have just set it to true is will allways set your {sc.%player%} to false. The second thing is you never have set {sc.%player%} to true or false. so it will never check for it.
 
Status
Not open for further replies.