Posted: Thu Aug 06, 2020 10:36 am Post subject: Need Help with database
I wanna make user count for my cheat engine trainer online users would be cool too. Can someone tell me how I can do that I dont need login or register forms just usercount
Look for some online counter script that can tell you how many users are in your website or blog, use getInternet().getURL('your website') and parse results, that is assuming the counter script is not javascript based, but rather like included php script.
here's an example without using site which should suit your needs, hopefully won't bother the service provider.
Code:
local gi = getInternet();
t = createTimer();
t.interval = 10000 -- every 10 secs
t.onTimer = function(sender)
local response = gi.getURL('http://freehostedscripts.net/ocounter.php?site=5644621&e1=Online%20User&e2=Online%20Users&r=0&m=0&wh=1024%20x%20768&a=1&pn=http://somenonexistent.site.com');
if (response) then
local users = response:match('>(%d+ Online Users?)</a>');
print(users);
end
end
_________________
I'm rusty and getting older, help me re-learn lua.
Joined: 25 Jan 2006 Posts: 8585 Location: 127.0.0.1
Posted: Sun Aug 09, 2020 8:23 pm Post subject:
If you want something accurate you will need to track sessions in some manner. No login/auth would be required for this. Think of it as a basic analytics setup where you'd want to track usage/interactions with your trainer.
Create a website that has some API exposed, for this you'd only really need 1 endpoint and then some server-sided processing/cron job to deal with stale information depending on how you store it.
When the user starts the trainer, it makes a connection to the above URL. (For better stats, ideally you'd send some POST data with it, mainly the trainer id to track just that trainer specifically if you want to do this for multiple programs.) When that connection is made, the server would create a session with their IP, trainer id and any extra data you want to collect/link to their session. Give the session a TTL (time to live) of like 2-10 minutes, and a cron job that will auto-delete any stale sessions that have not been updated. (ie. if storing in a SQL database, just have it look for expired stuff based on a timestamp.)
While the trainer is running, have it connect to 'https://yourwebsite.com/api/heartbeat' every minute or so to refresh their session time. (In this case, the server would first look for an existing session matching their IP and other POST data like the trainer id. If a session exists, update the timestamp. If not, make a new session.)
You can have the API return the current count of users that are connecting to the API with the same trainer information to do it all in a single endpoint.
SQL wise, you could do something as basic as a table with:
- The users IP
- The timestamp the session was created.
- The timestamp the session was last updated.
- The unique trainer id given to the trainer.
Then you can just do a simple SELECT COUNT(*) query to pull a total of people using a given trainer based on its id and a valid timestamp.
The cron job can cleanup stale stuff every ~10min or so depending on how urgent your database grows etc. _________________
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum You cannot attach files in this forum You can download files in this forum