Raised This Month: $ Target: $400
 0% 

Saving player scores and weapon stats before map change


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
ghostdlr
Senior Member
Join Date: Aug 2010
Old 11-05-2022 , 14:46   Saving player scores and weapon stats before map change
Reply With Quote #1

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)

Last edited by ghostdlr; 11-05-2022 at 15:18.
ghostdlr is offline
Spirit_12
Veteran Member
Join Date: Dec 2012
Location: Toronto, CA
Old 11-05-2022 , 20:11   Re: Saving player scores and weapon stats before map change
Reply With Quote #2

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.
__________________
Spirit_12 is offline
ghostdlr
Senior Member
Join Date: Aug 2010
Old 11-06-2022 , 05:02   Re: Saving player scores and weapon stats before map change
Reply With Quote #3

Quote:
Originally Posted by Spirit_12 View Post
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

Last edited by ghostdlr; 11-06-2022 at 05:07.
ghostdlr is offline
ghostdlr
Senior Member
Join Date: Aug 2010
Old 11-05-2022 , 20:22   Re: Saving player scores and weapon stats before map change
Reply With Quote #4

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 is offline
Spirit_12
Veteran Member
Join Date: Dec 2012
Location: Toronto, CA
Old 11-06-2022 , 11:22   Re: Saving player scores and weapon stats before map change
Reply With Quote #5

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.
__________________

Last edited by Spirit_12; 11-06-2022 at 11:25.
Spirit_12 is offline
ghostdlr
Senior Member
Join Date: Aug 2010
Old 11-06-2022 , 19:27   Re: Saving player scores and weapon stats before map change
Reply With Quote #6

Quote:
Originally Posted by Spirit_12 View Post
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?
ghostdlr is offline
Natsheh
Veteran Member
Join Date: Sep 2012
Old 11-06-2022 , 17:03   Re: Saving player scores and weapon stats before map change
Reply With Quote #7

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.
__________________
@Jailbreak Main Mod v2.7.0 100%
@User Tag Prefix 100% done !
@Mystery Box 100% done !
@VIP System 100% done !


Last edited by Natsheh; 11-06-2022 at 17:03.
Natsheh is offline
Send a message via MSN to Natsheh Send a message via Skype™ to Natsheh
Spirit_12
Veteran Member
Join Date: Dec 2012
Location: Toronto, CA
Old 11-09-2022 , 19:54   Re: Saving player scores and weapon stats before map change
Reply With Quote #8

https://forums.alliedmods.net/forumdisplay.php?f=156
__________________
Spirit_12 is offline
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


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


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