Skript Problem - Can't figure out how to detect numbers

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

kittkarrkitt

Supporter
Jan 4, 2021
33
0
6
Hi, I need to know how to use numbers as input for a command, for example: "/give [amount] [item]" / "give 20 beef".

I cant seem to figure out the correct way to make it give the message after I have asked if the input is a specific number.

It does not give me an error with the current code, but the correct output
(the messages) after putting in the second argument wont show up either.

Here is my code. I have tried a bunch, but nothing has seemed to work so far.


!!!! SKRIPT:

options:
NoPerm: &4&l(&f&lUK&4&l) >> &4You do not have the needed permissions to use this command!

command /ukrules [<text>] [<number>]:
permission: uk.rules
permission message: {@NoPerm}
trigger:
set {_num} to arg-2
if arg-1 is not set:
message ""
message "&4&l>------(&f&lUK&4&l)------<"
message ""
message "&7/ukrules &c>>&7 ... &7[&clist&7]"
message ""
message "&4&l>------(&f&lUK&4&l)------<"
message ""
if arg-1 is "list":
message ""
message "&4&l>------(&f&lUK&4&l)------<"
message ""
message "&7/ukrules list &c>>&7 ... &7[&cList Number&7]"
message ""
message "&4&l>------(&f&lUK&4&l)------<"
message ""
if {_num} is "1":
message "&4&l>------(&f&lUK&4&l)------<"
message "1"
message "2"
message "3"
message "4"
message "5"
message "6"
message "7"
message "8"
message "9"
message "&4&l>------(&f&lUK&4&l)------<"
if {_num} is "2":
message "&4&l>------(&f&lUK&4&l)------<"
message "1"
message "2"
message "3"
message "4"
message "5"
message "6"
message "7"
message "8"
message "9"
message "&4&l>------(&f&lUK&4&l)------<"
 
Last edited:
[<integer>] :emoji_slight_smile:
Thanks for the reply, but I have tried that before to. I have just tried it again with the current code, and I dont recieve any errors on reload.
But the input also wont show up and just shows the arg-1 is list output.
 
Found your problem, You have to use [<text>] [<text>] and not [<text>] [<integer>]

Code:
options:
    NoPerm: &4&l(&f&lUK&4&l) >> &4You do not have the needed permissions to use this command!

command /ukrules [<text>] [<text>]:
    permission: uk.rules
    permission message: {@NoPerm}   
    trigger:
        set {_num} to arg-2
        if arg-1 is not set:
            message ""
            message "&4&l>------(&f&lUK&4&l)------<"
            message ""
            message "&7/ukrules &c>>&7 ... &7[&clist&7]"
            message ""
            message "&4&l>------(&f&lUK&4&l)------<"
            message ""
        if arg-1 is "list":
            message ""
            message "&4&l>------(&f&lUK&4&l)------<"
            message ""
            message "&7/ukrules list &c>>&7 ... &7[&cList Number&7]"
            message ""
            message "&4&l>------(&f&lUK&4&l)------<"
            message ""
        if {_num} is "1":
            message "&4&l>------(&f&lUK&4&l)------<"
            message "1"
            message "2"
            message "3"
            message "4"
            message "5"
            message "6"
            message "7"
            message "8"
            message "9"
            message "&4&l>------(&f&lUK&4&l)------<"
        if {_num} is "2":
            message "&4&l>------(&f&lUK&4&l)------<"
            message "1"
            message "2"
            message "3"
            message "4"
            message "5"
            message "6"
            message "7"
            message "8"
            message "9"
            message "&4&l>------(&f&lUK&4&l)------<"

remember to put your code in a box :^)
upload_2021-1-4_11-53-4.png


upload_2021-1-4_11-54-31.png
 

Attachments

  • upload_2021-1-4_11-54-25.png
    upload_2021-1-4_11-54-25.png
    6.2 KB · Views: 98
Found your problem, You have to use [<text>] [<text>] and not [<text>] [<integer>]

Code:
options:
    NoPerm: &4&l(&f&lUK&4&l) >> &4You do not have the needed permissions to use this command!

command /ukrules [<text>] [<text>]:
    permission: uk.rules
    permission message: {@NoPerm} 
    trigger:
        set {_num} to arg-2
        if arg-1 is not set:
            message ""
            message "&4&l>------(&f&lUK&4&l)------<"
            message ""
            message "&7/ukrules &c>>&7 ... &7[&clist&7]"
            message ""
            message "&4&l>------(&f&lUK&4&l)------<"
            message ""
        if arg-1 is "list":
            message ""
            message "&4&l>------(&f&lUK&4&l)------<"
            message ""
            message "&7/ukrules list &c>>&7 ... &7[&cList Number&7]"
            message ""
            message "&4&l>------(&f&lUK&4&l)------<"
            message ""
        if {_num} is "1":
            message "&4&l>------(&f&lUK&4&l)------<"
            message "1"
            message "2"
            message "3"
            message "4"
            message "5"
            message "6"
            message "7"
            message "8"
            message "9"
            message "&4&l>------(&f&lUK&4&l)------<"
        if {_num} is "2":
            message "&4&l>------(&f&lUK&4&l)------<"
            message "1"
            message "2"
            message "3"
            message "4"
            message "5"
            message "6"
            message "7"
            message "8"
            message "9"
            message "&4&l>------(&f&lUK&4&l)------<"

remember to put your code in a box :^)
View attachment 5618

View attachment 5620
Yes this has worked for me! Thank you very much. I had [<text>] [<text>] before, but might have had something in the rest of the code different at that point. Thank you very much.

and yes I will put my code in a box from now on :emoji_slight_smile:
[doublepost=1609754793,1609754514][/doublepost]
Found your problem, You have to use [<text>] [<text>] and not [<text>] [<integer>]

Code:
options:
    NoPerm: &4&l(&f&lUK&4&l) >> &4You do not have the needed permissions to use this command!

command /ukrules [<text>] [<text>]:
    permission: uk.rules
    permission message: {@NoPerm} 
    trigger:
        set {_num} to arg-2
        if arg-1 is not set:
            message ""
            message "&4&l>------(&f&lUK&4&l)------<"
            message ""
            message "&7/ukrules &c>>&7 ... &7[&clist&7]"
            message ""
            message "&4&l>------(&f&lUK&4&l)------<"
            message ""
        if arg-1 is "list":
            message ""
            message "&4&l>------(&f&lUK&4&l)------<"
            message ""
            message "&7/ukrules list &c>>&7 ... &7[&cList Number&7]"
            message ""
            message "&4&l>------(&f&lUK&4&l)------<"
            message ""
        if {_num} is "1":
            message "&4&l>------(&f&lUK&4&l)------<"
            message "1"
            message "2"
            message "3"
            message "4"
            message "5"
            message "6"
            message "7"
            message "8"
            message "9"
            message "&4&l>------(&f&lUK&4&l)------<"
        if {_num} is "2":
            message "&4&l>------(&f&lUK&4&l)------<"
            message "1"
            message "2"
            message "3"
            message "4"
            message "5"
            message "6"
            message "7"
            message "8"
            message "9"
            message "&4&l>------(&f&lUK&4&l)------<"

remember to put your code in a box :^)
View attachment 5618

View attachment 5620
Wait hold up, the same thing is happening as in my other thread. It is showing both the "if arg-1 is "list":" and "if {_num} is "1":" outputs! (same with is "2")

upload_2021-1-4_11-6-13.png


The red lines show what output should not be there again.
 
Thats because you told it to show those lines lol
Yes, when you only use arg-1 behind the original command, but if you add the arg-2 input, it should overwrite that right? That is what happens in the first part of my other code, which is also the thing that should happen.

It should only give that specific output when I execute the command "/ukrules list", and not when I execute the command "/ukrules list [number input]"
 
Using square brackets([ ]) just means that the extra arguments aren't vital. Therefore you won't necessarily need to put your code in squares, unless the other argument(s) are specifically required.

Code:
#Example:

command /stats [<player>]:
 trigger:
  if arg-1 is set:
   send {stats.%arg-1%}
  else:
   send {stats.%player%}

command /gamemode <integer>:
 trigger:
  if arg-1 is set:
   set gamemode of player to arg-1
  else:
   send "Please specify a gamemode"
 
Using square brackets([ ]) just means that the extra arguments aren't vital. Therefore you won't necessarily need to put your code in squares, unless the other argument(s) are specifically required.

Code:
#Example:

command /stats [<player>]:
 trigger:
  if arg-1 is set:
   send {stats.%arg-1%}
  else:
   send {stats.%player%}

command /gamemode <integer>:
 trigger:
  if arg-1 is set:
   set gamemode of player to arg-1
  else:
   send "Please specify a gamemode"

Removing the [] brackets from any one of the arguments in the original command (command /??? [<text>] [<text>]: ) would result in the command not working at all and outputting the usage of the command, even when its not even in the code

upload_2021-1-4_14-36-18.png


I have a second thread with a simular problem as the one you replied to. Maybe you could test it out for yourself aswell, so you could experience what my problem is.
 
Removing the [] brackets from any one of the arguments in the original command (command /??? [<text>] [<text>]: ) would result in the command not working at all and outputting the usage of the command, even when its not even in the code

View attachment 5623

I have a second thread with a simular problem as the one you replied to. Maybe you could test it out for yourself aswell, so you could experience what my problem is.

In your case it would, yes. I was simply trying to explain what square brackets do in general. Example:

Code:
 #Adding square brackets, the command would return <none>. We want players only able to use the command if they specify an argument. Example:

command /hi <text>:
    trigger:
        send "%arg-1%"

Screen-Shot-2021-01-04-at-14-49-57.png
 
In your case it would, yes. I was simply trying to explain what the square brackets do in general.

Code:
 #Adding square brackets, the command would return <none>. We want players only able to use the command if they specify an argument. Example:

command /hi <text>:
    trigger:
        send "%arg-1%"

Screen-Shot-2021-01-04-at-14-49-57.png

How is it that way for me then? What makes my code fail like that if im missing those [] brackets?
 
Pardon me if I misunderstood you, but it seemed to me like you were gonna use square brackets on all your commands in the future:

and yes I will put my code in a box from now on :emoji_slight_smile:
 
Pardon me if I misunderstood you, but it seemed to me like you were gonna use square brackets on all your commands in the future:
No, that was about the threads on this websites, and if I need help, I would put them in a code box that you can use in your messagee
Code:
command <text>:
    trigger:
        message "Like this"
 
No, that was about the threads on this websites, and if I need help, I would put them in a code box that you can use in your messagee
Code:
command <text>:
    trigger:
        message "Like this"

My bad! Mark you thread as solved, if you're satisfied :emoji_grinning:
 
Status
Not open for further replies.