Note: This forum is merely an archive. It is no longer possible to register or post. - StackOverflow
New Ace of Spades Forums: http://buildandshoot.com/

Can someone optimize my script?

For all your hosting needs.

Can someone optimize my script?

Postby oxygenxd » Wed Mar 28, 2012 6:58 pm

Hey Guys!

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.
There are 10 types of humen, the ones who understand the binary system and the ones who don't.

Sorry, if my english is not so perfect, I'm German. Would be nice if you speak in simple english :)
oxygenxd
Member
 
Posts: 11
Joined: Fri Mar 16, 2012 10:42 pm

Return to Server



Who is online

Users browsing this forum: No registered users and 2 guests

cron