skrayfall: send "" to arg-2 for arg-3 seconds

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

ililedie

New Member
Feb 19, 2021
7
0
1
have this code and in the chat i receive a condition recognition error, I think it is due to the way I point out the arguments, can someone help me by changing what I did a little? specifically, I need the title to be able to be saved and retained when reloading/rebooting the server [cant understand this condition "send title"", already have skrayfall and its workin with "on join:"]
Code:
command /aw <text> <text> <integer>:
  trigger:
    if arg-1 is "subtitle":
      set {csub} to arg-2
    if arg-1 is "title":
      set {ctit} to arg-2
    if arg-1 is "send":
      if arg-2 is set:
        send title {ctit} to arg-2 for arg-3 seconds
        send subtitle {csub} to arg-2 for arg-3 seconds
      else:
        send "Needs a username in 2nd arg" to player
 
have this code and in the chat i receive a condition recognition error, I think it is due to the way I point out the arguments, can someone help me by changing what I did a little? specifically, I need the title to be able to be saved and retained when reloading/rebooting the server [cant understand this condition "send title"", already have skrayfall and its workin with "on join:"]
Code:
command /aw <text> <text> <integer>:
  trigger:
    if arg-1 is "subtitle":
      set {csub} to arg-2
    if arg-1 is "title":
      set {ctit} to arg-2
    if arg-1 is "send":
      if arg-2 is set:
        send title {ctit} to arg-2 for arg-3 seconds
        send subtitle {csub} to arg-2 for arg-3 seconds
      else:
        send "Needs a username in 2nd arg" to player
if i had to guess it's because of the 2nd argument, you can't send a title to "text" try changing that to player
 
Two things I've found:
1. Since arg-2 is a text, you'll need to specify that you want arg-1 to be handled like a player.
2. When setting (or sending) something for a certain period of time, it requires a timespan. Due to how Skript works, even though arg-3 is an integer, it's not a usable value for a timespan.

You can fix these by using the parse expression. When using arg-2, it's pretty straight forward as it's already a text. Adding "parsed as player" to the end of arg-2 ("arg-2 parsed as player") will fix the first problem.
The timespan requires a bit more, but it's still easy. You first need to make arg-3 a text (contradicts itself, doesn't it), but that doesn't mean that you should change the command to require a text though. You could end up sending a title for "text instead of an integer amount of time" seconds. To make arg-3 a text, you just surround it in % symbols and then surround '%arg-3%' with " symbols (now it should look like this, include the quote marks: "%arg-3%"). Now to parse it as a timespan, you'll need to add the "seconds" in that text too (it should now look like: "%arg-3% seconds"). Finally, you can add the "parsed as timespan" at the end ("%arg-3% seconds" parsed as timespan). I hope this helps, reply if you have any problems or concerns (or if you just want the updated lines)!
 
Status
Not open for further replies.