Welcome to Open Carnage

A resource for Halo Custom Edition and MCC modding, with unique means of rewarding content creation and support. Have a wander to see why we're worth the time! - EST. 2012

mouseboyx

Webserver Statistics Logging

24 posts in this topic

I come from a background in web development so I was considering extending sapp into web development.

 

Rather than have a file that is updated on the server with lua, I'm thinking I could use the http request to send statistics to a website.  The website would sort the stats like kills, deaths, and k/d ratio for each game, and keep data since the script has begun logging.  Has someone already made some sort of server statistics related to kills and deaths before?  I'm at the point where I set up a way for the server to have a list of requests and they could be like  https://somesite.com/halo.php?killer=playerName1&victim=playerName2&killerip=x.x.x.x&victimip=x.x.x.x&updatekey=912ec803b2ce49e4a541068d495ab570  The update key could be anything giving it a bit of extra security so people can't query the server by themselves messing up the logging. 

 

It uses the async ability of the http request when the game starts if there are requests waiting it does them once a second, unless there are none waiting, which there would be one added to the array each time someone kills another player.  When the game ends it waits for the last request to come in then stops the looping timer so timers don't get called multiple times when a game starts.  Even if the game ends with an explosion that kills 8 players I think it would still be able to keep up.  If not the timer could be faster.

 

I'm thinking the website could put the data in a mysql table so that if the name/ip combo exists it does nothing, if not it inserts the name/ip combo with an id generated by the database.  And keep track of the current game with a number, like the first time it's 1 then 2 and so on.  And have a table that is something like  | game_id | player_id | victim_id | kill_count |  it could be done with the standard CRUD rules to make everything right.  Then it would be interesting to query the database, find all kills or deaths of a specific player.  Or all kills of one player against another, or do a k/d ratio over one game, multiple games, or the life of the logging.

 

It may be able to be extended to multiple servers but making it public would impose a risk on the data, because they could send whatever to the webserver.  I guess if you sorted it into different servers you could delete servers or sort servers that seem to have false information.

 

tldr;

Send kill and death information to a web server so it can track and sort the information. 

 

I'm going to work on this for a while or from time to time and see if it's actually doable, I think it is, but feel free to tell me I'm crazy or something.

Edited by mouseboyx

Share this post


Link to post
Share on other sites

Tiddy-bits:

1 hour ago, Enclusion said:

would definitely use this

Great to know there's someone interested.  I would release it with all the code to be able to configure and run it on your own web hosting and halo server.  I was considering building in some type of invitation request where anyone who hosts it can allow other halo server owners to use the site by generating a key that would pair with a given halo server ip address.

Tucker933 and Enclusion like this

Share this post


Link to post
Share on other sites
15 hours ago, mouseboyx said:

Great to know there's someone interested.  I would release it with all the code to be able to configure and run it on your own web hosting and halo server.  I was considering building in some type of invitation request where anyone who hosts it can allow other halo server owners to use the site by generating a key that would pair with a given halo server ip address.

Would be cool if people could just host their own site and you could choose to connect to others, federation sort of deal. If you start working on this a public repository would be great. 

Share this post


Link to post
Share on other sites
On 1/15/2021 at 9:48 AM, Enclusion said:

Would be cool if people could just host their own site and you could choose to connect to others, federation sort of deal. If you start working on this a public repository would be great. 

Yes, that is what I would like, anyone can host and the host decides who can connect their halo server, otherwise I don't know how to control fake information being sent.  Setting up a captcha and email verification to get a key from a host isn't good enough, it has to be done with trust and halo server owners have to be on the honor system.  I guess I could try to put in a way so there's no middle man for getting a key from someone hosting, but I can't think of a way to do it.

 

I'm a noob when it comes to git, I did set up a repo no github but it's only the files I've been working on and no structure or install.  https://github.com/mouseboyx/halo-sapp-webserver-stats  I added a few comments to help.

 

Edit:

Things are going well on the progress, I'm trying to do at least one commit each day, the admin interface is going well.  For admins, they can add servers identified by a key, and edit the translations from damage tag paths to human readable weapon names, as well as add new custom damage tag path translations for custom or modded maps.  I've uploaded some screenshots of what I have so far

https://mouseboyx.xyz/halo_screenshots/

The part that inserts the information into the database when halo sends it to the web server still needs some work, and I haven't started the part of the site that allows for public queries of the data depending on all sorts of parameters like: find all deaths of specific player/ip combo, find most killed by, find most killed player by another player, total deaths server wide, organize by games and when the game started etc...  Also adding in scoring like the players last known score whenever a score happens with 'EVENT_SCORE'

Edited by mouseboyx
Progress Happening
Enclusion likes this

Share this post


Link to post
Share on other sites

New Development:

 

I've gotten to a point where I have a live preview (which is by no means a complete final product) https://mouseboyx.xyz/halo-stats/index.php  Writing those mysql queries is sort of taxing so I'm making incremental steps adding in features day by day.  I already have a few changes that need to be made for things to actually work when it is released.  But this is a testing ground for changes that arise from progressing the work on it.

Share this post


Link to post
Share on other sites
20 hours ago, Enclusion said:

Does the site query the database every time it's loaded or are you doing caching of some sort to occasionally serve updated info? 

No caching so far, but I would imagine if there are lots of rows added over time it might be a good idea to cache older data so that older known data doesn't bog down the whole process combined with newer.  I've actually never implemented something like caching before.  My 1 core vps that it's running on doesn't even hit 4% cpu usage with the current data but there's only about 5.5k rows in the killed_by table as of now.  Some of the queries could be altered for better efficiency, I'm being kind of lazy about working on it and improving it all the time.
Edit:
There's about 10k rows in the killed_by_weapon table though, over time that's going to get massive, because that's only 82 games across 3 servers.

Maybe when a new game starts all of the finer details about each specific player in the last game can get cached in a table dedicated for that, when viewing the specifics for a particular game that took place I don't know if it makes sense to cache that because the details will only be pulled out when someone views the page for that specific game.  I guess like a table that caches the same stats as the index page only game by game would work though.  Otherwise it's joining quite a few tables to pull out that information all from a root table that contains all kills with a victim, killer, server and game id.  At least the number of times each player kills another isn't it's own row there's a times column so if the same person kills another same person it will only increment the times, but also add in what weapon in another table if that changed again with a times column.

 

5 hours ago, Sunstriker7 said:

New001 is fuckin' slaying it with that 75 K/D

I'm almost positive he was killing an inactive though the whole game, which does skew the data...  Probably have to get creative for weeding out circumstances like that.

Edited by mouseboyx
Enclusion likes this

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
  • Recently Browsing   0 members

    No registered users viewing this page.