thankyou
Donate to the B3 fund!

"even a small donation helps!"
Donate with PayPal!
Most of the plugins here are made by B3 users and the authors may not visit frequently. If you need support for plugins or if questions remain unanswered, you will have to contact the author directly. Read the full Support Disclaimer here

NOTE: Do not attach plugins to your forumtopics! Attachements are periodically removed by maintenance tasks. Upload your plugins to our Downloads section instead!

Author Topic: FirstKill Plugin  (Read 8434 times)

Offline danger89

  • Full Member
  • ***
  • Posts: 129
    • JoinMyServer - Game Servers
Re: FirstKill Plugin
« Reply #15 on: July 26, 2012, 04:50:43 PM »
EDIT:
Call of Duty 4 version of first kill 1.0 (with headshot feature):
Code: python [Select]
# firstkill Plugin

__author__  = 'PtitBigorneau changed by Melroy van den berg'
__version__ = '1.0'


import b3
import b3.plugin
import b3.events

class FirstkillPlugin(b3.plugin.Plugin):
    _adminPlugin = None
    _kill = 0
    _tk = 0
    _hs =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')
        self._fkonoff = self.config.get('settings', 'fkonoff')
        self._hsonoff = self.config.get('settings', 'hsonoff')
   
    def onEvent(self, event):
        if event.type == b3.events.EVT_GAME_ROUND_START:
            self._kill = 0
            self._tk = 0
            self._hs = 0

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

            client = event.client
            target = event.target
            hitlocation = event.data[2]
               
            if hitlocation == "head":                   
                self._hs += 1
            if self._fkonoff == "on":
                if self._kill == 1:
                    if self._hs == 1 and self._hsonoff == "on":
                               
                        self.console.say("^2First Kill ^5By Headshot ^3: %s killed %s" % (client.exactName, target.exactName))
                        self._hs += 1                       
                    else:
                        self.console.say("^2First Kill ^3:%s killed %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))


The code above doesn't have the 5 times message issue.
« Last Edit: July 26, 2012, 05:37:53 PM by danger89 »
JoinMyServer.com
Call of Duty 4 Game Servers

Offline PtitBigorneau

  • Moderator
  • Sr. Member
  • *
  • Posts: 194
    • www.ptitbigorneau.fr
Re: FirstKill Plugin
« Reply #16 on: July 26, 2012, 06:40:42 PM »
it is the function "self.console.saybig" who poses problem with cod4?

PtitBigorneau

Offline MordyT

  • Support Hero
  • Hero Member
  • *
  • Posts: 3644
  • Over $300 Donated to B3!
    • MordyT
Re: FirstKill Plugin
« Reply #17 on: July 26, 2012, 06:57:25 PM »
it is the function "self.console.saybig" who poses problem with cod4?


There is no saybig in cod4 (stock, modded can add it back in) afaik
Help will be given to those with a b3.log

If drop off the map it is due to RL becoming busy :)

System: Python 2.7.3 - Deb 7 - B3 Source Code - 128MB RAM box (rented at $5 a year) - remote MySQL - Remote Web Services

Offline PtitBigorneau

  • Moderator
  • Sr. Member
  • *
  • Posts: 194
    • www.ptitbigorneau.fr
Re: FirstKill Plugin
« Reply #18 on: August 14, 2012, 10:55:11 AM »
v 1.4.1

solves the problem with cod4

download -> firstkill v1.4.1

PtitBigorneau

Offline Fenix

  • Dev. Team
  • Hero Member
  • *
  • Posts: 981
    • GitHub
Re: FirstKill Plugin
« Reply #19 on: May 20, 2015, 02:33:26 PM »
Since this plugin has become quite popular I decided to include it in B3 1.10 as built-in plugin: commit here.
I gave it a general rewrite in order to better support new core features and allowing the user to customize the plugin more.
I obviously kept the credits ;). If you feel you want to change something feel free to send us a pull request.

Thanks for your contribution :):):)

Offline PtitBigorneau

  • Moderator
  • Sr. Member
  • *
  • Posts: 194
    • www.ptitbigorneau.fr
Re: FirstKill Plugin
« Reply #20 on: June 04, 2015, 09:31:09 AM »
np ;)
PtitBigorneau

 


Rate this page +1 at Google Search

anything