Donate to the B3 fund!

"even a small donation helps!"
Donate with PayPal!

Author Topic: i need help firstkill plugin  (Read 1285 times)

Offline hockeykiller1

  • Newbie
  • *
  • Posts: 4
i need help firstkill plugin
« on: December 14, 2013, 09:32:45 PM »
i want that firstkill plugin show me the first kill and other 49 kills teamkill with other messages on my blackops server

that is the original code



# firstkill Plugin

__author__  = 'PtitBigorneau www.ptitbigorneau.fr'
__version__ = '1.1.2'


import b3
import b3.plugin
import b3.events

class FirstkillPlugin(b3.plugin.Plugin):
    _adminPlugin = None
    _kill = 0
    _tk = 0

    def onStartup(self):
        self._adminPlugin = self.console.getPlugin('admin')

        if not self._adminPlugin:
            self.error('Could not find admin plugin')
            return False

        self.registerEvent(b3.events.EVT_CLIENT_KILL)
        self.registerEvent(b3.events.EVT_CLIENT_KILL_TEAM)
        self.registerEvent(b3.events.EVT_GAME_ROUND_START)

    def onLoadConfig(self):
        self._tkonoff = self.config.get('settings', 'tkonoff')

    def onEvent(self, event):
        if event.type == b3.events.EVT_GAME_ROUND_START:
            self._kill = 0
            self._tk = 0

        if event.type == b3.events.EVT_CLIENT_KILL:
            self._kill += 1

            client = event.client
            target = event.target

            if self._kill == 1:
                self.console.say("^2First Kill ^3:%s killed ^2%s" % (client.exactName, target.exactName))

        if (event.type == b3.events.EVT_CLIENT_KILL_TEAM) and (self._tkonoff=="on"):
            self._tk += 1

            client = event.client
            target = event.target

            if self._tk == 1:
                self.console.say("^1First TeamKill ^3:%s Teamkilled %s" % (client.exactName, target.exactName))


and that is what i want

i want that other teamkill i say 2-50 teamkills the consloe write


self.console.say("^3:%s ^1Teamkilled ^3%s" % (client.exactName, target.exactName))


how can i change that it works

too time i write the code wrong the b3 not start or only firstkill plugin works

i don't want to use teamkill plugin i want a code for the  firstkill plugin



« Last Edit: December 14, 2013, 09:34:24 PM by hockeykiller1 »

Offline Fenix

  • Dev. Team
  • Hero Member
  • *
  • Posts: 989
    • GitHub
Re: i need help firstkill plugin
« Reply #1 on: December 15, 2013, 03:00:14 AM »
Definitely not my best work, but should do the job. However it would be better to make this in a different plugin so you don't lose your customizations if the plugin gets upgraded (and this is already an old version of this plugin)

Code: python [Select]
# firstkill Plugin

__author__  = 'PtitBigorneau www.ptitbigorneau.fr'
__version__ = '1.1.2'


import b3
import b3.plugin
import b3.events

class FirstkillPlugin(b3.plugin.Plugin):
    _adminPlugin = None
    _kill = 0
    _tk = 0

    def onStartup(self):
        self._adminPlugin = self.console.getPlugin('admin')

        if not self._adminPlugin:
            self.error('Could not find admin plugin')
            return False

        self.registerEvent(b3.events.EVT_CLIENT_KILL)
        self.registerEvent(b3.events.EVT_CLIENT_KILL_TEAM)
        self.registerEvent(b3.events.EVT_GAME_ROUND_START)

    def onLoadConfig(self):
        self._tkonoff = self.config.get('settings', 'tkonoff')

    def onEvent(self, event):
   
        if event.type == b3.events.EVT_GAME_ROUND_START:
            self._kill = 0
            self._tk = 0

        if event.type == b3.events.EVT_CLIENT_KILL:
           
            if self._kill < 1:
           
                self._kill += 1

                client = event.client
                target = event.target

                if self._kill == 1:
                    self.console.say("^21st Kill^3: %s killed ^2%s" % (client.exactName, target.exactName))

        if event.type == b3.events.EVT_CLIENT_KILL_TEAM and self._tkonoff == "on":
           
            if self._tk < 50:
           
                self._tk += 1
               
                client = event.client
                target = event.target
               
                suffix = 'th'
                if self._tk == 1 or if self._tk == 21 or if self._tk == 31 or if self._tk == 41:
                    suffix = 'st'
                elif self._tk == 2 or if self._tk == 22 or if self._tk == 32 or if self._tk == 42:
                    suffix = 'nd'
                elif self._tk == 3 or if self._tk == 23 or if self._tk == 33 or if self._tk == 43:
                    suffix = 'rd'
                   
                self.console.say("^1%d%s TeamKill^3: %s Teamkilled %s" % (self._tk, suffix, client.exactName, target.exactName))

 


Rate this page +1 at Google Search

anything