Solved How to cancel broadcast?

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

Adrihun

Member
Feb 1, 2017
368
6
0
I am currently working on json prefixes for my Server. So whenever you type something in chat, it will do tellraw (as console) and if you hover over the prefix, it will say rank description.

code_language.skript:
on chat:
    cancel event
    player has permission "admin"
    set {_to} to "%player%"
    set {_msg} to "test||ttp:test%nl%test|| &5%player%&8 %message%"
    json({_to}, {_msg})

code_language.skript:
function json(to: text, msg: text, color: boolean = true):
    set {_msg} to jsonFormat({_msg}, {_color})
    execute console command "/tellraw @a %{_msg}%"
    
    if {@debug} is true:
        set {_player} to {_to} parsed as offline player
        if {_player} is online:
            send uncolored {_msg} to {_player}
https://forums.skunity.com/resources/json-sk.23/

Before This, i just had "on chat:" for my Anti Spam.
It will be really hard now to block spam in chat.

Does anyone know how i can make anti spam, anti swear in this script?
 
place the "on chat" part of antispam before the json part.
Example:

code_language.skript:
    on chat:
        cancel event
        if message contais "nigger":
          stop #this stops the code here hence stops the json broadcast
        player has permission "admin"
        set {_to} to "%player%"
        set {_msg} to "test||ttp:test%nl%test|| &5%player%&8 %message%"
        json({_to}, {_msg})
 
Instead of asking help for anti-spam, maybe you can do it yourself because it's literally the easiest thing to do.

Literally just add a variable detecting whether the player can chat or not. If the variable says he can, set the variable to "cannot chat yet" or whatever and wait 0.5 seconds. After the wait, set the variable to "able to chat" or something like that. Simple.
 
@White
code_language.skript:
on chat:
    cancel event
    {sql_.antispam.%player%} is true
    stop
    player has permission "test"
    set {_to} to "%player%"
    set {_msg} to "test &5%player%&c %message%"
    json({_to}, {_msg})
    wait 1 ticks
    set {sql_.antispam.%player%} to true
    wait 1 seconds
    clear {sql_.antispam.%player%}

It should work?
Also @aescraft @White in @aescraft 's script how do i send message to player?
I tried message "no"and send "no" to player But it won't show in chat?
 
Here's your problem with the anti-spam. First of all, pretty messy and obviously wouldn't work due to lack of indentations or use of " : ". Also, why are you clearing the player's anti-spam variable after it is set to true? That means it won't exist anymore after deletion. If you want to clear it, clear the variable after the player quits.

code_language.skript:
on chat:
    cancel event
    if {sql_.antispam.%player%} is true:
        if message contains "bad words and stuff":
            stop
        if player has permission "test":
            set {_to} to "%player%"
            set {_msg} to "test &5%player%&c %message%"
            json({_to}, {_msg})
            wait 1 ticks
            set {sql_.antispam.%player%} to true

on quit:
    delete {sql_.antispam.%player%.}
    # Use this if you want to clear the player's variable

To answer your other question, simply do

code_language.skript:
send "no" to player
 
@White Thanks.

code_language.skript:
    on chat:
        cancel event
        if message contais "nigger":
          stop
          send "no" to player
        player has permission "admin"
        set {_to} to "%player%"
        set {_msg} to "test||ttp:test%nl%test|| &5%player%&8 %message%"
        json({_to}, {_msg})

This for some reason doesn't work. Nothing shows up in chat.
Using Spigot 1.8.9 Server
Bungee 1.11.2
Skript 2.2 dev 25
 
Every time you add stop, you want to add it at the end of the condition. So in this code, put it after send "no" to player.
 
Last edited by a moderator:
@White Thanks.

code_language.skript:
    on chat:
        cancel event
        if message contais "nigger":
          stop
          send "no" to player
        player has permission "admin"
        set {_to} to "%player%"
        set {_msg} to "test||ttp:test%nl%test|| &5%player%&8 %message%"
        json({_to}, {_msg})

This for some reason doesn't work. Nothing shows up in chat.
Using Spigot 1.8.9 Server
Bungee 1.11.2
Skript 2.2 dev 25

The "stop" stops the skript. This is what makes the skript not continue thus not broadcasting the message with "nigger" on it.
if you want the "no" to be sent to the player, you need to place the line "send "no" to player" BEFORE the stop, not after.

This is the correct:

code_language.skript:
    on chat:
        cancel event
        if message contais "nigger":
          send "no" to player
          stop
        player has permission "admin"
        set {_to} to "%player%"
        set {_msg} to "test||ttp:test%nl%test|| &5%player%&8 %message%"
        json({_to}, {_msg})
 
Status
Not open for further replies.