Created
October 31, 2011 10:31
-
-
Save thomasleveil/1327247 to your computer and use it in GitHub Desktop.
B3 pm stats plugin
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
__version__ = '1.0.1' | |
__author__ = 'KnightOrk' | |
from b3 import clients | |
import b3, os, string, re, threading | |
import b3.events | |
import b3.plugin | |
class PmstatsPlugin(b3.plugin.Plugin): | |
_xlrstatsPlugin = None | |
requiresConfigFile = False | |
def onStartup(self): | |
self.registerEvent(b3.events.EVT_GAME_ROUND_END) | |
self.registerEvent(b3.events.EVT_GAME_EXIT) | |
self._xlrstatsPlugin = self.console.getPlugin('xlrstats') | |
def onEvent(self, event): | |
if event.type == b3.events.EVT_GAME_ROUND_END or event.type == b3.events.EVT_GAME_EXIT: | |
self.show_stats() | |
def show_stats(self): | |
d= {} | |
for player in self.console.clients.getList(): | |
if not d.has_key(player.name): | |
d[player.name] = [player.cid] | |
else: | |
d[player.name].append(player.cid) | |
for pname,cidlist in d.items(): | |
if (len(pname) > 0): | |
for cid in cidlist: | |
client = self.console.clients.getByCID(cid) | |
stats = self._xlrstatsPlugin.get_PlayerStats(client) | |
if stats: | |
client.message( '^3XLR Stats: ^7%s ^7: K ^2%s ^7D ^3%s ^7TK ^1%s ^7Ratio ^5%1.02f ^7Skill ^3%1.02f' % (client.exactName, stats.kills, stats.deaths, stats.teamkills, stats.ratio, stats.skill)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment