Need help with pycoding.
Posted: Fri Jul 26, 2013 6:17 pm
I'm trying to nerf rifle in this script, can some1 explain me how on_shoot_set works? I return false but it still parses a shot.
Is there a way to prevent shooting? Here is the code:
Is there a way to prevent shooting? Here is the code:
Code: Select all
"""
Shooting a rifle has 2 second cooldown.
by arch_kun
"""
from pyspades.constants import *
from twisted.internet.reactor import callLater, seconds
def apply_script(protocol, connection, config):
class RifleNerfConnection(connection):
cantShoot = 0
def rifleCooldown(self):
self.cantShoot = 1
callLater(2.0, self.recharged)
def recharged(self):
self.cantShoot = 0
def on_shoot_set(self, fire):
if self.weapon == RIFLE_WEAPON and fire:
self.send_chat('ping')
if self.cantShoot == 0 :
self.send_chat('ping2')
self.rifleCooldown()
return connection.on_shoot_set(self, fire)
else:
return False
return protocol, RifleNerfConnection