AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Saving player scores and weapon stats before map change (https://forums.alliedmods.net/showthread.php?t=340258)

ghostdlr 11-05-2022 14:46

Saving player scores and weapon stats before map change
 
I want to save the full statistics for each match played on the server in a database, as a json that I can load and display on a web page later. (I can handle this part myself)

I want to track as much information as possible:
- basic stats like: kills, deaths , headshots etc
- individual weapon stats

Players come and go, so I also want to save the stats for the players that played only a few rounds and left. (players that were not online at the map change)

What is the best approach for doing this?

Can I detect when the map changes? Do I have time to do a POST request to my web server?
Should I keep all the statistics in a giant array?

How do other plugins do this? (hlstats, psychostats)

Spirit_12 11-05-2022 20:11

Re: Saving player scores and weapon stats before map change
 
Never used Psychostats, but HLSTATSX uses a separate demon. It is a 3 step process.
  1. Game server generates the logs based on the events and then sends them to a dedicated IP where your demon is running.
  2. The stats processing demon parses the data from the logs and transposes the data into an SQL database.
  3. The front end uses the database and outputs the information.

I like this method as sending data directly to the database may lead to game server performance degradation. On top all servers create logs which already keep track of kills and what not, so its convenient to use it rather than re-implementing the whole tracker.

Hope that helps.

ghostdlr 11-05-2022 20:22

Re: Saving player scores and weapon stats before map change
 
I want to do the same thing like HLSTATSX.

Either send data to a TCP server or do a HTTP POST to a web page.

Where can I find the HLSTATS plugin to see how they implemented this?

ghostdlr 11-06-2022 05:02

Re: Saving player scores and weapon stats before map change
 
Quote:

Originally Posted by Spirit_12 (Post 2792220)
Never used Psychostats, but HLSTATSX uses a separate demon. It is a 3 step process.
  1. Game server generates the logs based on the events and then sends them to a dedicated IP where your demon is running.
  2. The stats processing demon parses the data from the logs and transposes the data into an SQL database.
  3. The front end uses the database and outputs the information.

I like this method as sending data directly to the database may lead to game server performance degradation. On top all servers create logs which already keep track of kills and what not, so its convenient to use it rather than re-implementing the whole tracker.

Hope that helps.

What kind of events does it use? And how can I get all the data from them? Does it send the events to a TCP/UDP server or to a web page?

I was also thinking of making a live preview of the game:
- live scoreboard
- a picture of the map with player icons on it, so you can know their location (with some delay to prevent cheating) - this means I would also need to send the player positions every 5 seconds
- a live log with kills and other events

Spirit_12 11-06-2022 11:22

Re: Saving player scores and weapon stats before map change
 
It uses UDP as far as I know. As for how to get the data you can take a look at HLXSTATS demon yourself.

Here is a sample from parsed HLXSTATS demon log.

PHP Code:

2022-11-03 16:48:02:   SERVER_IP DEBUGNo infected match for Coach
2022
-11-03 16:48:02:   SERVER_IP E001"BOT-Coach" <P:305,U:-8,W:BOT-Coach,T:> connectedaddress "none"hostname ""hostgroup ""
2022-11-03 16:48:05:   SERVER_IP DEBUGNo infected match for Coach
2022
-11-03 16:48:05:   SERVER_IP E002"BOT-Coach" <P:305,U:-8,W:BOT-Coach,T:> entered the game
2022
-11-03 16:48:05:   SERVER_IP DEBUGNo infected match for Coach
2022
-11-03 16:48:05:   SERVER_IP E005"BOT-Coach" <P:305,U:-8,W:BOT-Coach,T:Unassignedjoined team "Survivor"
2022-11-03 16:48:05:   SERVER_IP DEBUGNo infected match for Rochelle
2022
-11-03 16:48:05:   SERVER_IP E001"BOT-Rochelle" <P:306,U:-8,W:BOT-Rochelle,T:> connectedaddress "none"hostname ""hostgroup ""
2022-11-03 16:48:07:   SERVER_IP DEBUGNo infected match for Rochelle
2022
-11-03 16:48:07:   SERVER_IP E002"BOT-Rochelle" <P:306,U:-8,W:BOT-Rochelle,T:> entered the game
2022
-11-03 16:48:07:   SERVER_IP DEBUGNo infected match for Rochelle
2022
-11-03 16:48:07:   SERVER_IP E005"BOT-Rochelle" <P:306,U:-8,W:BOT-Rochelle,T:Unassignedjoined team "Survivor" 

From my knowledge you can utilize this and create custom events and then capture it.

Natsheh 11-06-2022 17:03

Re: Saving player scores and weapon stats before map change
 
Why don't you use SQL to save up data ingame and then use the webpage to display out the data from the database? It would be much simpler.

ghostdlr 11-06-2022 19:27

Re: Saving player scores and weapon stats before map change
 
Quote:

Originally Posted by Spirit_12 (Post 2792266)
It uses UDP as far as I know. As for how to get the data you can take a look at HLXSTATS demon yourself.

Here is a sample from parsed HLXSTATS demon log.

PHP Code:

2022-11-03 16:48:02:   SERVER_IP DEBUGNo infected match for Coach
2022
-11-03 16:48:02:   SERVER_IP E001"BOT-Coach" <P:305,U:-8,W:BOT-Coach,T:> connectedaddress "none"hostname ""hostgroup ""
2022-11-03 16:48:05:   SERVER_IP DEBUGNo infected match for Coach
2022
-11-03 16:48:05:   SERVER_IP E002"BOT-Coach" <P:305,U:-8,W:BOT-Coach,T:> entered the game
2022
-11-03 16:48:05:   SERVER_IP DEBUGNo infected match for Coach
2022
-11-03 16:48:05:   SERVER_IP E005"BOT-Coach" <P:305,U:-8,W:BOT-Coach,T:Unassignedjoined team "Survivor"
2022-11-03 16:48:05:   SERVER_IP DEBUGNo infected match for Rochelle
2022
-11-03 16:48:05:   SERVER_IP E001"BOT-Rochelle" <P:306,U:-8,W:BOT-Rochelle,T:> connectedaddress "none"hostname ""hostgroup ""
2022-11-03 16:48:07:   SERVER_IP DEBUGNo infected match for Rochelle
2022
-11-03 16:48:07:   SERVER_IP E002"BOT-Rochelle" <P:306,U:-8,W:BOT-Rochelle,T:> entered the game
2022
-11-03 16:48:07:   SERVER_IP DEBUGNo infected match for Rochelle
2022
-11-03 16:48:07:   SERVER_IP E005"BOT-Rochelle" <P:306,U:-8,W:BOT-Rochelle,T:Unassignedjoined team "Survivor" 

From my knowledge you can utilize this and create custom events and then capture it.

Where can I download it from? Can I get the source code?

Spirit_12 11-09-2022 19:54

Re: Saving player scores and weapon stats before map change
 
https://forums.alliedmods.net/forumdisplay.php?f=156


All times are GMT -4. The time now is 15:36.

Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.