Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
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'
def trust(connection, player):
player = get_player(connection.protocol, player)
player.on_user_login('trusted', False)
return S_GRANTED.format(player =
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:
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 =
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