You are here: Big Brother Bot ForumCommunity DevelopersThe Code Binspawn kill detector help
Pages: [1] 2   Go Down
  Print  
Author Topic: spawn kill detector help  (Read 1102 times) Bookmark and Share
Jr. Member
**
OS: Windows
Type: Gameserver Rental Co.
Gameservers: Homefront
Posts: 13
Offline Offline
« on: July 15, 2011, 10:38:31 AM »

Hey everyone. I am making a spawn kill detector for Homefront. This is my very first attempt at a plugin (and python but I know php and c++ so i have the hang of it) so I'm sure it has tons of errors.

Any advice/tips are more then welcome.

thanks

so here is my code.

What i am aiming for is:

user spawns
associative array with the unix timestamp gets set
player dies
code checks current unix time and compares with timestamp in the array
if time difference is less then 5 seconds warn the killer

Code:
  __version__ = '1.0'
    __author__  = 'Courgette'
     
    import b3
    import b3.events
    import b3.plugin
import time
     
     
    class Tutorial1Plugin(b3.plugin.Plugin):

spawntime = {}
     
        def onStartup(self):
            # get the admin plugin so we can register commands
            self._adminPlugin = self.console.getPlugin('admin')
     
            if not self._adminPlugin:
                # something is wrong, can't start without admin plugin
                self.error('Could not find admin plugin')
                return
     
        def onStartup(self):
        if self.console.gameName not in SUPPORTED_PARSERS:
            self.error("This game is not supported by this plugin")
            self.disable()
            return

        self.registerEvent(EVT_CLIENT_AUTH)

        self._workerThread = threading.Thread(target=self._worker)
        self._workerThread.setDaemon(True)
        self._workerThread.start()

        self._checkConnectedPlayers()

def onEvent(self,event, client)
if event.type == b3.events.EVT_CLIENT_SPAWN:
spawntime[client.guid] = int(time.time())
self.console.write('bigtext "test %s"' % (spawntime[client.guid]))
if event.type == b3.events.EVT_CLIENT_DISCONNECT:
del spawntime[client.guide]
if event.type == event.type == b3.events.EVT_CLIENT_KILL:
if int(time.time()) <= (spawntime[event.target] + 5):
self.console.write('bigtext "DO NOT SPAWN KILL"')
Logged

XLRstats dev.
Dev. Team
*
OS: Linux
Type: Home user
Gameservers: COD5, COD7, BF3
Posts: 947
Offline Offline
WWW
Support Specialty: XLRstats webfront
« Reply #1 on: July 15, 2011, 01:01:11 PM »

Game engine doesn't provide player spawn information to B3. So there's no way to produce a player spawn event I guess.

However in weapon list I remember seeing spawn kill. If this is really spawn kills then you can use this information and warn the attacker for spawn killing.
Logged

Senior Dev.
*
OS: Linux
Type: Home user
Posts: 3485
Offline Offline
WWW
Support Specialty: B3-Core, UrT/SmG/BFBC2 parsers, Plugin development
« Reply #2 on: July 15, 2011, 02:13:09 PM »

Also have a look at Client.var() or .setvar() (I don't remember) which would allow you to save the timestamp on the client object. IIRC, the tk and Spam plugins use this

Sent from my HTC Legend using Tapatalk
Logged

Jr. Member
**
OS: Windows
Type: Gameserver Rental Co.
Gameservers: Homefront
Posts: 13
Offline Offline
« Reply #3 on: July 15, 2011, 02:16:45 PM »

ok, so, homefront engine doesn't spit out when player spawns?

so EVT_CLIENT_SPAWN won't work

sorry, there is a lot i do not known but eager to learn.

what is weapon list and where can I find it/look at it?

clients.var and server() where can I see what these hold?

sorry for the noobiness and thanks for the help



Logged
Senior Dev.
*
OS: Linux
Type: Home user
Posts: 3485
Offline Offline
WWW
Support Specialty: B3-Core, UrT/SmG/BFBC2 parsers, Plugin development
« Reply #4 on: July 15, 2011, 11:16:36 PM »

Client.var() is meant for plugins to store any data they want on a client object. This has the advantage of not requiring you to monitor clients disconnections to free up the memory

Sent from my HTC Legend using Tapatalk
Logged

XLRstats dev.
Dev. Team
*
OS: Linux
Type: Home user
Gameservers: COD5, COD7, BF3
Posts: 947
Offline Offline
WWW
Support Specialty: XLRstats webfront
« Reply #5 on: July 16, 2011, 02:40:27 AM »

The name of the weapon is "SpawnCamp". That's the console name so you can check for this name in your code. It's here in xlrstats output.

http://gs2.snt.utwente.nl/xlr/xlrstatsdev/index.php?func=show&page=4&pagenumber=4

But like I said I'm not sure if this is really for spawn kills.
Logged

Jr. Member
**
OS: Windows
Type: Gameserver Rental Co.
Gameservers: Homefront
Posts: 13
Offline Offline
« Reply #6 on: July 16, 2011, 08:40:01 AM »

yup, there isn't one, so I'm going to make a rough one that checks the time between the first and second kill.

Not ideal but it will pick up most.

ok so...after tweaking my code, also testing and getting used to it this is what I have, i don't get any errors but it doesn't output anything either. Any ideas?

Thanks

Code:
import b3
import b3.events
import b3.plugin
import time
 
 
class SpawnkillPlugin(b3.plugin.Plugin):

requiresConfigFile = False
_adminPlugin = None

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)

def onEvent(self, event, client):
client.message('^1First TeamKill ^3:%s killed %s' % (client.exactName, client.exactName))
if event.type == b3.events.EVT_CLIENT_SPAWN:
spawntime[client.guid] = int(time.time())
self.console.write('bigtext "test %s"' % (spawntime[client.guid]))
if event.type == b3.events.EVT_CLIENT_DISCONNECT:
del spawntime[client.guide]
if event.type == b3.events.EVT_CLIENT_KILL:
client.message('^1First TeamKill ^3:%s killed %s' % (client.exactName, client.exactName))
Logged
Jr. Member
**
OS: Windows
Type: Gameserver Rental Co.
Gameservers: Homefront
Posts: 22
Offline Offline
« Reply #7 on: July 17, 2011, 12:41:49 AM »

I too am curious on this and if this worked it would be beneficial to our server for sure.
Logged
Beta Testers
*
OS: Windows
Type: Owner dedicated server(s)
Gameservers: MW2 (aIW)
Posts: 187
Offline Offline
WWW
« Reply #8 on: July 17, 2011, 08:55:13 AM »

Hi

I´m actually running a MW2 server and I´m pretty much interested in this plugin.
Nevertheless, I don´t see 'EVT_CLIENT_SPAWN' listed in events.py of  the bot.

Do you have an idea if the code above could be working for MW2?

Thanks in advance.
Logged
Jr. Member
**
OS: Windows
Type: Gameserver Rental Co.
Gameservers: Homefront
Posts: 22
Offline Offline
« Reply #9 on: July 17, 2011, 09:29:42 AM »

yup, there isn't one, so I'm going to make a rough one that checks the time between the first and second kill.

Not ideal but it will pick up most.

ok so...after tweaking my code, also testing and getting used to it this is what I have, i don't get any errors but it doesn't output anything either. Any ideas?

Thanks


I think what he means is that he's gonna ignore the whole spawn camp feature in the game and just look for a event to occur when" player a" is killed and then say if "player a" is killed again with in 10 seconds for it to issue a warning about spawn camping.
Logged
Jr. Member
**
OS: Windows
Type: Gameserver Rental Co.
Gameservers: Homefront
Posts: 13
Offline Offline
« Reply #10 on: July 17, 2011, 02:45:50 PM »

Hi

I´m actually running a MW2 server and I´m pretty much interested in this plugin.
Nevertheless, I don´t see 'EVT_CLIENT_SPAWN' listed in events.py of  the bot.

Do you have an idea if the code above could be working for MW2?

Thanks in advance.

I did see it, somewhere, but it doesn't work for Homefront because Homefront doesn't announce when a player spawns in, you would have to check your B3 logs to see if Cod announces spawn.

yes, lol is correct, thats how I plan to do it.

If someone could tell me why my test code isn't working i would greatly appreciate it!

this is what i put in my B3.xml

Code:
<plugin name="spawnkill" />

found this in the log:

Quote
handler SpawnkillPlugin could not handle event Client Kill: TypeError: onEvent() takes exactly 3 arguments (2 given) [('C:\\\\UserFiles\\\\hoos\\\\B3Homefront\\\\b3\\\\parser.py', 961, 'handleEvents', 'hfunc.parseEvent(event)'), ('C:\\\\UserFiles\\\\hoos\\\\B3Homefront\\\\b3\\\\plugin.py', 157, 'parseEvent', 'self.onEvent(event)')]"
« Last Edit: July 17, 2011, 03:03:41 PM by virtus » Logged
Beta Testers
*
OS: Windows
Type: Owner dedicated server(s)
Gameservers: MW2 (aIW)
Posts: 187
Offline Offline
WWW
« Reply #11 on: July 17, 2011, 02:57:21 PM »

Why don´t you add the path to the xml plugin in that sentence?

Code:
<plugin name="spawnkill" config="@b3/extplugins/conf/plugin_spawnkill.xml />
« Last Edit: July 17, 2011, 02:59:30 PM by gabarram » Logged
Jr. Member
**
OS: Windows
Type: Gameserver Rental Co.
Gameservers: Homefront
Posts: 13
Offline Offline
« Reply #12 on: July 17, 2011, 03:04:24 PM »

updated last post.

I don't have an xml file and in the plugin i declared one didn't exist.
Logged
Beta Testers
*
OS: Windows
Type: Owner dedicated server(s)
Gameservers: MW2 (aIW)
Posts: 187
Offline Offline
WWW
« Reply #13 on: July 17, 2011, 03:27:14 PM »

updated last post.

I don't have an xml file and in the plugin i declared one didn't exist.
How B3 knows there´s a plugin without your declaring here or there that the file exists?
Logged
Jr. Member
**
OS: Windows
Type: Gameserver Rental Co.
Gameservers: Homefront
Posts: 13
Offline Offline
« Reply #14 on: July 17, 2011, 03:34:09 PM »

this line, which i commented above

Quote
<plugin name="spawnkill" />
Logged
Tags:
Pages: [1] 2   Go Up
  Print  
 
Jump to:  


Rate this page +1 at Google Search


SimplePortal 2.3.1 © 2008-2009, SimplePortal