Variables cannot be used here. Please help

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

Aarush Jain

Member
Oct 22, 2023
11
0
1
24
In my skript this issue is occurring kindly help

Issue in line

else if %{chattext::%player%}% is {_message} and if %{chatspamcount::%player%}% is 5:

Skript file
variables:
{chatspamcount::%player%} = 0

on chat:
loop all players:
if player has permission "spam.ignore":
else if %{chattext::%player%}% is {_message} and if %{chatspamcount::%player%}% is 5:
cancel event
send "&c&lYou should not spam!"
else:
set {chattext::%player%} to {_message}
add 1 to {chatspamcount::%player%}

Issue
says variables cannot be used here


Please help
 
Last edited:
Hey,
1. Use code format for pasting code into the post
2. learn how to make syntaxes and spacings
3. From what i understand you want to make chat cooldown that player can send message after 5 seconds?
 
Hey,
1. Use code format for pasting code into the post
2. learn how to make syntaxes and spacings
3. From what i understand you want to make chat cooldown that player can send message after 5 seconds?
naah
I am trying a make a code so that a person does not spam same thing more than 5 times consecutively.
 
here is the file cause these threads do not support spaces or smth
 

Attachments

  • antispam.sk
    409 bytes · Views: 59
I think this is what you are looking for:
Code:
on join:
    set {messages::%player%} to ""
on chat:
    if {messages::%player%} is message:
        if {chatspamcount::%player%} is not 5:
            add 1 to {chatspamcount::%player%}
        else:
            cancel event
            send "&c&lYou should not spam!" to player
    else:
        set {messages::%player%} to message
        clear {chatspamcount::%player%}
 
I think this is what you are looking for:
Code:
on join:
    set {messages::%player%} to ""
on chat:
    if {messages::%player%} is message:
        if {chatspamcount::%player%} is not 5:
            add 1 to {chatspamcount::%player%}
        else:
            cancel event
            send "&c&lYou should not spam!" to player
    else:
        set {messages::%player%} to message
        clear {chatspamcount::%player%}
Thanks