Forums

BF2Statistics.com :: Forums :: Off Topic

I need a No Commander script

C4 boom! cya at heaven
legayo

Joined: Sun Jul 26 2009, 10:00AM
Posts: 17
hi.. today i post here becouse i hate commanders in small-size maps and if someone help me posting a script who disable commander mode [completely] i will be grateful
Website
Krauzi
Krauzi

Joined: Fri Dec 14 2007, 12:06PM
Posts: 30
you cannot dissable the commander without creating a mod (and disable the button there).
The only thing you can do is warn and kick players who are commanders.
Im not at home right know so i cannot help you much, but this site could help you out:
http://bf2tech.org/index.php/Scripts:BF2Oldschool
Shark-kun

Joined: Sun Nov 26 2006, 02:56PM
Posts: 153
What you do not like the script?
  1. # Commander Kill System
  2.  
  3. # Module: comdis.py
  4. # Author: REW
  5. # Version: 1.0
  6.  
  7.  
  8. import bf2
  9. import host
  10. import mm_utils
  11. from bf2.stats.constants import *
  12. from bf2 import g_debug
  13.  
  14. #debug flag
  15. sks_debug = False # for verbose server console messages
  16.  
  17. #variable settings; intervals are in seconds
  18. minP = 10 # max players for 'no commanders' mode
  19. killInterval = 5 # time before a commander is killed
  20. msgInterval = 90 # time between warning messages
  21.  
  22. #timers
  23. msgTimer = None
  24.  
  25. #queue lists
  26. killList = []
  27.  
  28. __version__ = 1.0
  29.  
  30. __required_modules__ = {
  31.     'modmanager': 1.2
  32. }
  33.  
  34. __supports_reload__ = True
  35.  
  36. __description__ = "ModManager Commander Killer v%s" % __version__
  37.  
  38. class ComDis( object ):
  39.  
  40.     def __init__( self, modManager ):
  41.         # ModManager reference
  42.         self.mm = modManager
  43.         self.__state = 0
  44.        
  45.     # Initialize the kill system i.e. register game hooks.
  46.     def init( self ):
  47.         if 0 == self.__state:
  48.             host.registerHandler('PlayerSpawn', self.onPlayerSpawn, 1)
  49.             #host.registerHandler('EnterVehicle', self.onEnterVehicle, 1)
  50.             host.registerHandler('ChangedCommander', self.onChangedCommander, 1)
  51.             host.registerGameStatusHandler(self.onGameStatusChanged)
  52.         self.__state = 1
  53.  
  54.     def onChangedCommander(self, team, oldCmd, newCmd):
  55.         self.CheckForCommander()
  56.        
  57.     # On spawn, checks if the player is a commander.
  58.     # Player is added to kill list if player is a commander.
  59.     def onPlayerSpawn(self, p, vehicle):
  60.         self.CheckForCommander()
  61.    
  62.     # On enter vehicle, checks if the any player is a commander.
  63.     # Player is added to kill list if player is a commander.
  64.     def onEnterVehicle( self, p, vehicle, freeSoldier):
  65.         self.CheckForCommander()
  66.  
  67.     def CheckForCommander( self ):
  68.         global sks_debug
  69.         global killList, killInterval, minP
  70.         players = bf2.playerManager.getPlayers()
  71.         numP = bf2.playerManager.getNumberOfPlayers()
  72.         for pl in players:
  73.             if pl.isCommander() and numP <= minP:
  74.                 # Add the player if not in kill list
  75.                 if killList.count(pl.index) == 0:
  76.                     killList.append(pl.index)
  77.                    
  78.                     # Set timer for kill
  79.                     bf2.Timer(self.onKillTimer, killInterval, 1)
  80.                
  81.                 # Issue kill warning
  82.                 mm_utils.msg_server( "§3= SCRIPT: §C1001%s§C1001, §C1001NO COMMANDERS§C1001! You will §C1001DIE§C1001 in §C1001%s§C1001 sec! =" % ( pl.getName(), killInterval ))
  83.  
  84.        
  85.     # Sends out warning messages
  86.     def onMsgTimer(self, data):
  87.         global sks_debug
  88.         global minP
  89.         numP = bf2.playerManager.getNumberOfPlayers()
  90.         commander1 = bf2.playerManager.getCommander(1)
  91.         commander2 = bf2.playerManager.getCommander(2)
  92.         #if ((commander1 != None) or (commander2 != None)) and (numP <= minP):
  93.         if (numP <= minP):
  94.             mm_utils.msg_server( "= SCRIPT: §C1001NO COMMANDERS§C1001 or you will §C1001DIE§C1001! Players: §C1001%s§C1001<§C1001%s§C1001 =" % ( numP, minP+1 ) )
  95.        
  96.     # Processes the kill list queue. The next player in queue
  97.     # is checked again and killed if a commander.
  98.     def onKillTimer(self, data):
  99.         global sks_debug
  100.         global killList
  101.         global minP
  102.        
  103.         # Process the next player in queue.
  104.         p = bf2.playerManager.getPlayerByIndex(killList.pop(0))
  105.         numP = bf2.playerManager.getNumberOfPlayers()
  106.         # Player is still a commander, kill him.
  107.         if p.isCommander() and p.isValid() and p.isAlive() and (numP <= minP):
  108.             #host.rcon_invoke("admin.kickPlayer " + str(p.index))
  109.             vehicle = p.getVehicle()
  110.             rootVehicle = getRootParent(vehicle)
  111.             if getVehicleType(rootVehicle.templateName) == VEHICLE_TYPE_SOLDIER:
  112.                 rootVehicle.setDamage(0)
  113.                 # This should kill them !
  114.             else:
  115.                 rootVehicle.setDamage(0.01)
  116.                 # a vehicle will likely explode within 0.3 sec killing entire crew,
  117.                 # not so sure about base defenses though
  118.             p.score.score = p.score.score - 5
  119.             mm_utils.msg_server( "= SCRIPT: commander §C1001%s§C1001 was punished by \'Commander Killer\' script =" % ( p.getName() ) )
  120.  
  121.     # Handles clean up and initialization between rounds.
  122.     def onGameStatusChanged(self, status):
  123.         global killList
  124.         global msgInterval, msgTimer
  125.        
  126.         if status == bf2.GameStatus.Playing:
  127.            
  128.             # Set the warning timer.
  129.             msgTimer = bf2.Timer(self.onMsgTimer, msgInterval, 1)
  130.             msgTimer.setRecurring(msgInterval)
  131.            
  132.         elif status == bf2.GameStatus.PreGame:
  133.            
  134.             # Destroy any timers
  135.             msgTimer.destroy()
  136.             msgTimer = None
  137.            
  138.             # Blank the list.
  139.             killList = []
  140.        
  141.         elif status == bf2.GameStatus.EndGame:
  142.             pass
  143.  
  144.  
  145.     def shutdown( self ):
  146.         """Shutdown and stop processing."""
  147.        
  148.         # Unregister our handlers
  149.         host.unregisterGameStatusHandler( self.onGameStatusChanged )
  150.        
  151.         # Unregister our game handlers
  152.         # Flag as shutdown as there is currently way to do this
  153.         self.__state = 2
  154.  
  155. def mm_load( modManager ):
  156.     """Creates your object."""
  157.     return ComDis( modManager )
Website
C4 boom! cya at heaven
legayo

Joined: Sun Jul 26 2009, 10:00AM
Posts: 17
maybe ill take shark's script.. i hate BF2 old school it only works with PB...wagg but maybe someone can help me modding?? to disable the button like WYD Elite Snipers Server at V1.0
Website
C4 boom! cya at heaven
legayo

Joined: Sun Jul 26 2009, 10:00AM
Posts: 17
ohhhhhhhh i've found the magic key people!!!!!

i've searching at the folders of the server and i found this archive at %Battlefield2serverRoot%/mods/bf2/phyton/game/gamemodes/gpm_cq.py at line 28 and 30
host.sh_setEnable_Commander (1) [original] and i set it to 0 and vualà commander mode eliminated!!!!!
Website

Moderators: MrNiceGuy, Twhyman, Chump, hurr1k4ne, The Shadow, Wilson212

<< Previous thread | Next thread >>

Jump:     Back to top