Skip to content

Commit

Permalink
Improve ping checker output
Browse files Browse the repository at this point in the history
  • Loading branch information
urthub committed Mar 16, 2014
1 parent 93a613f commit 18604d1
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions spunky.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,8 +95,8 @@ def check_ping(self):
continue
else:
if self.max_ping < ping_value < 999 and gameplayer.get_admin_role() < 40:
gameplayer.add_high_ping()
game.rcon_tell(player.num, "^1WARNING ^7[^3%d^7]: ^7Your ping is too high [^4%d^7]. The maximum allowed ping is %d." % (gameplayer.get_high_ping(), ping_value, self.max_ping), False)
gameplayer.add_high_ping(ping_value)
game.rcon_tell(player.num, "^1WARNING ^7[^3%d^7]: ^7Your ping is too high [^4%d^7]. ^3The maximum allowed ping is %d." % (gameplayer.get_high_ping(), ping_value, self.max_ping), False)
else:
gameplayer.clear_high_ping()

Expand All @@ -119,11 +119,11 @@ def check_warnings_and_specs(self):
game.kick_player(player_num)
# kick player with high ping after 3 warnings, Admins will never get kicked
elif player.get_high_ping() > 2 and player_admin_role < 40:
game.rcon_say("^7Player ^2%s ^7kicked, because his ping was too high for this server" % player_name)
game.rcon_say("^7Player ^2%s ^7kicked, ping was too high for this server ^7[^4%s^7]" % (player_name, player.get_ping_value()))
game.kick_player(player_num)
# kick spectator after 3 warnings, Moderator or higher levels will not get kicked
elif player.get_spec_warning() > 2 and player_admin_role < 20:
game.rcon_say("^7Player ^2%s ^7kicked, because of spectator too long on full server" % player_name)
game.rcon_say("^7Player ^2%s ^7kicked, spectator too long on full server" % player_name)
game.kick_player(player_num)

# warn player with 2 warnings, Admins will never get the alert warning
Expand Down Expand Up @@ -1446,6 +1446,7 @@ def __init__(self, player_num, ip_address, guid, name):
self.db_team_death = 0
self.tk_victim_names = []
self.tk_killer_names = []
self.ping_value = 0
self.high_ping_count = 0
self.spec_warn_count = 0
self.warn_counter = 0
Expand Down Expand Up @@ -1726,15 +1727,19 @@ def clear_tk(self, killer):
def clear_all_tk(self):
self.tk_killer_names = []

def add_high_ping(self):
def add_high_ping(self, value):
self.high_ping_count += 1
self.ping_value = value

def clear_high_ping(self):
self.high_ping_count = 0

def get_high_ping(self):
return self.high_ping_count

def get_ping_value(self):
return self.ping_value

def add_spec_warning(self):
self.spec_warn_count += 1

Expand Down

0 comments on commit 18604d1

Please sign in to comment.