You are here: Big Brother Bot ForumAdd-OnsPluginsReleases!Weapon Control Plugin - Antinoob v1.0.7
Pages: 1 ... 13 14 [15]   Go Down
  Print  
Author Topic: Weapon Control Plugin - Antinoob v1.0.7  (Read 15670 times)
Full Member
***
OS: Linux
Type: Owner dedicated server(s)
Gameservers: CoD4
Posts: 50
Offline Offline
« Reply #210 on: December 10, 2009, 11:37:55 AM »

My final version of Anti Noob v1.0.8 is:

b3/plugins/antinoob.py
Code: python
# b3/plugins/antinoob.py
#
# Gamers 4 Gamers (http://g4g.pl)
# Copyright (C) 2009 Anubis
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.

# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
#
# $Id: antinoob.py 89 2008-06-06 22:38:34Z Anubis $
#
# CHANGELOG
#    06/06/2008 - 1.0.0 - Anubis
#    -- first version based on Antinoob plugin by MiLcH
#    07/06/2008 - 1.0.1 - Anubis
#    -- fixed airstrike issues
#    23/12/2008 - 1.0.2 - Anubis
#    -- Damage = warn
#    23/12/2008 - 1.0.3 - Anubis
#    -- New config - weapons/maps
#    12/02/2009 - 1.0.4 - Anubis
#    -- New config - MOD settings
#    16/02/2009 - 1.0.5 - Anubis
#    -- New config - MOD settings as restriction
#    26/03/2009 - 1.0.6 - Anubis
#    -- New config , new wepons handling
#    11/05/2009 - 1.0.7 - Anubis
#    -- Errors fixing
#    10/12/2009 - 1.0.8 - Melroy
#    -- Errors fixing

__version__ = '1.0.8'
__author__  = 'Anubis'
from b3 import clients
import b3, string, re, threading
import b3.events
import b3.plugin


class WeaponInfo:
   _weaponName = ""
   _mod = ""
   
class MapInfo:
   _mapName = None
   _duration = 10  

#--------------------------------------------------------------------------------------------------
class AntinoobPlugin(b3.plugin.Plugin):
   _adminPlugin = None
   _currentMap = None
   _bannedweaponswarn = []
   _bannedweaponskick = []    
   _weaponstimedwarn = []    
   _weaponstimedkick = []    
   _maps = []
   _warnduration = 10
   _warndurationdefault = 10
   _warningrule = 'rule10'
   _unlockmessage = '^3 %s seconds passed - ^3all weapons unlocked!!!'
   _infomessage = '^3 No nades, airstrike, tubes ^5for %s seconds of the round!!!'
   _bannedonlyinfomessage = '^3 Please, No nades, airstrike, tubes !!!'

   def onStartup(self):
       self.registerEvent(b3.events.EVT_CLIENT_KILL)
       self.registerEvent(b3.events.EVT_CLIENT_DAMAGE)
       self.registerEvent(b3.events.EVT_GAME_ROUND_START)
       self._adminPlugin = self.console.getPlugin('admin')

   def onLoadConfig(self):
       self.debug('Loading Configuration Started')
       self._warndurationdefault = self.config.getint('settings', 'warn_duration')
       self.debug('_warndurationdefault: ' + str(self._warndurationdefault))
       self._warningrule = self.config.get('settings', 'warning_rule')
       self._bannedwarningrule = self.config.get('settings', 'banned_warning_rule')
       if self._bannedwarningrule == '':
           self._bannedwarningrule = self._warningrule
       self._unlockmessage = self.config.get('settings', 'unlock_message')
       self._infomessage = self.config.get('settings', 'info_message')      
self._bannedonlyinfomessage = self.config.get('settings', 'bannedonly_info_message')
       
       for e in self.config.get('weapon_timed_warn/weapon'):
           #name  = setting.get('name')
           _wi = WeaponInfo()
           if e.text:
               _wi._weaponName = e.text
           else:
               _wi._weaponName = ""
           
           _wi._mod = e.get('mod')
           
           if (_wi._mod != "" or _wi._weaponName != ""):
               self.debug('Timed Warn - Weapon loaded: >' + _wi._weaponName + '< Mod:>' + _wi._mod + '<')
               self._weaponstimedwarn.append(_wi)
           else:
               self.debug('Timed Warn - Empty definition ignored')
               
       for e in self.config.get('weapon_timed_kick/weapon'):
           #name  = setting.get('name')
           _wi = WeaponInfo()
           if e.text:
               _wi._weaponName = e.text
           else:
               _wi._weaponName = ""
           
           _wi._mod = e.get('mod')
           
           if (_wi._mod != "" or _wi._weaponName != ""):
               self.debug('Timed Kick - Weapon loaded: >' + _wi._weaponName + '< Mod:>' + _wi._mod + '<')
               self._weaponstimedkick.append(_wi)
           else:
               self.debug('Timed Kick - Empty definition ignored')  
               
       for e in self.config.get('weapon_banned_kick/weapon'):
           #name  = setting.get('name')
           _wi = WeaponInfo()
           if e.text:
               _wi._weaponName = e.text
           else:
               _wi._weaponName = ""
           
           _wi._mod = e.get('mod')
           
           if (_wi._mod != "" or _wi._weaponName != ""):
               self.debug('Banned Kick - Weapon loaded: >' + _wi._weaponName + '< Mod:>' + _wi._mod + '<')
               self._bannedweaponskick.append(_wi)
           else:
               self.debug('Banned Kick - Empty definition ignored')                  
               
       for e in self.config.get('weapon_banned_warn/weapon'):
           #name  = setting.get('name')
           _wi = WeaponInfo()
           if e.text:
               _wi._weaponName = e.text
           else:
               _wi._weaponName = ""
           
           _wi._mod = e.get('mod')
           
           if (_wi._mod != "" or _wi._weaponName != ""):
               self.debug('Banned Warn - Weapon loaded: >' + _wi._weaponName + '< Mod:>' + _wi._mod + '<')
               self._bannedweaponswarn.append(_wi)
           else:
               self.debug('Banned Warn - Empty definition ignored')                    
           
       self._maps = []
       for e in self.config.get('maps/map'):
           #name  = setting.get('name')
           _mi = MapInfo();
           _mi._mapName = e.get('name')
           _mi._duration = int(e.text.strip())
           self.debug('Map parsed: ' + _mi._mapName + ' duration: ' + str(_mi._duration))
         
           self._maps.append(_mi);
       
       self.debug('Loading Configuration Finished')
       return
       
               
   def _usingWeaponsAllowed(self):
       self.debug(self._unlockmessage % self._warnduration)
       self.console.say(self._unlockmessage % self._warnduration)
       return
   
   def checkWeapon(self, weaponname, mod, player):
       if self.console.game.roundTime() <= self._warnduration:
           self.debug(weaponname + ' / ' + mod + ' - in warnduration: ' + str(self.console.game.roundTime()))
           #--------------------------------------------------------------------------------------#
           for weaponInfo in self._weaponstimedwarn:
               try:
                   if weaponInfo._weaponName == weaponname:
                       if(weaponInfo._mod == ""):
                           self.debug('Temporary Restricted Weapon: ' + str(weaponname) + ' - Round time: ' + str(self.console.game.roundTime()))
                           self.warnPlayerForTmpRestrictedWeapon(player)
                           return
                       else:
                           if(weaponInfo._mod == mod):
                               self.debug('Temporary Restricted Weapon: ' + str(weaponname) + ' Mod: ' + str(mod) + ' - Round time: ' + str(self.console.game.roundTime()))
                               self.warnPlayerForTmpRestrictedWeapon(player)
                               return
                           else:
                               return                
                   elif weaponInfo._weaponName == "":
                       if weaponInfo._mod == mod:
                           self.debug('Temporary Restricted MOD for weapon: ' + str(weaponname) + ' Mod: ' + str(mod) + ' - Round time: ' + str(self.console.game.roundTime()))
                           self.warnPlayerForTmpRestrictedWeapon(player)
                           return
               except:
                   self.debug('Unknown error while _weaponstimedwarn list processing')
           #--------------------------------------------------------------------------------------#
           for weaponInfo in self._weaponstimedkick:
               try:  
                   if weaponInfo._weaponName == weaponname:
                       if(weaponInfo._mod == ""):
                           self.debug('Temporary Restricted Weapon: ' + str(weaponname) + ' - Round time: ' + str(self.console.game.roundTime()))
                           self.kickPlayerForTmpRestrictedWeapon(player)
                           return
                       else:
                           if(weaponInfo._mod == mod):
                               self.debug('Temporary Restricted Weapon: ' + str(weaponname) + ' Mod: ' + str(mod) + ' - Round time: ' + str(self.console.game.roundTime()))
                               self.kickPlayerForTmpRestrictedWeapon(player)
                               return
                           else:
                               return
                   elif weaponInfo._weaponName == "":
                       if weaponInfo._mod == mod:
                           self.debug('Temporary Restricted MOD for weapon: ' + str(weaponname) + ' Mod: ' + str(mod) + ' - Round time: ' + str(self.console.game.roundTime()))
                           self.kickPlayerForTmpRestrictedWeapon(player)
                           return
                   
               except:
                   self.debug('Unknown error while _weaponstimedkick list processing')                                
       #--------------------------------------------------------------------------------------#
       for weaponInfo in self._bannedweaponswarn:
           try:            
               if weaponInfo._weaponName == weaponname:
                   if(weaponInfo._mod == ""):
                       self.debug('Banned Weapon: ' + str(weaponname) + ' - Round time: ' + str(self.console.game.roundTime()))
                       self.warnPlayerForBannedWeapon(player)
                       return
                   else:
                       if(weaponInfo._mod == mod):
                           self.debug('Banned Weapon: ' + str(weaponname) + ' Mod: ' + str(mod) + ' - Round time: ' + str(self.console.game.roundTime()))
                           self.warnPlayerForBannedWeapon(player)
                           return
                       else:
                           return
               elif weaponInfo._weaponName == "":
                   if weaponInfo._mod == mod:
                       self.debug('Banned MOD for weapon: ' + str(weaponname) + ' Mod: ' + str(mod) + ' - Round time: ' + str(self.console.game.roundTime()))
                       self.warnPlayerForBannedWeapon(player)
                       return
               
           except:
               self.debug('Unknown error while _bannedweaponswarn list processing')                                
       #--------------------------------------------------------------------------------------#
       for weaponInfo in self._bannedweaponskick:
           try:    
               if weaponInfo._weaponName == weaponname:
                   if(weaponInfo._mod == ""):
                       self.debug('Banned Weapon: ' + str(weaponname) + ' - Round time: ' + str(self.console.game.roundTime()))
                       self.kickPlayerForBannedWeapon(player)
                       return
                   else:
                       if(weaponInfo._mod == mod):
                           self.debug('Banned Weapon: ' + str(weaponname) + ' Mod: ' + str(mod) + ' - Round time: ' + str(self.console.game.roundTime()))
                           self.kickPlayerForBannedWeapon(player)
                           return
                       else:
                           return
               elif weaponInfo._weaponName == "":
                   if weaponInfo._mod == mod:
                       self.debug('Banned MOD for weapon: ' + str(weaponname) + ' Mod: ' + str(mod) + ' - Round time: ' + str(self.console.game.roundTime()))
                       self.kickPlayerForBannedWeapon(player)
                       return
           except:
               self.debug('Unknown error while _bannedweaponskick list processing')                                
                       
       #--------------------------------------------------------------------------------------#          
       return
       
       
   #---------------------------------------------------------------------------#
   # Penalties  / Kick  
   #---------------------------------------------------------------------------#
   def kickPlayerForBannedWeapon(self, player):
       if player:
           warningmsg = self.getKickWarningForBannedWeapon()
           self.debug('player.kick: ' + str(player.name) + ' Warn: ' + str(warningmsg))
           player.kick(warningmsg)
       return
       
   def kickPlayerForTmpRestrictedWeapon(self, player):
       if player:
           warningmsg = self.getKickWarningForTmpRestrictedWeapon()
           self.debug('player.kick: ' + str(player.name) + ' Warn: ' + str(warningmsg))
           player.kick(warningmsg, '', none)
       return        
   #---------------------------------------------------------------------------#
   # Penalties  / Warn  
   #---------------------------------------------------------------------------#
   def warnPlayerForTmpRestrictedWeapon(self, player):
       if player:
           warningrule = self.getWarningRuleForTmpRestrictedWeapon()
           self.debug('[TMP]WarnClient: ' + str(player.name) + ' WarnRule: ' + str(warningrule))
           self._adminPlugin.warnClient(player, warningrule , None, False)
       return    

   def warnPlayerForBannedWeapon(self, player):
       if player:
           warningrule = self.getWarningRuleForBannedWeapon()
           self.debug('[Banned]WarnClient: ' + str(player.name) + ' WarnRule: ' + str(warningrule))
           self._adminPlugin.warnClient(player, self._warningrule , None, False)
       return  
   #---------------------------------------------------------------------------#
   # WARNING RULES    
   #---------------------------------------------------------------------------#
   def getWarningRuleForBannedWeapon(self):
       return self._bannedwarningrule
   
   
   def getWarningRuleForTmpRestrictedWeapon(self):  
       return self._warningrule
   #---------------------------------------------------------------------------#
   
   #---------------------------------------------------------------------------#
   # Kick Messages  
   #---------------------------------------------------------------------------#
   def getKickWarningForBannedWeapon(self):
       defwarning = "Do not use banned weapon!"
       try:
           duration, warning = self._adminPlugin.getWarning(self._bannedwarningrule)
       except:
           warning = defwarning
       
       return warning
       
   def getKickWarningForTmpRestrictedWeapon(self):  
       defwarning = "Do not use restricted weapon!"
       try:
           duration, warning = self._adminPlugin.getWarning(self._warningrule)
       except:
           warning = defwarning
       
       return warning
   #---------------------------------------------------------------------------#

   def onEvent(self, event):
       if event.type == b3.events.EVT_CLIENT_KILL or event.type ==  b3.events.EVT_CLIENT_DAMAGE:
           weaponname = event.data[1]
           mod = event.data[3]
           self.checkWeapon(weaponname, mod, event.client)

       elif event.type == b3.events.EVT_GAME_ROUND_START:
           if self._currentMap == None or self.console.game.mapName != self._currentMap:
               self._currentMap = self.console.game.mapName
               self.debug('New Map: ' + str(self._currentMap))
               self._warnduration = self._warndurationdefault
               for mapinfo in self._maps:
                   if(mapinfo):
                       if self._currentMap == mapinfo._mapName:
                           self._warnduration = mapinfo._duration
                           self.debug('New Duration: ' + str(self._warnduration))
                           break
           if len(self._weaponstimedwarn) > 0 or len(self._weaponstimedkick) > 0:
               self.debug(self._infomessage % self._warnduration)
               self.console.say(self._infomessage % self._warnduration)
               t = threading.Timer(self._warnduration+1, self._usingWeaponsAllowed)
               t.start()
           if len(self._bannedweaponswarn) > 0 or len(self._bannedweaponskick) > 0:
               self.debug(self._bannedonlyinfomessage)
               self.console.say(self._bannedonlyinfomessage)                
           return

b3/extplugins/conf/plugin_antinoob.xml (for CoD4)

Code: xml


5
rule2
rule2
^3 %s seconds passed - ^3all weapons unlocked!!!
^3 No nades, airstrike, tubes or heli ^5first %s seconds of the round!!!
^3 Please, No marty/last stand, GL's or RPG's !!!









frag_grenade_short_mp
gl_ak47_mp
gl_g3_mp
gl_g36c_mp
gl_m4_mp
gl_m14_mp
gl_m16_mp
gl_mp
rpg_mp


b3/conf/b3.xml (Add the following line and change the priority after this plugins, so 10, 11 etc.)
Code: xml

Note
I know that this config is working well,  ofcourse you can try to make your own one. If that one is working, please share it with us.
« Last Edit: December 10, 2009, 03:45:51 PM by danger89 » Logged
Full Member
***
OS: Linux
Type: Owner dedicated server(s)
Gameservers: CoD4
Posts: 50
Offline Offline
« Reply #211 on: December 16, 2009, 08:52:49 AM »

I need to make a new message, otherwise I exceeded the max. chars  Grin

UPDATE:

I make a list of all weapons (& attachments) that are available in CoD4, because I couldn't find it on our website (!)

Quote
---Primary/Secondary & Attatchments---
ak47_acog_mp
ak47_gl_mp
ak47_mp
ak47_reflex_mp
ak47_silencer_mp
ak74u_acog_mp
ak74u_mp
ak74u_reflex_mp
ak74u_silencer_mp
g36c_acog_mp
g36c_gl_mp
g36c_mp
g36c_reflex_mp
g36c_silencer_mp
g3_acog_mp
g3_gl_mp
g3_mp
g3_reflex_mp
g3_silencer_mp
gl_ak47_mp
gl_g36c_mp
gl_g3_mp
gl_m14_mp
gl_m16_mp
gl_m4_mp
m14_acog_mp
m14_gl_mp
m14_mp
m14_reflex_mp
m14_silencer_mp
m16_acog_mp
m16_gl_mp
m16_mp
m16_reflex_mp
m16_silencer_mp
m4_acog_mp
m4_gl_mp
m4_mp
m4_reflex_mp
m4_silencer_mp
m60e4_acog_mp
m60e4_grip_mp
m60e4_mp
m60e4_reflex_mp
mp44_mp
mp5_acog_mp
mp5_mp
mp5_reflex_mp
mp5_silencer_mp
p90_acog_mp
p90_mp
p90_reflex_mp
p90_silencer_mp
remington700_acog_mp
remington700_mp
rpd_acog_mp
rpd_grip_mp
rpd_mp
rpd_reflex_mp
saw_acog_mp
saw_grip_mp
saw_mp
saw_reflex_mp
skorpion_acog_mp
skorpion_mp
skorpion_reflex_mp
skorpion_silencer_mp
uzi_acog_mp
uzi_mp
uzi_reflex_mp
uzi_silencer_mp

---Snipers & Attatchments---
barrett_acog_mp
barrett_mp
dragunov_acog_mp
dragunov_mp
m40a3_acog_mp
m40a3_mp
m21_acog_mp
m21_mp

---Shotguns & Attatchments---
winchester1200_grip_mp
winchester1200_mp
winchester1200_reflex_mp
m1014_grip_mp
m1014_mp
m1014_reflex_mp
   
---Pistols & Attatchments---
colt45_mp
colt45_silencer_mp
deserteaglegold_mp
deserteagle_mp
usp_mp
usp_silencer_mp
beretta_mp
beretta_silencer_mp
   
---Demolitions---
c4_mp
claymore_mp
rpg_mp

---Perks---
frag_grenade_short_mp

For example:

Code: xml
  
   
 m16_mp
 
« Last Edit: February 26, 2010, 05:18:59 AM by danger89 » Logged
Newbie
*
OS: Windows
Type: Renting Server with B3
Gameservers: CoD4
Posts: 1
Offline Offline
« Reply #212 on: February 25, 2010, 03:30:05 AM »

 Huh I can't find the code for last stand.... I need this!    Grin


Xfire is: ironeagleeye             I am almost always on
« Last Edit: February 25, 2010, 03:34:01 AM by neatherstalker » Logged
XLRstats dev.
XLRstats dev
Full Member
*****
OS: Linux
Type: Home user
Gameservers: COD4, SmG
Posts: 73
Offline Offline
WWW
« Reply #213 on: February 25, 2010, 05:02:44 AM »

You can't do that as it's like any other pistol kills.
Logged



Full Member
***
OS: Linux
Type: Owner dedicated server(s)
Gameservers: CoD4
Posts: 50
Offline Offline
« Reply #214 on: February 25, 2010, 05:14:30 AM »

Huh I can't find the code for last stand.... I need this!    Grin

Yep that is right, it's unpossible to register last stand nor Martydrom. I just need it too very hard...
Logged
XLRstats dev.
XLRstats dev
Full Member
*****
OS: Linux
Type: Home user
Gameservers: COD4, SmG
Posts: 73
Offline Offline
WWW
« Reply #215 on: February 25, 2010, 05:28:43 AM »

For martyrdom you can define "frag_grenade_short_mp" in weapons.
Logged



Full Member
***
OS: Linux
Type: Owner dedicated server(s)
Gameservers: CoD4
Posts: 50
Offline Offline
« Reply #216 on: February 25, 2010, 06:08:37 AM »

For martyrdom you can define "frag_grenade_short_mp" in weapons.

Your serious :| Why does nobody knows that ? Because all the nades will be dedected as a nade?
Logged
XLRstats dev.
XLRstats dev
Full Member
*****
OS: Linux
Type: Home user
Gameservers: COD4, SmG
Posts: 73
Offline Offline
WWW
« Reply #217 on: February 25, 2010, 06:44:11 AM »

Actually I'm not the only one who knows that  Smiley  It's mentioned even in the first page of this topic.
Logged



Full Member
***
OS: Linux
Type: Owner dedicated server(s)
Gameservers: CoD4
Posts: 50
Offline Offline
« Reply #218 on: February 25, 2010, 08:42:17 AM »

Actually I'm not the only one who knows that  Smiley  It's mentioned even in the first page of this topic.

Nope, your not standing at the beginning of this topic at all, besides that Anti-noob will kick/tempban all players who also using just a normal nade...
Logged
XLRstats dev.
XLRstats dev
Full Member
*****
OS: Linux
Type: Home user
Gameservers: COD4, SmG
Posts: 73
Offline Offline
WWW
« Reply #219 on: February 25, 2010, 11:55:27 PM »

No I'm not standing at the first post. I said it is mentioned in one of the posts there. I don't know why it is kicking all nades in your server. We are using the version 1.0.3 of this plugin in our CoDWaW server and it's successfuly warning only martyrdom while normal nades can be used without any problem.
Logged



Full Member
***
OS: Linux
Type: Owner dedicated server(s)
Gameservers: CoD4
Posts: 50
Offline Offline
« Reply #220 on: February 26, 2010, 05:14:01 AM »

No I'm not standing at the first post. I said it is mentioned in one of the posts there. I don't know why it is kicking all nades in your server. We are using the version 1.0.3 of this plugin in our CoDWaW server and it's successfuly warning only martyrdom while normal nades can be used without any problem.
You said: "first page of this topic.". But never mind, I understand you Wink

It was rather an assumption / question than a fact. But I will try the anti-(noob) marydrom  Grin

EDIT:

Strange, I got the line already, but nobody was warned for using Marty. My part of the config file:

Code: xml
	

frag_grenade_short_mp  
gl_ak47_mp
gl_g3_mp
gl_g36c_mp
gl_m4_mp
gl_m14_mp
gl_m16_mp
gl_mp
rpg_mp
saw_acog_mp
saw_grip_mp
saw_mp
saw_reflex_mp
rpd_acog_mp
rpd_grip_mp
rpd_mp
rpd_reflex_mp
m60e4_acog_mp
m60e4_grip_mp
m60e4_mp
m60e4_reflex_mp
rpg_mp
« Last Edit: February 26, 2010, 05:21:49 AM by danger89 » Logged
Tags:
Pages: 1 ... 13 14 [15]   Go Up
  Print  
 
Jump to: