ATG
Junior Member
Posts: 79
|
Post by ATG on Aug 7, 2020 9:28:05 GMT
I'm testing the trial function. so far, it is working, which no matter how user manipulate the os.date() it will check the Internet for time.
could someone guide me on how to check whether the Internet is connected or not? if not connected , the script will need to exit. the reason for this is to make sure the script check the time online and prevent user playing around the date/time.
result = httpGet("http://google.com")
the result variable returned the message "Following networks are connected. Please check if any important information sent"
but the question is what to compare with the variable result to do if statement? I really have no idea here. please help
time_begin = 1596789557000---- in milliseconds 2020/08/07 time_end = 1596839958000 ---- in milliseconds 2020/08/08
local time_trial_check = (getNetworkTime()) if time_trial_check < time_begin or time_trial_check > time_end then toast("Trial is over") scriptExit() else toast("Trial is valid") end
|
|
|
Post by AnkuLua on Aug 7, 2020 12:19:52 GMT
Use pcall()
local satus, time_trial_check = pcall (getNetworkTime) if (not status) then scriptExit("No internet connection") end
|
|
ATG
Junior Member
Posts: 79
|
Post by ATG on Aug 8, 2020 3:11:50 GMT
thank you! My trial function now is working nicely now
|
|
ATG
Junior Member
Posts: 79
|
Post by ATG on Aug 8, 2020 3:26:34 GMT
Use pcall() local satus, time_trial_check = pcall (getNetworkTime) if (not status) then scriptExit("No internet connection") end I did one more test, when disconnected the Internet and run the script in LDplayer. It returned me a message of >>> java.net.NorouteToHostException: No route to host well, the script didnt run which is good, but scriptExit("No internet connection") didn't execute either. Should I leave it as it is?
|
|
|
Post by AnkuLua on Aug 8, 2020 13:28:03 GMT
Use pcall()
local satus, time_trial_check = pcall (getNetworkTime) if (not status) then scriptExit("No internet connection") end I did one more test, when disconnected the Internet and run the script in LDplayer. It returned me a message of >>> java.net.NorouteToHostException: No route to host well, the script didnt run which is good, but scriptExit("No internet connection") didn't execute either. Should I leave it as it is? AnkuLua Pro2 need the network to check the license before running the script. The message is from Pro2 itself, not from the script. By the way, after checking the script, it should be Use pcall()
local status, time_trial_check = pcall (getNetworkTime) if (not status or time_trial_check == 0) then scriptExit("No internet connection") end
|
|