Solved Chat Delay

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

IDuckz_

Active Member
Jul 25, 2019
106
2
18
Um, I am trying to make a Chat delay skript, but it does not work, I am trying to make it only donors can bypass this, but members can't

Here is my code:

Code:
command /chatdelay [<text>] [<number>]:
    aliases: /delaychat
    permission: mythical.chatdelay
    permission message: Unknown command. Type "/help" for help.
    trigger:
        if arg-1 is not set:
            clear {delay.timer}
            loop all players:
                set {delay.%loop-player%.timer} to 0
                send "&cSuccessfully removed the timer."
        if arg-1 is "set":
            if arg-2 is set:
                set {delay.timer} to arg-2
                send "&cYou have successfully set the chat delay to %arg-2%"
                stop
        if arg-1 is "help":
            send "&8&m-----------------------------------------"
            send "&c/chatdelay set <seconds> - Sets the chat delay."
            send "&c/chatdelay - Removes the chat delay."
            send "&c/chatdelay help - Displays this page."
            send "&c/chatdelay info - Extra info."
            send "&8&m-----------------------------------------"
            stop
        if arg-1 is "info":
            send "&8&m-----------------------"
            send "&cVersion: 1.0"
            send "&cMade By: ???"
            send "&8&m-----------------------"
            stop

on chat:
    if {delay.%player%.timer} is higher than 0:
        if player does not have permission "mythical.chatdelaybypass":
            send "&cYou must wait {delay.timer} before chatting."
            send "&cPurchase a rank at https://mythicalrpg.tebex.io to bypass this."
            stop
    add {delay.timer} to {delay.%player%.timer}

Thank you :emoji_slight_smile:
 
Um I don't understand the global container and the local container thing, and I tried greater than 0 and it didn't work :emoji_frowning:
 
There are two problems with your skript:

First is your variables. You are not using list variables.
Using simple variables like {something.%player%.timer} instead of {chatdelay::%player%::timer}, you will lost the ability to delete all variables.

To delete all variables with a list variable, just use:

delete {chatdelay::*}


################################

The other is that you didn't really code anything that will prevent the player from using the chat.
You are expecting that skript will see your variable "timer" and create by itself a clock. This is not how it works.
You just set up a really bad system for setting the timer and that's it.

I'll not feed you code on this, as if I do, you won't learn nothing.
Try reading what I said carefully and coding a system that works.

For the timer part, search how to do a cooldown. Looks like you didn't do your homework on this one, and it's a basic one, seriously.
 
So something like this

Code:
on chat:
    if ( 10 - 7 ) < 4:
        if player does not have permission "mythical.chatdelaybypass":
            cancel event
            send "&cYou must wait %{delay::timer}% before chatting."
            send "&cPurchase a rank at https://mythicalrpg.tebex.io to bypass this."
            stop

Edit: I am not very advanced in skript, so I don't know most of these stuff.
 
So something like this:

Code:
command /chat [<text>] [<number>]:
    permission: mythical.chatdelay
    permission message: Unknown command. Type "/help" for help.
    trigger:
        if arg 1 is "chatdelay":
            if player has permission "echat.togglechatdelay":
                if {ChatDelay.On} is false:
                    set {ChatDelay.On} to true
                    message "&9You have &aenabled &7chat delay!"
                    message "&9Info> &7Use /chatdelay <Time in seconds> to set the delay!"
                    stop trigger
                if {ChatDelay.On} is true:
                    set {ChatDelay.On} to false
                    message "&9You have &cdisabled &7chat delay!"
                    stop trigger
                if {ChatDelay.On} is not set:
                    set {ChatDelay.On} to true
                    message "&9You have &aenabled &7chat delay!"
                    message "&9Info> &7Use /chatdelay <Time in seconds> to set the delay!"
                    stop trigger
            else:
                message "&9You do not have permission to execute this command!"
 
on chat:
    if {ChatDelay.On} is true:
        if player has permission "echat.delaybypass":
            stop
        if {chatslow} isn't set:
            stop
        if difference between {lastChat::%player%} and now < {chatslow}:
            cancel event
            message "&9Blocked> &7You have to wait %{chatslow}% between messages!"
        else:
            set {lastChat::%player%} to now
    else:
        stop

Edit: Wops, I have to fix some stuff xd
 
Here is the code right now:

Code:
command /chat [<text>]:
    permission: mythical.chatdelay
    permission message: Unknown command. Type "/help" for help.
    trigger:
        if arg 1 is "chatdelay":
            if player has permission "echat.togglechatdelay":
                if {ChatDelay.On} is false:
                    set {ChatDelay.On} to true
                    message "&9You have &aenabled &7chat delay!"
                    message "&9Info> &7Use /chatdelay <Time in seconds> to set the delay!"
                    stop trigger
                if {ChatDelay.On} is true:
                    set {ChatDelay.On} to false
                    message "&9You have &cdisabled &7chat delay!"
                    stop trigger
                if {ChatDelay.On} is not set:
                    set {ChatDelay.On} to true
                    message "&9You have &aenabled &7chat delay!"
                    message "&9Info> &7Use /chatdelay <Time in seconds> to set the delay!"
                    stop trigger
            else:
                message "&9You do not have permission to execute this command!"
 
on chat:
    if {ChatDelay.On} is true:
        if player has permission "echat.delaybypass":
            stop
        if {chatslow} isn't set:
            stop
        if difference between {lastChat::%player%} and now < {chatslow}:
            cancel event
            message "&9Blocked> &7You have to wait %{chatslow}% between messages!"
        else:
            set {lastChat::%player%} to now
    else:
        stop
       
command /chatdelay [<integer>]:
    permission: echat.setdelay
    permission message: &9You do not have permission to execute this command!
    trigger:
        if {ChatDelay.On} is true:
            if player has permission "echat.setdelay":
                set {chatslow} to "%arg-1% seconds" parsed as timespan
                message "&9Chat delay set to %{chatslow}%"
            else:
                message "&9You do not have permission to execute this command!"
        else:
            message "&9Chat delay is currently disabled! (Use /chat chatdelay)"

But the weird thing is once I leave and join back, the chatdelay doesn't seem to work, or once I get kicked for spamming.

Edit: Nevermind, it seems I get opped once I join back -.-
[doublepost=1565450343,1565450289][/doublepost]Its fixed :emoji_grinning:!
 
Status
Not open for further replies.