1. 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!

  2. LOOKING FOR A VERSION OF SKRIPT?

    You can always check out our Wiki for downloads and any other information about Skript!

Dismiss Notice
This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

on command with arguments

Discussion in 'Skript' started by FireRoz, Dec 17, 2020.

Thread Status:
Not open for further replies.
  1. FireRoz

    FireRoz Active Member

    Joined:
    May 28, 2020
    Messages:
    134
    Likes Received:
    6
    hi, I know this is a stupid request and is not a frequently used in Skript. Though, I am trying to make it that when I vanish, my name tag will change to [V] FireRoz The problem is, if you do /vanish <other player>, it won't do it as I didn't define arguments.
    Here's my code
    Code (Text):
    1. on join:
    2.   player has permission "sv.see"
    3.   set player's nametag to "&7[V] %player%"
    4.   set {v.%player%} to true
    5.  
    6. on command "/v" or "/vanish":
    7.   if {v.%player%} is not set:
    8.     set {v.%player%} to true
    9.     set player's nametag to "&7[V] %player%"
    10.     stop trigger
    11.     stop
    12.    
    13.   if {v.%player%} is set:
    14.     set {v.%player%} to false
    15.     clear {v.%player%}
    16.     reset player's nametag
    17.     stop
    18.    
    19. on command "/vanish on" or "/v on":
    20.   set {v.%player%} to true
    21.   set player's nametag to "&7[V] %player%"
    22.  
    23. on command "/v off" or "/vanish off":
    24.   set {v.%player%} to false
    25.   reset player's nametag
    Thank you for your time.
     
  2. Marc

    Marc Active Member

    Joined:
    Nov 27, 2020
    Messages:
    94
    Likes Received:
    0
    for your command, try using arg-1 instead of player im quite confused and I dont see

    Code (Text):
    1. command /v:
    2.     blah blah arg-1 blah
     
  3. FireRoz

    FireRoz Active Member

    Joined:
    May 28, 2020
    Messages:
    134
    Likes Received:
    6
    when I use "on command" it says
    '"test to' is not a type.
    and i want it to execute a command that already exists in supervanish, not create a new command.
    thank you for your time
     
  4. MusicManSK

    MusicManSK Active Member

    Joined:
    Nov 30, 2017
    Messages:
    232
    Likes Received:
    11
    You have to make custom command arguments parser and overload the command like so:
    Code (Text):
    1. on join:
    2.   player has permission "sv.see"
    3.   set player's nametag to "&7[V] %player%"
    4.   set {v.%player%} to true
    5.  
    6. on command "/v" or "/vanish":
    7.   #Parse command arguments
    8.   set {_command} to full command
    9.   set {_args::*} to {_command} split at " "
    10.   set {_player_arg} to "%{_args::2}%" parsed as player
    11.  
    12.   #Command overloading
    13.   set {_player} to player
    14.   if {_player_arg} is set:
    15.     set {_player} to {_player_arg}
    16.  
    17.   #Use `{_player}` instead of `player`
    18.   if {v.%{_player}%} is not set:
    19.     set {v.%{_player}%} to true
    20.     set player's nametag to "&7[V] %player%"
    21.     stop trigger
    22.     stop
    23.  
    24.   if {v.%{_player}%} is set:
    25.     set {v.%{_player}%} to false
    26.     clear {v.%{_player}%}
    27.     reset player's nametag
    28.     stop
    29.  
    30. on command "/vanish on" or "/v on":
    31.   set {v.%player%} to true
    32.   set player's nametag to "&7[V] %player%"
    33.  
    34. on command "/v off" or "/vanish off":
    35.   set {v.%player%} to false
    36.   reset player's nametag
     
  5. acai

    acai Active Member

    Joined:
    Oct 23, 2020
    Messages:
    89
    Likes Received:
    1
    Great, but the syntax is "command /v:" and not "on command /v:".
     
  6. Killerz1243

    Killerz1243 Active Member

    Joined:
    Oct 31, 2019
    Messages:
    78
    Likes Received:
    7
  7. MusicManSK

    MusicManSK Active Member

    Joined:
    Nov 30, 2017
    Messages:
    232
    Likes Received:
    11
    Look what @FireRoz said:
    Yes, this is exactly what he requested.
     
Thread Status:
Not open for further replies.

Share This Page

Loading...