thankyou
Donate to the B3 fund!

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

Author Topic: spawn kill detector help  (Read 6622 times)

Offline virtus

  • Jr. Member
  • **
  • Posts: 13
spawn kill detector help
« on: July 15, 2011, 08:38:31 PM »
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: [Select]
  __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"')

Offline Freelander

  • XLRstats dev.
  • Dev. Team
  • Hero Member
  • *
  • Posts: 1000
Re: spawn kill detector help
« Reply #1 on: July 15, 2011, 11: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.

Offline Courgette

  • Senior Dev.
  • Hero Member
  • *
  • Posts: 4882
    • Github repository
Re: Re: spawn kill detector help
« Reply #2 on: July 16, 2011, 12:13:09 AM »
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

Offline virtus

  • Jr. Member
  • **
  • Posts: 13
Re: spawn kill detector help
« Reply #3 on: July 16, 2011, 12:16:45 AM »
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




Offline Courgette

  • Senior Dev.
  • Hero Member
  • *
  • Posts: 4882
    • Github repository
Re: Re: spawn kill detector help
« Reply #4 on: July 16, 2011, 09:16:36 AM »
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

Offline Freelander

  • XLRstats dev.
  • Dev. Team
  • Hero Member
  • *
  • Posts: 1000
Re: spawn kill detector help
« Reply #5 on: July 16, 2011, 12:40:27 PM »
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.

Offline virtus

  • Jr. Member
  • **
  • Posts: 13
Re: spawn kill detector help
« Reply #6 on: July 16, 2011, 06:40:01 PM »
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: [Select]
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))

Offline lolasaurous

  • Jr. Member
  • **
  • Posts: 22
Re: spawn kill detector help
« Reply #7 on: July 17, 2011, 10:41:49 AM »
I too am curious on this and if this worked it would be beneficial to our server for sure.

Offline gabarram

  • Sr. Member
  • ****
  • Posts: 186
Re: spawn kill detector help
« Reply #8 on: July 17, 2011, 06:55:13 PM »

Offline lolasaurous

  • Jr. Member
  • **
  • Posts: 22
Re: spawn kill detector help
« Reply #9 on: July 17, 2011, 07:29:42 PM »
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.

Offline virtus

  • Jr. Member
  • **
  • Posts: 13
Re: spawn kill detector help
« Reply #10 on: July 18, 2011, 12:45:50 AM »
« Last Edit: July 18, 2011, 01:03:41 AM by virtus »

Offline gabarram

  • Sr. Member
  • ****
  • Posts: 186
Re: spawn kill detector help
« Reply #11 on: July 18, 2011, 12:57:21 AM »
« Last Edit: July 18, 2011, 12:59:30 AM by gabarram »

Offline virtus

  • Jr. Member
  • **
  • Posts: 13
Re: spawn kill detector help
« Reply #12 on: July 18, 2011, 01:04:24 AM »
updated last post.

I don't have an xml file and in the plugin i declared one didn't exist.

Offline gabarram

  • Sr. Member
  • ****
  • Posts: 186
Re: spawn kill detector help
« Reply #13 on: July 18, 2011, 01:27:14 AM »

Offline virtus

  • Jr. Member
  • **
  • Posts: 13
Re: spawn kill detector help
« Reply #14 on: July 18, 2011, 01:34:09 AM »
this line, which i commented above

Quote
<plugin name="spawnkill" />

 


Rate this page +1 at Google Search