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!
You can always check out skUnity Downloads for downloads and any other information about Skript!
You don't need to parse "%now%" as text because anything within quotes is already text.I'm trying to use '"%now%" parsed as text'
I got this to work:from a database back into the game to use for 'difference between <x> and <y>', I've tried parsing as 'date', 'date and time', 'time', but nothing seems to work
on script load:
set {_now} to "%now%"
send "Now is: '%{_now}%'" to console
set {_date} to {_now} parsed as date
send "Date is: '%{_date}%'" to console
You don't need to parse "%now%" as text because anything within quotes is already text.
I got this to work:
Although, the hours got messed up. No idea why.code_language.skript:on script load: set {_now} to "%now%" send "Now is: '%{_now}%'" to console set {_date} to {_now} parsed as date send "Date is: '%{_date}%'" to console
http://njol.ch/projects/skript/doc/classes/#date
So parse them as dates like I did in my post.hmm, I'm trying to use it for a daily bonus thing. It works fine with variables, but because I'm saving it as "%now%" in the database, then when I load in the data I can't use it as a time to find the "difference between now and X".
https://hastebin.com/itifehehun.sqlSo parse them as dates like I did in my post.
Ah, that makes a lot more sense to use unix time, never though of that. Just tested it and it works great, thanks for your help.I recommend getting SkUtilities and storing unix time in your database instead of a the output of "%now%": https://skunity.com/search?search=unix
Unix time is stored in seconds, so it should be much easier to manage (no date format conversions, etc).
Is there a way to parse the result to unix? Doesn't seem to work if I use the string result to convert to a date format.Ah, that makes a lot more sense to use unix time, never though of that. Just tested it and it works great, thanks for your help.
Actually, I think a 24 hour difference in unix is 86400, so I should be able to just subtract the last bonus from now as unix, (parse them both as integers?) and then check if the difference is > 86400Ah, that makes a lot more sense to use unix time, never though of that. Just tested it and it works great, thanks for your help.
[doublepost=1489113918,1489113498][/doublepost]
Is there a way to parse the result to unix? Doesn't seem to work if I use the string result to convert to a date format.
Is there a way to parse the result to unix? Doesn't seem to work if I use the string result to convert to a date format.
Since the values are in unix time, you can convert them directly into skript timespans (or integers) using:Actually, I think a 24 hour difference in unix is 86400, so I should be able to just subtract the last bonus from now as unix, (parse them both as integers?) and then check if the difference is > 86400
set {_timespan} to "%{_unix-time}% seconds" parsed as timespan
on script load:
# Getting the current time as unix time.
set {_unix-time} to convert date now to unix date
send "<cyan> Now: '%now%' Unix time: '%{_unix-time}%'" to console
# Because unix time is stored as seconds, it can be parsed as a timespan with:
# '<unix time> seconds' parsed as timespan
set {_timespan} to "%{_unix-time}% seconds" parsed as timespan
send "<cyan> Timespan: '%{_timespan}%'" to console
#
# Waiting 5 seconds to compare times...
#
send "<white> Waiting 5 seconds..." to console
wait 5 seconds
# Getting the new current (future) time.
set {_future-unix-time} to convert date now to unix date
send "<light cyan> Now (future): '%now%' Unix time: '%{_future-unix-time}%'" to console
set {_future-timespan} to "%{_future-unix-time}% seconds" parsed as timespan
send "<light cyan> Timespan (future): '%{_future-timespan}%'" to console
# Finding the difference between the old time and the current time:
subtract {_timespan} from {_future-timespan}
send "<light green> Time difference: %{_future-timespan}%" to console
if {_future-timespan} is greater than 2 seconds:
send "<white> Yes!!!" to console
Since the values are in unix time, you can convert them directly into skript timespans (or integers) using:
Like in this example:code_language.skript:set {_timespan} to "%{_unix-time}% seconds" parsed as timespan
code_language.skript:on script load: # Getting the current time as unix time. set {_unix-time} to convert date now to unix date send "<cyan> Now: '%now%' Unix time: '%{_unix-time}%'" to console # Because unix time is stored as seconds, it can be parsed as a timespan with: # '<unix time> seconds' parsed as timespan set {_timespan} to "%{_unix-time}% seconds" parsed as timespan send "<cyan> Timespan: '%{_timespan}%'" to console # # Waiting 5 seconds to compare times... # send "<white> Waiting 5 seconds..." to console wait 5 seconds # Getting the new current (future) time. set {_future-unix-time} to convert date now to unix date send "<light cyan> Now (future): '%now%' Unix time: '%{_future-unix-time}%'" to console set {_future-timespan} to "%{_future-unix-time}% seconds" parsed as timespan send "<light cyan> Timespan (future): '%{_future-timespan}%'" to console # Finding the difference between the old time and the current time: subtract {_timespan} from {_future-timespan} send "<light green> Time difference: %{_future-timespan}%" to console
And because the results are in timespans, you can check if it's "greater than 1 day" or "greater than 30 seconds", etc.
code_language.skript:if {_future-timespan} is greater than 2 seconds: send "<white> Yes!!!" to console
I found out the issue, it was because I changed some stuff and I had to parse the current UNIX into a number to be able to subtract it.It does work, as I've shown with my example.