Solved Issue on deducting on date and 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 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.

yuetau

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

---
Full Code:
Code:
    if {TimeExpire::%player's UUID%} is not set:
      send a "get" request to "http://localhost/api2.php?UUID=%player's UUID%"
      set {_response} to the last http response
      set {_body} to {_response}'s body
      copy json {_body} to {_output::*}
      if {_output::TimeLeft} is set:
        set {TimeExpire::%player's UUID%} to now
        add {_output::TimeLeft} seconds to {TimeExpire::%player's UUID%}
        broadcast "Success"
        #kick the player due to "Sorry"
    else if {TimeExpire::%player's UUID%} is set:
      if {TimeExpire::%player's UUID%} is greater than now:
        broadcast "Success"
        #kick the player due to "Sorry"
      else:
        clear {TimeExpire::%player's UUID%}
Errors on Reload:
Code:
[00:17:59 ERROR]: '{_output::TimeLeft} seconds' can't be added to {TimeExpire::%the UUID of the player%} because the former is not an object (GlobleBan.sk, line 32: add {_output::TimeLeft} seconds to {TimeExpire::%player's UUID%}')
Addons using (including versions):
Reqn (v1.2.3), Skript-JSON (v1.0.0)

Additional Infomation:
The API will return a string of JSON like below
Code:
{"UUID":"XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX","Warnings":"0","TimeLeft":83289}
"TimeLeft" is the second calculated in backend needed to ban for how many second more.
If there is no record, it will return
Code:
{"UUID":"XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX","Warnings":"0"}

Troubleshooting:

Have you tried searching the docs? Yes
Have you tried searching the forums? Yes
What other methods have you tried to fix it? I found a post suggest to phrase the variable to integer to be possible to be calculated, but the post doesn't suggest a way to be implement in my case.
https://forums.skunity.com/threads/issues-with-subtracting-from-variables.3272/
 
Skript Version: Skript 2.5-alpha2 (Github)

---
Full Code:
Code:
    if {TimeExpire::%player's UUID%} is not set:
      send a "get" request to "http://localhost/api2.php?UUID=%player's UUID%"
      set {_response} to the last http response
      set {_body} to {_response}'s body
      copy json {_body} to {_output::*}
      if {_output::TimeLeft} is set:
        set {TimeExpire::%player's UUID%} to now
        add {_output::TimeLeft} seconds to {TimeExpire::%player's UUID%}
        broadcast "Success"
        #kick the player due to "Sorry"
    else if {TimeExpire::%player's UUID%} is set:
      if {TimeExpire::%player's UUID%} is greater than now:
        broadcast "Success"
        #kick the player due to "Sorry"
      else:
        clear {TimeExpire::%player's UUID%}
Errors on Reload:
Code:
[00:17:59 ERROR]: '{_output::TimeLeft} seconds' can't be added to {TimeExpire::%the UUID of the player%} because the former is not an object (GlobleBan.sk, line 32: add {_output::TimeLeft} seconds to {TimeExpire::%player's UUID%}')
Addons using (including versions):
Reqn (v1.2.3), Skript-JSON (v1.0.0)

Additional Infomation:
The API will return a string of JSON like below
Code:
{"UUID":"XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX","Warnings":"0","TimeLeft":83289}
"TimeLeft" is the second calculated in backend needed to ban for how many second more.
If there is no record, it will return
Code:
{"UUID":"XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX","Warnings":"0"}

Troubleshooting:

Have you tried searching the docs? Yes
Have you tried searching the forums? Yes
What other methods have you tried to fix it? I found a post suggest to phrase the variable to integer to be possible to be calculated, but the post doesn't suggest a way to be implement in my case.
https://forums.skunity.com/threads/issues-with-subtracting-from-variables.3272/

Code:
add "%{_output::TimeLeft}% seconds" parsed as a time span to {TimeExpire::%player's UUID%}
 
  • Like
Reactions: yuetau
Status
Not open for further replies.