Hello everyone!
I think this request will not be difficult to do.
What I need is a plugin / line of code, which if the player is connected to the internet, he will earn X Gold per Minute, then for example: every minute I will earn 20 of Gold because my internet is connected:
If the internet is on, every 1 minute earns an x amount of gold.
If the internet is turned off, the player will not win anything.
[It will be an incentive to play with internet connected and player and earn gold and show the developer ad]
If it is some line of code that tells me where to put it, I have no scripting experience.
Sorry for English, I'm using google translate so there may be errors in the request.
navigator.onLine only works if the computer doesnt have a virtual machine installed. just a small caveat, but one to note. 🙂
do you have a server on the net?
as said above any pure local check for the internet can be circumvented with virtual machines or a few other ways.
the only way to check for a guaranteed connection is to check for something you placed on the internet, and that means you'll need a server or at minimum a hosted website - which usually has monthly costs.
You have to contact a server that has CORS enabled. else the reply is an error. 🙂
Yea forgot to mention that you need CORS enabled, I actually forgot myself, it's been so long since I've had to do net stuff. Well not a huge deal if you your own server, other than that I'm not sure what you can do.
I tested it on my computer and it worked, but the goal of these plugins is Android, I will test and see if it works on Android. I used that first code.
Ill certainly look into digital ocean and firebase..
ATM I use heroku, its certainly not free anymore. Their free plan turns your server off after 30 minutes of inactivty, and it has like, a 20 second restart time.. This causes major delays in api requests, most well programmed ones would likely timeout.It also has to sleep 8 hours a day im sure.
Heroku costs $7 per month, per dyno, if you want your app to run continuously, and have ssl encryption. It then costs an absolute fortune if you want to have any kind of database integration. I've been looking for a good alternative 😀
Yikes! I never knew about Heroku changing so much, it used to be half decent. I used DigitalOcean and I really enjoyed it, they give you a server with whatever OS you want, I chose Ubuntu due to familiarity and it was rather easy to get setup, they have a ton of tutorials and guides too.
Firebase I only played around with, I have no idea what the usage limits are but it too is easy to get get started and they have database, cloud services, and authentication straight out the box, makes things easy for app developers. Happy hunting!
Yea, heroku used to be decent, as did openshift, but the market seems to have changed alot in the past few years and they can get away with offering total crap free plans 😀
I may actually test out DigitalOcean. I do remember looking into them and going with heroku because of their transfer limit. From the way it seems, they basically give you a private vm that you can access via the cloud? Its quite interesting either way. Definitely need to check if out some more 😀