Making /ignore command

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

YellowZaki

Member
Mar 6, 2017
24
0
0
26
I'm making a /ignore command but I can't get it to work (all players receive the message). Any help would be appreciated :emoji_grinning:


code_language.skript:
command /ignore [<player>]:
    trigger:
        if arg 1 is not set:
            send "You are ignoring: %{ignorar:%player%::*}%"
            stop
        if arg 1 is set:
            if arg 1 is "%player%":
                send "You cannot ignore yourself."
                stop
            else:
                if {ignorar:%player%::*} contains arg 1:
                    clear {ignorar:%player%::*}
                    send "You are no longer ignoring %arg 1%."
                    stop
                else:
                    add arg 1 to {ignorar:%player%::*}
                    send "You are now ignoring %arg 1%."
                    stop

on chat:
    cancel event
    loop all players:
        if {ignorar::%loop-player%::*} contains player:
            stop
        else:
            send "%message%" to loop-player
 
I'll point out the problem and some suggestions here:
1. You don't have to check if the first argument isn't set then check if it is, an else statement instead of checking if the first argument is set would be sufficient.

2. That stop everywhere is so useless and what's causing the issue here, the stop effect is used when you want stop the current trigger, putting it at the end of the trigger is just useless (I know it can be a habit, I had it but you may want stop doing it such as it can cause issues like this one), and in this case, it's stopping the loop from being executed after the first element on that list.

3. Instead of cancel the event and send a message, you could do the following:
code_language.skript:
loop all players:
    if {ignorar::%loop-player%::*} contains player:
        remove loop-player from chat recipients
 
I'll point out the problem and some suggestions here:
1. You don't have to check if the first argument isn't set then check if it is, an else statement instead of checking if the first argument is set would be sufficient.

2. That stop everywhere is so useless and what's causing the issue here, the stop effect is used when you want stop the current trigger, putting it at the end of the trigger is just useless (I know it can be a habit, I had it but you may want stop doing it such as it can cause issues like this one), and in this case, it's stopping the loop from being executed after the first element on that list.

3. Instead of cancel the event and send a message, you could do the following:
code_language.skript:
loop all players:
    if {ignorar::%loop-player%::*} contains player:
        remove loop-player from chat recipients
Thanks for the advices, but it doesn't work neither. Actually, it'll not send a chat message, it will be a a tellraw so I cannot use the chat recipients thing.

code_language.skript:
command /ignore [<player>]:
    trigger:
        if arg 1 is not set:
            send "You are ignoring: %{ignorar:%player%::*}%"
        else:
            if arg 1 is "%player%":
                send "You cannot ignore yourself."
            else:
                if {ignorar:%player%::*} contains arg 1:
                    clear {ignorar:%player%::*}
                    send "You are no longer ignoring %arg 1%."
                else:
                    add arg 1 to {ignorar:%player%::*}
                    send "You are now ignoring %arg 1%."
 
on chat:
    cancel event
    loop all players:
        if {ignorar::%loop-player%::*} contains player:
            set {_temp} to 1
        else:
            execute console command "/tellraw %loop-player% ["""",{""text"":""%{prefixmiembro}%%player's display name%"",""clickEvent"":{""action"":""suggest_command"",""value"":""/msg %player's name% ""},""hoverEvent"":{""action"":""show_text"",""value"":{""text"":"""",""extra"":[{""text"":""&8&m----------------\n&6Nivel de isla &a>&e %island level of player%\n&8&m----------------\n&cClick para mensaje privado""}]}}},{""text"":""%{suffixmiembro}%%message%"",""color"":""white""}]"
 
code_language.skript:
on chat:
    cancel event
    loop all players:
        loop {ignorar::%loop-player%::*}:
            if "%loop-player%" isn't "%loop-value%":
                execute console command "/tellraw %loop-player% ["""",{""text"":""%{prefixmiembro}%%player's display name%"",""clickEvent"":{""action"":""suggest_command"",""value"":""/msg %player's name% ""},""hoverEvent"":{""action"":""show_text"",""value"":{""text"":"""",""extra"":[{""text"":""&8&m----------------\n&6Nivel de isla &a>&e %island level of player%\n&8&m----------------\n&cClick para mensaje privado""}]}}},{""text"":""%{suffixmiembro}%%message%"",""color"":""white""}]"
 
code_language.skript:
on chat:
    cancel event
    loop all players:
        loop {ignorar::%loop-player%::*}:
            if "%loop-player%" isn't "%loop-value%":
                execute console command "/tellraw %loop-player% ["""",{""text"":""%{prefixmiembro}%%player's display name%"",""clickEvent"":{""action"":""suggest_command"",""value"":""/msg %player's name% ""},""hoverEvent"":{""action"":""show_text"",""value"":{""text"":"""",""extra"":[{""text"":""&8&m----------------\n&6Nivel de isla &a>&e %island level of player%\n&8&m----------------\n&cClick para mensaje privado""}]}}},{""text"":""%{suffixmiembro}%%message%"",""color"":""white""}]"
It doesn't work neither (I changed loop-value to loop-value-2 because it didn't load)
[doublepost=1493978631,1493590405][/doublepost]Bump!
 
It doesn't work neither (I changed loop-value to loop-value-2 because it didn't load)
[doublepost=1493978631,1493590405][/doublepost]Bump!
code_language.skript:
on chat:
    cancel event
    loop all players:
        if {ignorar::%loop-player%::%player%} is not set:
            execute console command "/tellraw %loop-player% ["""",{""text"":""%{prefixmiembro}%%player's display name%"",""clickEvent"":{""action"":""suggest_command"",""value"":""/msg %player's name% ""},""hoverEvent"":{""action"":""show_text"",""value"":{""text"":"""",""extra"":[{""text"":""&8&m----------------\n&6Nivel de isla &a>&e %island level of player%\n&8&m----------------\n&cClick para mensaje privado""}]}}},{""text"":""%{suffixmiembro}%%message%"",""color"":""white""}]"
 
code_language.skript:
on chat:
    cancel event
    loop all players:
        if {ignorar::%loop-player%::%player%} is not set:
            execute console command "/tellraw %loop-player% ["""",{""text"":""%{prefixmiembro}%%player's display name%"",""clickEvent"":{""action"":""suggest_command"",""value"":""/msg %player's name% ""},""hoverEvent"":{""action"":""show_text"",""value"":{""text"":"""",""extra"":[{""text"":""&8&m----------------\n&6Nivel de isla &a>&e %island level of player%\n&8&m----------------\n&cClick para mensaje privado""}]}}},{""text"":""%{suffixmiembro}%%message%"",""color"":""white""}]"
Still not working ;C
[doublepost=1494372943,1494010574][/doublepost]Bump
 
Still not working ;C
[doublepost=1494372943,1494010574][/doublepost]Bump
i have no plan what your problem?


upload_2017-5-10_3-2-45.png



code_language.skript:
command /ignore <player>:
    trigger:
        if arg-1 is not player:
            if {Ignore::%player%::%arg-1%} is set:
                delete {Ignore::%player%::%arg-1%}
                send "You can see now text from %arg-1%"
            else:
                set {Ignore::%player%::%arg-1%} to true
                send "You will not anymore see %arg-1% text"
                
on chat:
    cancel event
    loop all players:
        if {Ignore::%loop-player%::%player%} is not set:
            send "Psst... %player% - %message%" to loop-player
 
  • Like
Reactions: YellowZaki
i have no plan what your problem?


View attachment 667


code_language.skript:
command /ignore <player>:
    trigger:
        if arg-1 is not player:
            if {Ignore::%player%::%arg-1%} is set:
                delete {Ignore::%player%::%arg-1%}
                send "You can see now text from %arg-1%"
            else:
                set {Ignore::%player%::%arg-1%} to true
                send "You will not anymore see %arg-1% text"
               
on chat:
    cancel event
    loop all players:
        if {Ignore::%loop-player%::%player%} is not set:
            send "Psst... %player% - %message%" to loop-player
I can also confirm it works.
It is your server.
 
i have no plan what your problem?


View attachment 667


code_language.skript:
command /ignore <player>:
    trigger:
        if arg-1 is not player:
            if {Ignore::%player%::%arg-1%} is set:
                delete {Ignore::%player%::%arg-1%}
                send "You can see now text from %arg-1%"
            else:
                set {Ignore::%player%::%arg-1%} to true
                send "You will not anymore see %arg-1% text"
               
on chat:
    cancel event
    loop all players:
        if {Ignore::%loop-player%::%player%} is not set:
            send "Psst... %player% - %message%" to loop-player
Oh, thanks a lot, it worked!
 
Status
Not open for further replies.