Skip to content

Instantly share code, notes, and snippets.

@infogulch
Created August 9, 2012 14:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save infogulch/3304934 to your computer and use it in GitHub Desktop.
Save infogulch/3304934 to your computer and use it in GitHub Desktop.
Before/After changes
"""
Adds the ability to 'trust' certain players, i.e. they cannot be votekicked
or rubberbanded.
Maintainer: mat^2 / hompy
"""
from commands import add, admin, get_player
import votekick
S_GRANTED = '{player} is now trusted'
S_GRANTED_SELF = "You've been granted trust, and can't be votekicked"
S_CANT_VOTEKICK = "{player} is trusted and can't be votekicked"
S_RESULT_TRUSTED = 'Trusted user'
@admin
def trust(connection, player):
player = get_player(connection.protocol, player)
player.on_user_login('trusted', False)
player.send_chat(S_GRANTED_SELF)
return S_GRANTED.format(player = player.name)
add(trust)
def apply_script(protocol, connection, config):
# trusted depends on votekick events being higher in the heirarchy than itself
# so force it to come first!
protocol, connection = votekick.apply_script(protocol, connection, config)
# note: votekick would have to be modified to not add itself more than once
class TrustedConnection(connection):
def on_user_login(self, user_type, verbose = True):
if user_type == 'trusted':
self.speedhack_detect = False
votekick = getattr(self.protocol, 'votekick', None)
if votekick and votekick.victim is self:
votekick.end(S_RESULT_TRUSTED)
self.protocol.votekick = None
return connection.on_user_login(self, user_type, verbose)
class TrustedProtocol(protocol):
def on_votekick_start(self, instigator, victim, reason):
if victim.user_types.trusted:
return S_CANT_VOTEKICK.format(player = victim.name)
return protocol.on_votekick_start(self, instigator, victim, reason)
return TrustedProtocol, TrustedConnection
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment