I edited run.py so:
- Code: Select all
...
def on_hit(self, hit_amount, player, type):
if not self.protocol.killing and not self.admin:
self.send_chat(
"Du kannst jetzt niemanden umbringen! Schaden ist AUS!")
return False
if not self.killing and not self.admin:
self.send_chat("%s. Du kannst niemanden umbringen." % player.name)
return False
elif player.god:
if not player.invisible:
self.send_chat("Du kannst %s nicht schaden! Dieser Spieler ist im "
"*god mode*" % player.name)
return True
#if self.god:
#self.protocol.send_chat('%s, toeten im *god mode* ist verboten!' %
# self.name, irc = True)
#self.protocol.send_chat('%s ist jetzt wieder ein normaler Mensch.' %
# self.name, irc = True)
#self.god = False
#self.god_build = False
...
I know killing in invisible-mode is unfair!
Now I want to make it into a script-file, because I want to use it with normal pyspades server.
I tried this:
- Code: Select all
import commands
def apply_script(protocol, connection, config):
class Kill_in_God_Connection(connection):
def on_hit(self, hit_amount, player, type):
if not self.protocol.killing and not self.admin:
self.send_chat(
"Du kannst jetzt niemanden umbringen! Schaden ist AUS!")
return False
if not self.killing and not self.admin:
self.send_chat("%s. Du kannst niemanden umbringen." % player.name)
return False
elif player.god:
if not player.invisible:
self.send_chat("Du kannst %s nicht schaden! Dieser Spieler ist im "
"*god mode*" % player.name)
return True
class Kill_in_God_Protocol(protocol):
def on_hit(self, hit_amount, player, type):
if not self.protocol.killing and not self.admin:
self.send_chat(
"Du kannst jetzt niemanden umbringen! Schaden ist AUS!")
return False
if not self.killing and not self.admin:
self.send_chat("%s. Du kannst niemanden umbringen." % player.name)
return False
elif player.god:
if not player.invisible:
self.send_chat("Du kannst %s nicht schaden! Dieser Spieler ist im "
"*god mode*" % player.name)
return True
return Kill_in_God_Protocol, Kill_in_God_Connection
It woks, but I believe this isn't perfect.
So I want to ask, whether someone can optimize it.
Thanks.