Solved Team chat

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

SoMuchWessel

Active Member
Apr 3, 2017
147
3
18
Hey guys,

Is there a easy compact way to send a chat message to players with a permission only?
Like if the player has permission "team.red", that the message he send will only be seen by other players with this permission.

I prefer not to use loop all players
 
Last edited:
Like this?

code_language.skript:
on chat:
    cancel event
    loop all players:
        if loop-player has permission "team.red":
            message "&7%player%&f: %message%" to loop-player
 
Like this?

code_language.skript:
on chat:
    cancel event
    loop all players:
        if loop-player has permission "team.red":
            message "&7%player%&f: %message%" to loop-player

That will work, but what if i have many players on my server? Then there will be a delay because it will loop all players one by one
 
code_language.skript:
send “whatever” to all players where [player input has permission “whatever”]
Needs skquery
 
code_language.skript:
send “whatever” to all players where [player input has permission “whatever”]
Needs skquery

I tried with 3 codes, but none of them work, they all got the bugg that other people can see the other team chats. But in the color of there own team.
Like Player 1 is in team red, with the permission "team.red"
Player 2 is in team blue, with the permission "team.blue"

If player red is now chatting in teamchat red, player 2 sees his chat in blue color.
Same reversed.

Code1:

code_language.skript:
on chat:
    if {%player%.teamchat} is true:
        cancel event
        send "&8[&6TeamChat&8] &c%player%&f: %message%" to all players where [player input has permission "team.red"]
        send "&8[&6TeamChat&8] &9%player%&f: %message%" to all players where [player input has permission "team.blue"]
        send "&8[&6TeamChat&8] &2%player%&f: %message%" to all players where [player input has permission "team.green"]
        send "&8[&6TeamChat&8] &a%player%&f: %message%" to all players where [player input has permission "team.lime"]
        send "&8[&6TeamChat&8] &d%player%&f: %message%" to all players where [player input has permission "team.pink"]

Code 2:

code_language.skript:
on chat:
    if {%player%.teamchat} is true:
        cancel event
        loop all players:
            if loop-player has permission "team.red":
                send "&8[&6TeamChat&8] &c%player%&f: %message%" to all players where [player input has permission "team.red"]
                send "&8[&6TeamChat&8] &c%player%&f: %message%" to console
            else if loop-player has permission "team.blue":
                send "&8[&6TeamChat&8] &9%player%&f: %message%" to all players where [player input has permission "team.blue"]
                send "&8[&6TeamChat&8] &9%player%&f: %message%" to console
            else if loop-player has permission "team.green":
                send "&8[&6TeamChat&8] &2%player%&f: %message%" to all players where [player input has permission "team.green"]
                send "&8[&6TeamChat&8] &2%player%&f: %message%" to console
            else if loop-player has permission "team.lime":
                send "&8[&6TeamChat&8] &a%player%&f: %message%" to all players where [player input has permission "team.lime"]
                send "&8[&6TeamChat&8] &a%player%&f: %message%" to console
            else if loop-player has permission "team.pink":
                send "&8[&6TeamChat&8] &d%player%&f: %message%" to all players where [player input has permission "team.pink"]
                send "&8[&6TeamChat&8] &d%player%&f: %message%" to console

Code 3:


code_language.skript:
on chat:
    if {%player%.teamchat} is true:
        cancel event
        loop all players:
            if loop-player has permission "team.red":
                send "&8[&6TeamChat&8] &c%player%&f: %message%" to loop-player
                send "&8[&6TeamChat&8] &c%player%&f: %message%" to console
            else if loop-player has permission "team.blue":
                send "&8[&6TeamChat&8] &9%player%&f: %message%" to loop-player
                send "&8[&6TeamChat&8] &9%player%&f: %message%" to console
            else if loop-player has permission "team.green":
                send "&8[&6TeamChat&8] &2%player%&f: %message%" to loop-player
                send "&8[&6TeamChat&8] &2%player%&f: %message%" to console
            else if loop-player has permission "team.lime":
                send "&8[&6TeamChat&8] &a%player%&f: %message%" to loop-player
                send "&8[&6TeamChat&8] &a%player%&f: %message%" to console
            else if loop-player has permission "team.pink":
                send "&8[&6TeamChat&8] &d%player%&f: %message%" to loop-player
                send "&8[&6TeamChat&8] &d%player%&f: %message%" to console
 
because youre sending it to all the teams...

you need to do something like
code_language.skript:
if player has permission "team.red":
    send "&8[&6TeamChat&8] &c%player%&f: %message%" to all players where [player input has permission "team.red"]
else if player has permission "team.blue":
    send "&8[&6TeamChat&8] &9%player%&f: %message%" to all players where [player input has permission "team.blue"]
however idk why youre using perms for teams in the first place
 
because youre sending it to all the teams...

you need to do something like
code_language.skript:
if player has permission "team.red":
    send "&8[&6TeamChat&8] &c%player%&f: %message%" to all players where [player input has permission "team.red"]
else if player has permission "team.blue":
    send "&8[&6TeamChat&8] &9%player%&f: %message%" to all players where [player input has permission "team.blue"]
however idk why youre using perms for teams in the first place

This worked! Thanks :emoji_slight_smile:
And im using permissions because i got different permission groups for each team
 
Status
Not open for further replies.