Issue on UNIX Time

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

Status
Not open for further replies.

yuetau

New Member
Mar 13, 2020
6
1
0
Skript Version: Skript 2.5-alpha2 (Github)

---
Full Code:
Code:
command /tempban <offlineplayer> <text>:
  trigger:
    set {_sections::*} to arg-2 split at "~"
    if {LocalTimeExpire::%arg-1's UUID%} is not set:
      set {LocalTimeExpire::%arg-1's UUID%} to now
      add {_sections::1} parsed as a time span to {LocalTimeExpire::%arg-1's UUID%}
      set {_UNIXTime} to unix timestamp of {LocalTimeExpire::%arg-1's UUID%}

Errors on Reload:
None
Addons using (including versions):
Reqn (v1.2.3), Skript-JSON (v1.0.0)

Additional Infomation:
{_sections::1} should be a timespan in text format

Variable {_UNIXTime} return <none>
Troubleshooting:

Have you tried searching the docs? Yes
Have you tried searching the forums? Yes
What other methods have you tried to fix it? Try to change it to <timespan> <text> and it didn't work so I change to <text>
 
First, variables with "_" in front is a temporary variable, which will be deleted automatically after all the codes in the command finished running
Like {_test} is a temp. variable, {abc} is not.

If you need to retrieve a time in {_UNIXTime}, I think you should try this:
1. set {LocalTimeExpire::%arg-1's UUID%} to unix timestamp of now, rather than set it to now, as it will be difficult to parse or do calculations
2. parse {_sections::1} as a number instead, then add it to {LocalTimeExpire::%arg-1's UUID%}
3. retrieve the time using the unix timestamp afterwards.
 
  • Like
Reactions: yuetau
Code:
command /tempban <offlineplayer> <timespan>:
  aliases: /tb
  description: To let the Local Ban Hummer flown for some time.
  permission: {@TempBan_Perm}
  trigger:
    if {LocalTimeExpire::%arg-1's UUID%} is not set:
      set {_msg} to {@TempBan_Local_MSG}
      set {LocalTimeExpire::%arg-1's UUID%} to unix timestamp of now
      add "%arg-2%" parsed as number to {LocalTimeExpire::%arg-1's UUID%}
      send a "post" request to "{@Host}" with the headers "Content-Type: application/json" and the body "{'Key':'{@Key}','Action':'BAN','Preformer':'%player's UUID%','Target':'%arg-1's UUID%','Expire':'%{LocalTimeExpire::%arg-1's UUID%}%'}"
I follow your suggestion and edit the code.
But it seem that {LocalTimeExpire::%arg-1's UUID%} still return <none>
 
Code:
command /tempban <offlineplayer> <timespan>:
  aliases: /tb
  description: To let the Local Ban Hummer flown for some time.
  permission: {@TempBan_Perm}
  trigger:
    if {LocalTimeExpire::%arg-1's UUID%} is not set:
      set {_msg} to {@TempBan_Local_MSG}
      set {LocalTimeExpire::%arg-1's UUID%} to unix timestamp of now
      add "%arg-2%" parsed as number to {LocalTimeExpire::%arg-1's UUID%}
      send a "post" request to "{@Host}" with the headers "Content-Type: application/json" and the body "{'Key':'{@Key}','Action':'BAN','Preformer':'%player's UUID%','Target':'%arg-1's UUID%','Expire':'%{LocalTimeExpire::%arg-1's UUID%}%'}"
I follow your suggestion and edit the code.
But it seem that {LocalTimeExpire::%arg-1's UUID%} still return <none>
So as you add arg-2 to the variable, you need to type the time in second in arg-2
Did you try that?
 
Skript Version: Skript 2.5-alpha2 (Github)

---
Full Code:
Code:
command /tempban <offlineplayer> <text>:
  trigger:
    set {_sections::*} to arg-2 split at "~"
    if {LocalTimeExpire::%arg-1's UUID%} is not set:
      set {LocalTimeExpire::%arg-1's UUID%} to now
      add {_sections::1} parsed as a time span to {LocalTimeExpire::%arg-1's UUID%}
      set {_UNIXTime} to unix timestamp of {LocalTimeExpire::%arg-1's UUID%}

Errors on Reload:
None
Addons using (including versions):
Reqn (v1.2.3), Skript-JSON (v1.0.0)

Additional Infomation:
{_sections::1} should be a timespan in text format

Variable {_UNIXTime} return <none>
Troubleshooting:

Have you tried searching the docs? Yes
Have you tried searching the forums? Yes
What other methods have you tried to fix it? Try to change it to <timespan> <text> and it didn't work so I change to <text>

what is the command ur running?
 
Oh I originally thought that type something after ~ for the remark.
But As for the renewed code
Code:
command /tempban <offlineplayer> <timespan>:
  aliases: /tb
  description: To let the Local Ban Hummer flown for some time.
  permission: {@TempBan_Perm}
  trigger:
    if {LocalTimeExpire::%arg-1's UUID%} is not set:
      set {_msg} to {@TempBan_Local_MSG}
      set {LocalTimeExpire::%arg-1's UUID%} to unix timestamp of now
      add "%arg-2%" parsed as number to {LocalTimeExpire::%arg-1's UUID%}
      send a "post" request to "{@Host}" with the headers "Content-Type: application/json" and the body "{'Key':'{@Key}','Action':'BAN','Preformer':'%player's UUID%','Target':'%arg-1's UUID%','Expire':'%{LocalTimeExpire::%arg-1's UUID%}%'}"
I follow your suggestion and edit the code.
But it seem that {LocalTimeExpire::%arg-1's UUID%} still return <none>
The args change to <timespan> so I stop that implementation.
 
Status
Not open for further replies.