Problems with event commands

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

Death68093

Member
Nov 17, 2025
2
0
1
Im trying to make some simple /addwin and /remwin cmds and I'm new to skript. but I can't get this to work. when I add a win it will show I have 1 win (even when I do it multiple times) and when I use /remwin It will skip 0 and show I have -1 win.
here is my skript:


Code:
command /addwin <offlineplayer>:
    permission: event.wins.addwin
    trigger:
        set {_plr} to arg-1
        set {_uuid} to uuid of {_plr}
        if {_data::players::%{_uuid}%::wins} is not set:
            set {_data::players::%{_uuid}%::wins} to 0
        add 1 to {_data::players::%{_uuid}%::wins}
        send "&aAdded a win for %{_plr}%! Total wins: %{_data::players::%{_uuid}%::wins}%" to player
        broadcast "&c%{_plr}%&b now has %{_data::players::%{_uuid}%::wins}% wins!"

command /remwin <offlineplayer>:
    permission: event.wins.remwin
    trigger:
        set {_plr} to arg-1
        set {_uuid} to uuid of {_plr}
        if {_data::players::%{_uuid}%::wins} is not set:
            set {_data::players::%{_uuid}%::wins} to 0
        remove 1 from {_data::players::%{_uuid}%::wins}
        send "&aRemoved a win for %{_plr}%! Total wins: %{_data::players::%{_uuid}%::wins}%" to player
        broadcast "&c%{_plr}%&b now has %{_data::players::%{_uuid}%::wins}% wins!"
 
Seems like it can't really check if someone has 0 wins or not... You could add an additional Checking mechanism like that:

Code:
command /remwin <offlineplayer>:
    permission: event.wins.remwin
    trigger:
        set {_plr} to arg-1
        set {_uuid} to uuid of {_plr}
        if {_data::players::%{_uuid}%::wins} is not set:
            set {_data::players::%{_uuid}%::wins} to 0
        if {_data::players::%{_uuid}%::wins} > 0:
            remove 1 from {_data::players::%{_uuid}%::wins}
            send "&aRemoved a win for %{_plr}%! Total wins: %{_data::players::%{_uuid}%::wins}%" to player
            broadcast "&c%{_plr}%&b now has %{_data::players::%{_uuid}%::wins}% wins!"
        else:
            send "&c%{_plr}% already has 0 wins, cannot remove more!" to player

With the "> 0:" it would check if the value is more than 0 and then it removes a win. If the value = 0 it would send the message that the player already has 0 wins. Let me know if that worked for ya!
 
  • Like
Reactions: Death68093
You could try checking if the wins is greater than 0 first, and if it's not you set it to 0 so you don't get -1:


command /remwin <offlineplayer>:
permission: event.wins.remwin
trigger:
set {_plr} to arg-1
set {_uuid} to uuid of {_plr}
if {_data::emoji_stuck_out_tongue:layers::%{_uuid}%::wins} is not set:
set {_data::emoji_stuck_out_tongue:layers::%{_uuid}%::wins} to 0
if {_data::emoji_stuck_out_tongue:layers::%{_uuid}%::wins} >= 0:
remove 1 from {_data::emoji_stuck_out_tongue:layers::%{_uuid}%::wins}
send "&aRemoved a win for %{_plr}%! Total wins: %{_data::emoji_stuck_out_tongue:layers::%{_uuid}%::wins}%" to player
broadcast "&c%{_plr}%&b now has %{_data::emoji_stuck_out_tongue:layers::%{_uuid}%::wins}% wins!"
if {_data::emoji_stuck_out_tongue:layers::%{_uuid}%::wins} <= 0:
set {_data::emoji_stuck_out_tongue:layers::%{_uuid}%::wins to 0
else:
send "&c%{_plr}% already has 0 wins, cannot remove more
!" to player

Sorry if this isn't what you meant there wasn't a lot of context and I can't test it rn, if it doesn't work could you provide a little more context and I can try to help you
 
Im trying to make some simple /addwin and /remwin cmds and I'm new to skript. but I can't get this to work. when I add a win it will show I have 1 win (even when I do it multiple times) and when I use /remwin It will skip 0 and show I have -1 win.
here is my skript:


Code:
command /addwin <offlineplayer>:
    permission: event.wins.addwin
    trigger:
        set {_plr} to arg-1
        set {_uuid} to uuid of {_plr}
        if {_data::players::%{_uuid}%::wins} is not set:
            set {_data::players::%{_uuid}%::wins} to 0
        add 1 to {_data::players::%{_uuid}%::wins}
        send "&aAdded a win for %{_plr}%! Total wins: %{_data::players::%{_uuid}%::wins}%" to player
        broadcast "&c%{_plr}%&b now has %{_data::players::%{_uuid}%::wins}% wins!"

command /remwin <offlineplayer>:
    permission: event.wins.remwin
    trigger:
        set {_plr} to arg-1
        set {_uuid} to uuid of {_plr}
        if {_data::players::%{_uuid}%::wins} is not set:
            set {_data::players::%{_uuid}%::wins} to 0
        remove 1 from {_data::players::%{_uuid}%::wins}
        send "&aRemoved a win for %{_plr}%! Total wins: %{_data::players::%{_uuid}%::wins}%" to player
        broadcast "&c%{_plr}%&b now has %{_data::players::%{_uuid}%::wins}% wins!"
This is mostly coded correctly as far as I can tell. It sets it to 0 each time because you are using temporary variables.

{_variable} = temporary, forgotten as soon as the trigger section is complete
{variable} = remembered, can be called upon at any time

Also, list variables require ::* at the end.

This system applies to list variables as well. You used...set {_data::players::"%{_uuid}%"::wins} to 0...which means when this trigger section is completed, the list variable is lost/unset. Therefore, every time you try to recall it, it is being recreated anew and set to 0. Simply remove the _ from the variable name!


You also need to include the %{_uuid}% portion in "quotations" because you are parsing the uuid string into the list. Overall, use this instead...set {data::players::"%{_uuid}%"::wins::*} to 0

There may be other issues but I caught those 3 at a glance.

EDIT: Had to edit this 5 times to fix my own mistakes lol
 
Last edited:
  • Like
Reactions: Death68093