![]() # now add this batch of kills to our persistant statsįor account_id, kill_count in self._account_ems(): # We use a background thread so our server doesn't hitch while doing this. # and write everything back to disk (along with a pretty html version) # from disk, do display-string lookups for accounts that need them, # Now lets kick off a background thread to load existing scores # Ok now we've got a dict of account-ids and kills. # look at score-set entries to tally per-account kills for this roundįor p_entry in score_set.getValidPlayers().values():Īccount_id = p_entry.getPlayer().get_account_id()Īccount_tdefault(account_id, 0) # make sure existsĪccount_kills += p_entry.accumKillCount Given a Session's ScoreSet, tallies per-account killsĪnd passes them to a background thread to process and # where our stats file and pretty html output will go To use this, add the following 2 lines to (): Provides functionality for dumping player stats to disk between rounds. Mystats module for BombSquad version 1.4.143 A not-ultra-ugly-looking top kills pageĪnyway, I hope this is useful.if your server gets a lot of players you may want to prune scores or only display the top 100 or something to that effect (or get really fancy and wire it up to a proper database instead of a json file).capturing other stats besides just kills.perhaps resetting the kill-count once per day or once per week.Some ideas for improvements as an exercise for the reader: Have a look through it, see what its doing, and then feel free to modify it to do something fancier if you’d like. Note that this code is pretty bare-bones it could use some error-checking and of course more features, but I wanted to keep it simple and hopefully readable to use as a starting point. (see this post about the new stats button option) ![]() so if you wire up your server to dump this out somewhere world-accessible, you can then set your server’s stat button to point at that url so everyone can see who is the most awesomest dude on your server at any time. It also writes out an html file showing all names sorted by total kill-count. (the same name they show up on league lists as). You should also wind up with a json file containing a running tally of kills per account along with html snippets to display each account’s name. If you do this correctly, your server should print ‘ Added X kill entries‘ to the terminal at the end of each round. (should be about line 1904 in the latest 1.4.143 builds) add the following few lines in bsGame.py in ScoreScreenActivity’s onBegin() method.change the ‘statsfile’ and ‘htmlfile’ paths at the top of the script to wherever you want your stats to go.Grab the sample code from the bottom of this page, save it to a file called ‘mystats.py’ in the scripts directory of your bombsquad server.The example uses BombSquad version 1.4.143 your mileage may vary on older or newer versions. This example shows how to mod a BombSquad server to add a ‘total kills’ stat which keeps a permanent record of kills for each account that plays on it, as well as a webpage for viewing top kill counts.
0 Comments
Leave a Reply. |