Помощь - Поиск - Пользователи - Календарь
Полная версия этой страницы: ищу baserape под сервер 1.5,win32
Форумы Боевого Народа > Игры > Форумы игр серии Battlefield > Форум администраторов
$korpi()n
ищу скрипт baserape под сервер 1.5,win32
maiorBoltach
# ------------------------------------------------------------------------
# Module: AntiBaseRape.py
# Author: SHAnders
# Port to bf2cc/mm: graag42
#
# Version 1.11
#
# Changes:
# v1.1 -> 1.11
# Fixed the timer to only be started once
# v1.0 -> 1.1
# Implemted a baseRapeWarning attribute on players to count safe base kills
# Implemted allowed amount of safe base kills (3)
# up to this amount player only loses kill points + 1 score pr baseRapeWarning
# over this amount player is allso killed
# Implemtes a timer for removing 1 baseRapeWarning every 2 minutes
#
# Description:
# Server side only admin script
#
# This script will punish players who kill enemy within the area of a safe base
#
# Requirements:
# None.
#
# Installation as Admin script:
# 1: Save this script as 'AntiBaseRape.py' in your <bf2>/admin/standard_admin directory.
# 2: Add the lines 'import AntiBaseRape' and 'AntiBaseRape.init()' to the file
# '<bf2>/admin/standard_admin/__init__.py'.
#
# TODO:
# Since not all maps are alike, the requirements for base rape protiction
# should be able to be altered individualy for each control point.
#
# Thanks to:
# Battlefield.no for inspiration from their pingkick.py script
#
# ------------------------------------------------------------------------

import host
import bf2
import math
import mm_utils
from bf2.stats.constants import *
from bf2 import g_debug

# Set the version of your module here
__version__ = 1.11

# Set the required module versions here
__required_modules__ = {
'modmanager': 1.0
}

# Does this module support reload ( are all its reference closed on shutdown? )
__supports_reload__ = True

# Set the description of your module here
__description__ = "AntiBaseRape v%s" % __version__

# ------------------------------------------------------------------------
# Constants
# ------------------------------------------------------------------------

DEFAULT_SAFEBASE_RADIUS = 50 # Default safe area radius (normal commandpoint radius = 10)
ALLOWED_SAFEBASEKILLS = 3
SAFEBASEKILL_TIMER_INTERVAL = 120 # Intervals between removing a point from players.baseRapeWarning

# ------------------------------------------------------------------------
# Variables
# ------------------------------------------------------------------------

WarnReduceTimer = None # Timer that reduces the warnings at intervals

# ------------------------------------------------------------------------
# Init
# ------------------------------------------------------------------------

class BaseRape( object ) :

def __init__( self, modManager ):
# ModManager reference
self.mm = modManager

# Internal shutdown state
self.__state = 0

def init( self ):
if g_debug: print "AntiBaseRape init"
if 0 == self.__state:
host.registerHandler('PlayerConnect', self.onPlayerConnect, 1)
host.registerHandler('PlayerKilled', self.onPlayerKilled)

# Update to the running state
self.__state = 1

# Start the timer that reduces warnings on the SAFEBASEKILL_TIMER_INTERVAL
WarnReduceTimer = bf2.Timer(self.onSafeBaseKillTimer, SAFEBASEKILL_TIMER_INTERVAL, 1)
WarnReduceTimer.setRecurring(SAFEBASEKILL_TIMER_INTERVAL)

# Connect already connected players if reinitializing
for p in bf2.playerManager.getPlayers():
self.onPlayerConnect(p)
# ------------------------------------------------------------------------


# ------------------------------------------------------------------------
# onPlayerConnect
# ------------------------------------------------------------------------
def onPlayerConnect(self, player):
self.resetPlayer(player)
# ------------------------------------------------------------------------


# ------------------------------------------------------------------------
# onPlayerKilled
# ------------------------------------------------------------------------
def onPlayerKilled(self, victim, attacker, weapon, assists, object):
# killed by self
if attacker == victim:
pass

# killed by enemy
elif attacker != None and attacker.getTeam() != victim.getTeam():
self.checkForSafeBase(attacker, victim)
# ------------------------------------------------------------------------


def shutdown( self ):
"""Shutdown and stop processing."""

# Unregister game handlers and do any other
# other actions to ensure your module no longer affects
# the game in anyway
if WarnReduceTimer:
WarnReduceTimer.destroy()
WarnReduceTimer = None

# Flag as shutdown as there is currently way to:
# host.unregisterHandler
self.__state = 2

# ------------------------------------------------------------------------
# Reset the number of warnings
# ------------------------------------------------------------------------
def resetPlayer(self, player):
player.baseRapeWarning = 0
# ------------------------------------------------------------------------


# ------------------------------------------------------------------------
# Check if victim was killed within safebase area
# ------------------------------------------------------------------------
def checkForSafeBase(self, attacker, victim):
victimVehicle = victim.getVehicle()
controlPoints = bf2.objectManager.getObjectsOfType('dice.hfe.world.ObjectTemplate.ControlPoint')
for cp in controlPoints:
if cp.cp_getParam('unableToChangeTeam') != 0 and cp.cp_getParam('team') != attacker.getTeam():
distanceTo = self.getVectorDistance(victimVehicle.getPosition(), cp.getPosition())
if DEFAULT_SAFEBASE_RADIUS > float(distanceTo):
self.justify(attacker, victim, cp, distanceTo)
# ------------------------------------------------------------------------


# ------------------------------------------------------------------------
# Punish attacker, give victim life back and inform all
# ------------------------------------------------------------------------
def justify(self, attacker, victim, controlPoint, distanceTo):
victim.score.deaths += -1
attacker.score.kills += -1
attacker.score.score += -2 - attacker.baseRapeWarning
attacker.baseRapeWarning += 1
self.sendWarning(attacker, controlPoint, distanceTo)
if attacker.baseRapeWarning > ALLOWED_SAFEBASEKILLS:
attacker.score.TKs += 1
if attacker.isAlive():
vehicle = attacker.getVehicle()
rootVehicle = getRootParent(vehicle)
if getVehicleType(rootVehicle.templateName) == VEHICLE_TYPE_SOLDIER:
rootVehicle.setDamage(0)
# This should kill them !
else:
rootVehicle.setDamage(1)
# a vehicle will likely explode within 1 sec killing entire crew,
# not so sure about base defenses though
# ------------------------------------------------------------------------


# ------------------------------------------------------------------------
# Send Warning
# ------------------------------------------------------------------------
def sendWarning(self, player, controlPoint, distanceTo):
mapName = bf2.gameLogic.getMapName()
if player.baseRapeWarning > ALLOWED_SAFEBASEKILLS:
mm_utils.msg_server(player.getName() + " is punished for repeated violating of the no kill rules within safe base area")
else:
mm_utils.msg_server(player.getName() + " has violated the no kill rules within safe base area " + str(player.baseRapeWarning) + " times now")
# ------------------------------------------------------------------------


# ------------------------------------------------------------------------
# remove baseRapeWarnings over time
# ------------------------------------------------------------------------
def onSafeBaseKillTimer(self, data):
for p in bf2.playerManager.getPlayers():
if p.baseRapeWarning <= 0:
p.baseRapeWarning = 0
else:
p.baseRapeWarning += -1
# ------------------------------------------------------------------------


# ------------------------------------------------------------------------
# get distance between two positions
# ------------------------------------------------------------------------
def getVectorDistance(self, pos1, pos2):
diffVec = [0.0, 0.0, 0.0]
diffVec[0] = math.fabs(pos1[0] - pos2[0])
diffVec[1] = math.fabs(pos1[1] - pos2[1])
diffVec[2] = math.fabs(pos1[2] - pos2[2])

return math.sqrt(diffVec[0] * diffVec[0] + diffVec[1] * diffVec[1] + diffVec[2] * diffVec[2])
# ------------------------------------------------------------------------


# ------------------------------------------------------------------------
# ModManager Init
# ------------------------------------------------------------------------
def mm_load( modManager ):
"""Creates and returns your object."""
return BaseRape( modManager )


$korpi()n
если install к этому скрипту?
sh@rk
Установка нового модуля

Создаётся, или распаковываешь, или проста скидываешь его в директорию в сервере "admin/modules", потом редактируется в "mods/bf2/settings/modmanager.con" добавляешь туда следующие:

modmanager.loadModule "<тут собственно новый модуль>"

Installing new modules

пример, сохраняю этот скрипт как mm_AntiBaseRape.py и скидываю его сюда <dir bf2 server>admin/modules, а патом редактирую <dir bf2 server>mods/bf2/settings/modmanager.con

modmanager.loadModule "mm_AntiBaseRape"

и радуемся работе скрипта!
Excavator
Кто ко мне в аську писал насчёт этого скрипта и его "анти-спам" послал?
Пишите ещё раз - жду. Сервер, правда, у меня в оффлайне, жду окончания каникул, чтоб к нему пробраться, но по памяти чем могу помогу.
$korpi()n
я писал!
дай свои скайп!
-Military-
у меня почемуто не робят скрипты? в чём может быть проблема, всё по инструкции устанавливал
sh@rk
что ставил и как?
-Military-
modmanager.con
Раскрывающийся текст
#
# Multiplay, ModManager
#
modmanager.autoSave 1
modmanager.banManagerModule "mm_banmanager"
modmanager.debugEnable 0
modmanager.debugFile "modmanager_debug.log"
modmanager.homeGuess "C:/Documents and Settings/Евгений/My Documents/Battlefield 2/"
modmanager.logAppend 0
modmanager.logAutoFlush 1
modmanager.logDateFormat "[%Y-%m-%d %H:%M:%S] "
modmanager.logLevel 2
modmanager.logModule "mm_logger"
modmanager.moduleBase "modules"
modmanager.rconModule "mm_rcon"

# Modules
modmanager.loadModule "mm_tk_punish"
modmanager.loadModule "mm_kicker"
modmanager.loadModule "mm_announcer"
modmanager.loadModule "mm_bf2cc"
modmanager.loadModule "mm_autobalance"
modmanager.loadModule "mm_AntiBaseRape.py"
#modmanager.loadModule "mm_reserver"

#
# ModManager Announcer
#
#mm_announcer.addTimedMessage "30:300:Server Rules: No team killing, no stats padding, keep the teams balanced and play fair!"

#
# ModManager Team autobalance
#
mm_autobalance.allowCommander 0
mm_autobalance.allowSquadLeader 0
mm_autobalance.allowSquadMember 0
mm_autobalance.roundSwitch 0

#
# BF2CC for ModManager
#
mm_bf2cc.chatBufferSize 50
mm_bf2cc.serverChatFormat "[Administrator: %s] %s"

#
# ModManager Logger
#
mm_logger.logAppend 0
mm_logger.logAutoFlush 1
mm_logger.logFilename "modmanager.log"

#
# ModManager Player Kicker
#
mm_kicker.banLimit 1
mm_kicker.banPeriod "Round"
mm_kicker.banWordReason "Using bad / racist language"
mm_kicker.enableChatChecks 0
mm_kicker.idleIgnoreNotStarted 1
mm_kicker.idleLimit 0
mm_kicker.initDelay 60
mm_kicker.kickDelay 5
mm_kicker.kickLimit 3
mm_kicker.kickMessage "Sorry '%s' your are being kicked ( %s )"
mm_kicker.kickType 1
mm_kicker.kickWordReason "Using bad / racist language"
mm_kicker.maxPing 0
mm_kicker.minPing 0
mm_kicker.negScoreKick 0
mm_kicker.pingLimit 8
mm_kicker.positionDelay 120
mm_kicker.samplePeriod 120
mm_kicker.sampleRate 10
mm_kicker.warnWordMessage "WARNING: Please refrain from using bad / racist language on this server '%s'"

#
# ModManager Rcon
#
mm_rcon.allowBatching 1
mm_rcon.basicAuthLevel 50
mm_rcon.enableLinger 0
mm_rcon.lingerFor 1
mm_rcon.logCommands 0
mm_rcon.loginMessage "%s became a server administrator"
mm_rcon.logoutMessage "%s gave up administrator rights"
mm_rcon.rconBasicPassword
mm_rcon.rconIp "188.226.126.160"
mm_rcon.rconListenQueue 1
mm_rcon.rconPassword "p00787217"
mm_rcon.rconPort 4716
mm_rcon.reuseAddress 1
mm_rcon.superAuthLevel 100
mm_rcon.defaultGametype "gpm_cq"
mm_rcon.advancedMapSizeValidation 0

#
# ModManager Reserver
#
mm_reserver.kickDelay 5
mm_reserver.kickReason "Reserved slots reached"
mm_reserver.kickMode 2
mm_reserver.kickType 1
mm_reserver.privatePassword ""
mm_reserver.reservedSlots 1

#
# ModManager Team kill punisher
#
mm_tk_punish.announcePunishments 0
mm_tk_punish.banMessageDelay 5
mm_tk_punish.bannedBy "ModManager Team Kill Punisher"
mm_tk_punish.banPeriod "Round"
mm_tk_punish.banReason "Team killing"
mm_tk_punish.forgiveMessage "TKPUNISH: %s forgives %s for a teamkill (%s has %d punishes and %d forgives)"
mm_tk_punish.punishMessage "TKPUNISH: %s punishes %s for a teamkill (%s has %d punishes and %d forgives)"
mm_tk_punish.punishTime 20

#
# ModManager BanManager
#
mm_banmanager.banFilename "mm_bans.xml"
mm_banmanager.banMessage "%s you are being banned (reason: %s)"
mm_banmanager.defaultBanAddress "N/A"
mm_banmanager.defaultBanCdKeyHash "N/A"
mm_banmanager.defaultBanDelay 0
mm_banmanager.defaultBanMethod "Key"
mm_banmanager.defaultBanNick "N/A"
mm_banmanager.defaultBanPeriod "Perm"
mm_banmanager.defaultBanReason "Unknown"
mm_banmanager.defaultKickDelay 5
mm_banmanager.defaultKickReason "Unknown"
mm_banmanager.defaultUnBanReason "Unknown"
mm_banmanager.kickMessage "%s you are being kicked (reason: %s)"
mm_banmanager.dateTimeFormat "%a %b %d %H:%M:%S %Y"
mm_banmanager.oldDateTimeFormat "%a %b %d %H:%M:%S %Y"

__init__.py
Раскрывающийся текст
import autobalance
import tk_punish
import playerconnect
import AntiBaseRape
import dc_automap
import dc_teamtickets

autobalance.init()
tk_punish.init()
playerconnect.init()
AntiBaseRape.init()
dc_automap.init()
dc_teamtickets.init()

не работает скрипт базрейпа, dc_automap.py, dc_teamtickets.py и MM MapAutoSizer, что неправильно зделал?
-Military-
лог вот ещё modmanager
Раскрывающийся текст
[2012-01-13 13:48:50] Info: Module 'mm_logger' initialised
[2012-01-13 13:48:50] Info: Creating Multiplay, ModManager v2.0 for Battlefield 2 (www.multiplay.co.uk)
[2012-01-13 13:48:50] Info: Starting ModManager Rcon v6.1 on 188.226.126.160:4716
[2012-01-13 13:48:50] Info: Rcon command handler 'login' registered
[2012-01-13 13:48:50] Info: Rcon command handler 'logout' registered
[2012-01-13 13:48:50] Info: Rcon command handler 'users' registered
[2012-01-13 13:48:50] Info: Rcon command handler 'kick' registered
[2012-01-13 13:48:50] Info: Rcon command handler 'ban' registered
[2012-01-13 13:48:50] Info: Rcon command handler 'banby' registered
[2012-01-13 13:48:50] Info: Rcon command handler 'banlist' registered
[2012-01-13 13:48:50] Info: Rcon command handler 'unban' registered
[2012-01-13 13:48:50] Info: Rcon command handler 'clearbans' registered
[2012-01-13 13:48:50] Info: Rcon command handler 'list' registered
[2012-01-13 13:48:50] Info: Rcon command handler 'profileid' registered
[2012-01-13 13:48:50] Info: Rcon command handler 'profileids' registered
[2012-01-13 13:48:50] Info: Rcon command handler 'listlocked' registered
[2012-01-13 13:48:50] Info: Rcon command handler 'maplist' registered
[2012-01-13 13:48:50] Info: Rcon command handler 'map' registered
[2012-01-13 13:48:50] Info: Rcon command handler 'exec' registered
[2012-01-13 13:48:50] Info: Rcon command handler 'help' registered
[2012-01-13 13:48:50] Info: Rcon command handler '?' registered (alias)
[2012-01-13 13:48:50] Info: ModManager Rcon started
[2012-01-13 13:48:50] Info: Module 'mm_rcon' v6.1 loaded
[2012-01-13 13:48:50] Info: Module 'mm_rcon' initialised
[2012-01-13 13:48:50] Info: Module 'mm_banmanager' v3.6 loaded
[2012-01-13 13:48:50] Info: Rcon command handler 'bm' registered
[2012-01-13 13:48:50] Info: Module 'mm_banmanager' initialised
[2012-01-13 13:48:50] Info: Module 'mm_tk_punish' v2.2 loaded
[2012-01-13 13:48:50] Error: Failed to load module 'mm_mapautosizer' ( No module named mm_mapautosizer )
[2012-01-13 13:48:50] Error: Traceback (most recent call last):
File "admin\modmanager.py", line 588, in __loadModule
module = __import__( module_name )
ImportError: No module named mm_mapautosizer
[2012-01-13 13:48:50] Info: Module 'mm_kicker' v2.5 loaded
[2012-01-13 13:48:50] Error: Failed to load module 'mm_AntiBaseRape.py' ( No module named mm_AntiBaseRape.py )
[2012-01-13 13:48:50] Error: Traceback (most recent call last):
File "admin\modmanager.py", line 588, in __loadModule
module = __import__( module_name )
ImportError: No module named mm_AntiBaseRape.py
[2012-01-13 13:48:51] Info: Module 'mm_announcer' v1.7 loaded
[2012-01-13 13:48:51] Info: Module 'mm_bf2cc' v7.0 loaded
[2012-01-13 13:48:51] Info: Module 'mm_autobalance' v2.3 loaded
[2012-01-13 13:48:51] Info: Loaded 5 additional modules
[2012-01-13 13:48:51] Info: Rcon command handler 'mm' registered
[2012-01-13 13:48:51] Info: Module 'mm_tk_punish' initialised
[2012-01-13 13:48:51] Info: Rcon command handler 'kicker' registered
[2012-01-13 13:48:51] Info: Module 'mm_kicker' initialised
[2012-01-13 13:48:51] Info: Rcon command handler 'announcer' registered
[2012-01-13 13:48:51] Info: Module 'mm_announcer' initialised
[2012-01-13 13:48:51] Info: Rcon command handler 'bf2cc' registered
[2012-01-13 13:48:51] Info: Module 'mm_bf2cc' initialised
[2012-01-13 13:48:51] Info: Module 'mm_autobalance' initialised
[2012-01-13 13:48:51] Info: Initialised 5 modules
[2012-01-13 13:49:12] Info: Validating maplist...
[2012-01-13 13:49:12] Info: No maplist changes required
[2012-01-13 13:49:13] Info: Authed 'tcp: 188.226.126.160:63843' by AdminServer.basicAuth at level 100
[2012-01-13 13:49:18] Info: Authed 'tcp: 188.226.126.160:63844' by AdminServer.basicAuth at level 100
[2012-01-13 13:49:46] Info: Authed 'tcp: 188.226.126.160:63850' by AdminServer.basicAuth at level 100
[2012-01-13 13:49:47] Info: cmdExec 'maplist.list' by tcp: 188.226.126.160:63850
[2012-01-13 13:49:47] Info: cmdExec 'admin.nextLevel' by tcp: 188.226.126.160:63850
[2012-01-13 13:49:48] Info: cmdExec 'admin.currentLevel' by tcp: 188.226.126.160:63850
[2012-01-13 13:49:49] Info: cmdExec 'maplist.list' by tcp: 188.226.126.160:63850
[2012-01-13 13:49:50] Info: cmdExec 'admin.nextLevel' by tcp: 188.226.126.160:63850
[2012-01-13 13:49:50] Info: cmdExec 'admin.currentLevel' by tcp: 188.226.126.160:63850
[2012-01-13 13:50:30] Info: cmdExec 'maplist.list' by tcp: 188.226.126.160:63850
[2012-01-13 13:50:31] Info: cmdExec 'maplist.list' by tcp: 188.226.126.160:63850
maiorBoltach
Цитата
[2012-01-13 13:48:50] Error: Failed to load module 'mm_AntiBaseRape.py' ( No module named mm_AntiBaseRape.py )


Нету файла с самим скриптом. Он его не видит
sh@rk
а, ты сам скрипт куда кидал "mm_AntiBaseRape.py"?

Цитата
[2012-01-13 13:48:50] Error: Failed to load module 'mm_AntiBaseRape.py' ( No module named mm_AntiBaseRape.py )

так как он этого скрипта в папке "modules" не видит!
-Military-
туда кинул шяс скрины дам обоих папок
Папка Admin
http://clip2net.com/s/1ueih
Папка modules
http://clip2net.com/s/1ueiC
папка standard_admin
http://clip2net.com/s/1ueiH
-Military-
во спс а другие почему скрипты не идут у меня? например на рандомное переключение карт
sh@rk
mm_baserape_v1.py
Описание
При убийстве врага с использованием пехоты, техники на вражеской НТ в пределах некоторого радиуса убившему бойцу выносится предупреждение.
После 1-го (на 2-ее) предупреждение - боец умрёт, техника взрывается. Каждые 5 минут предупреждение сгорает.

Дополнительно
DEFAULT_SAFEBASE_RADIUS = 50 - радиус действия скрипта по умолчанию на НТ (это радиус будит работать на тех картах, которые не указаны в скрипте!)
ALLOWED_SAFEBASEKILLS = 2 - количество предупреждений
примечание: если выставить 0, то боец умрёт сразу, техника будит сразу взрываться!
SAFEBASEKILL_TIMER_INTERVAL = 300 - время сгорание предупреждения

Параметры
Экспериментальным путем были заданы следующие радиусы для карт (в метрах от флага на НТ) в которых будит действовать скрипт:
Dalian Plant: PLA - 320, USMC - 100
Daqing Oilfields: PLA - 275, USMC - 180
Dragon Valley: USMC - 67
FuShe Pass: PLA - 120, USMC - 85
Gulf of Oman: MEC - 160, USMC - 100
Kubra Dam: USMC - 83
Operation Clean Sweep: USMC - 285
Road to Jalalabad: USMC - 50
Sharqi Peninsula: MEC - 60
Strike at Karkand: USMC - 160
Wake Island 2007: USMC - 135
Zatar Wetlands: MEC - 120, USMC - 100
Скрипт
Код
# ------------------------------------------------------------------------
# Module: AntiBaseRape.py
# Author: SHAnders
# Port to bf2cc/mm: graag42
#
# Version 1.11
#
# Changes:
#   v1.1 -> 1.11
#   Fixed the timer to only be started once
#   v1.0 -> 1.1
#   Implemted a baseRapeWarning attribute on players to count safe base kills
#   Implemted allowed amount of safe base kills (3)
#      up to this amount player only loses kill points + 1 score pr baseRapeWarning
#      over this amount player is allso killed
#   Implemtes a timer for removing 1 baseRapeWarning every 2 minutes
#
# Description:
#   Server side only admin script
#
#   This script will punish players who kill enemy within the area of a safe base
#
# Requirements:
#   None.
#
# Installation as Admin script:
#   1: Save this script as 'AntiBaseRape.py' in your <bf2>/admin/standard_admin directory.
#   2: Add the lines 'import AntiBaseRape' and 'AntiBaseRape.init()' to the file
#      '<bf2>/admin/standard_admin/__init__.py'.
#
# TODO:
#   Since not all maps are alike, the requirements for base rape protiction
#   should be able to be altered individualy for each control point.
#
# Thanks to:
#   Battlefield.no for inspiration from their pingkick.py script
#
# ------------------------------------------------------------------------

import host
import bf2
import math
import mm_utils
from bf2.stats.constants import *
from bf2 import g_debug

# Set the version of your module here
__version__ = 1.11

# Set the required module versions here
__required_modules__ = {
    'modmanager': 1.0
}

# Does this module support reload ( are all its reference closed on shutdown? )
__supports_reload__ = True

# Set the description of your module here
__description__ = "AntiBaseRape v%s" % __version__

# ------------------------------------------------------------------------
# Constants
# ------------------------------------------------------------------------

DEFAULT_SAFEBASE_RADIUS = 50 # Default safe area radius (normal commandpoint radius = 10)
ALLOWED_SAFEBASEKILLS = 2
SAFEBASEKILL_TIMER_INTERVAL = 300 # Intervals between removing a point from players.baseRapeWarning

# ------------------------------------------------------------------------
# Variables
# ------------------------------------------------------------------------

WarnReduceTimer = None # Timer that reduces the warnings at intervals

# ------------------------------------------------------------------------
# Init
# ------------------------------------------------------------------------

class BaseRape( object ) :

   def __init__( self, modManager ):
      # ModManager reference
      self.mm = modManager

      # Internal shutdown state
      self.__state = 0

   def init( self ):
      if g_debug: print "AntiBaseRape init"
      if 0 == self.__state:
         host.registerHandler('PlayerConnect', self.onPlayerConnect, 1)
         host.registerHandler('PlayerKilled', self.onPlayerKilled)

         # Update to the running state
         self.__state = 1

         # Start the timer that reduces warnings on the SAFEBASEKILL_TIMER_INTERVAL
         WarnReduceTimer = bf2.Timer(self.onSafeBaseKillTimer, SAFEBASEKILL_TIMER_INTERVAL, 1)
         WarnReduceTimer.setRecurring(SAFEBASEKILL_TIMER_INTERVAL)

         # Connect already connected players if reinitializing
         for p in bf2.playerManager.getPlayers():
            self.onPlayerConnect(p)
   # ------------------------------------------------------------------------


   # ------------------------------------------------------------------------
   #  onPlayerConnect
   # ------------------------------------------------------------------------
   def onPlayerConnect(self, player):
      self.resetPlayer(player)
   # ------------------------------------------------------------------------


   # ------------------------------------------------------------------------
   # onPlayerKilled
   # ------------------------------------------------------------------------
   def onPlayerKilled(self, victim, attacker, weapon, assists, object):
      # killed by self
      if attacker == victim:
         pass

      # killed by enemy
      elif attacker != None and attacker.getTeam() != victim.getTeam():
         self.checkForSafeBase(attacker, victim)
   # ------------------------------------------------------------------------


   def shutdown( self ):
      """Shutdown and stop processing."""

      # Unregister game handlers and do any other
      # other actions to ensure your module no longer affects
      # the game in anyway
      if WarnReduceTimer:
        WarnReduceTimer.destroy()
        WarnReduceTimer = None

      # Flag as shutdown as there is currently way to:
      # host.unregisterHandler
      self.__state = 2

   # ------------------------------------------------------------------------
   # Reset the number of warnings
   # ------------------------------------------------------------------------
   def resetPlayer(self, player):
      player.baseRapeWarning = 0
   # ------------------------------------------------------------------------


   # ------------------------------------------------------------------------
   # Check if victim was killed within safebase area
   # ------------------------------------------------------------------------
def checkForSafeBase(self, attacker, victim):
      currentmap = bf2.gameLogic.getMapName()
      if currentmap == "dalian_plant" and victim.getTeam() == 1:
         DEFAULT_SAFEBASE_RADIUS = 320
      if currentmap == "dalian_plant" and victim.getTeam() == 2:
         DEFAULT_SAFEBASE_RADIUS = 100
      if currentmap == "daqing_oilfields" and victim.getTeam() == 1:
         DEFAULT_SAFEBASE_RADIUS = 275
      if currentmap == "daqing_oilfields" and victim.getTeam() == 2:
         DEFAULT_SAFEBASE_RADIUS = 180
      if currentmap == "dragon_valley":
         DEFAULT_SAFEBASE_RADIUS = 67
      if currentmap == "fushe_pass" and victim.getTeam() == 1:
         DEFAULT_SAFEBASE_RADIUS = 120
      if currentmap == "fushe_pass" and victim.getTeam() == 2:
         DEFAULT_SAFEBASE_RADIUS = 85
      if currentmap == "gulf_of_oman" and victim.getTeam() == 1:
         DEFAULT_SAFEBASE_RADIUS = 160
      if currentmap == "gulf_of_oman" and victim.getTeam() == 2:
         DEFAULT_SAFEBASE_RADIUS = 100
      if currentmap == "kubra_dam":
         DEFAULT_SAFEBASE_RADIUS = 83
      if currentmap == "operation_clean_sweep":
         DEFAULT_SAFEBASE_RADIUS = 285
      if currentmap == "road_to_jalalabad":
         DEFAULT_SAFEBASE_RADIUS = 50
      if currentmap == "sharqi_peninsula":
         DEFAULT_SAFEBASE_RADIUS = 60
      if currentmap == "strike_at_karkand":
         DEFAULT_SAFEBASE_RADIUS = 160
      if currentmap == "wake_island_2007":
         DEFAULT_SAFEBASE_RADIUS = 135
      if currentmap == "zatar_wetlands" and victim.getTeam() == 1:
         DEFAULT_SAFEBASE_RADIUS = 120
      if currentmap == "zatar_wetlands" and victim.getTeam() == 2:
         DEFAULT_SAFEBASE_RADIUS = 100
      if currentmap == "strike_at_karkand_2":
         DEFAULT_SAFEBASE_RADIUS = 35
      if currentmap == "battleaxe_2008" and victim.getTeam() == 1:
         DEFAULT_SAFEBASE_RADIUS = 52
      if currentmap == "battleaxe_2008" and victim.getTeam() == 2:
         DEFAULT_SAFEBASE_RADIUS = 48
      if currentmap == "uluwatu_city":
         DEFAULT_SAFEBASE_RADIUS = 33
      if currentmap == "vulcan_island":
         DEFAULT_SAFEBASE_RADIUS = 55

      victimVehicle = victim.getVehicle()
      controlPoints = bf2.objectManager.getObjectsOfType('dice.hfe.world.ObjectTemplate.ControlPoint')
      for cp in controlPoints:
         if cp.cp_getParam('unableToChangeTeam') != 0 and cp.cp_getParam('team') != attacker.getTeam():
            distanceTo = self.getVectorDistance(victimVehicle.getPosition(), cp.getPosition())
            if DEFAULT_SAFEBASE_RADIUS > float(distanceTo):
               self.justify(attacker, victim, cp, distanceTo)
   # ------------------------------------------------------------------------


   # ------------------------------------------------------------------------
   # Punish attacker, give victim life back and inform all
   # ------------------------------------------------------------------------
   def justify(self, attacker, victim, controlPoint, distanceTo):
      victim.score.deaths += -1
      attacker.score.kills += -1
      attacker.score.score += -2 - attacker.baseRapeWarning
      attacker.baseRapeWarning += 1
      self.sendWarning(attacker, controlPoint, distanceTo)
      if attacker.baseRapeWarning > ALLOWED_SAFEBASEKILLS:
         attacker.score.TKs += 1
         if attacker.isAlive():
            vehicle = attacker.getVehicle()
            rootVehicle = getRootParent(vehicle)
            if getVehicleType(rootVehicle.templateName) == VEHICLE_TYPE_SOLDIER:
               rootVehicle.setDamage(0)
               # This should kill them !
            else:
               rootVehicle.setDamage(1)
               # a vehicle will likely explode within 1 sec killing entire crew,
               # not so sure about base defenses though
   # ------------------------------------------------------------------------


   # ------------------------------------------------------------------------
   # Send Warning
   # ------------------------------------------------------------------------
   def sendWarning(self, player, controlPoint, distanceTo):
      mapName = bf2.gameLogic.getMapName()
      if player.baseRapeWarning > ALLOWED_SAFEBASEKILLS:
         mm_utils.msg_server("§3" + player.getName() + " is punished for kill in safe base area §C1001(ATAKA NT)§C1001")
      else:
         mm_utils.msg_server(player.getName() + " has violated the no kill rules within safe base area " + str(player.baseRapeWarning) + " times now")
   # ------------------------------------------------------------------------


   # ------------------------------------------------------------------------
   # remove baseRapeWarnings over time
   # ------------------------------------------------------------------------
   def onSafeBaseKillTimer(self, data):
      for p in bf2.playerManager.getPlayers():
         if p.baseRapeWarning <= 0:
            p.baseRapeWarning = 0
         else:
            p.baseRapeWarning += -1
   # ------------------------------------------------------------------------


   # ------------------------------------------------------------------------
   # get distance between two positions
   # ------------------------------------------------------------------------
   def getVectorDistance(self, pos1, pos2):
      diffVec = [0.0, 0.0, 0.0]
      diffVec[0] = math.fabs(pos1[0] - pos2[0])
      diffVec[1] = math.fabs(pos1[1] - pos2[1])
      diffVec[2] = math.fabs(pos1[2] - pos2[2])

      return math.sqrt(diffVec[0] * diffVec[0] + diffVec[1] * diffVec[1] + diffVec[2] * diffVec[2])
   # ------------------------------------------------------------------------


# ------------------------------------------------------------------------
# ModManager Init
# ------------------------------------------------------------------------
def mm_load( modManager ):
    """Creates and returns your object."""
    return BaseRape( modManager )



mm_baserape_v2.py
Описание
При убийстве врага с использованием техники на вражеской НТ в пределах некоторого радиуса убившему бойцу выносится предупреждение.
Исключение: если жертва сидит в/на ПВО или на TOW.
После 1-го (на 2-ее) предупреждение - техника взрывается. Каждые 5 минут предупреждение сгорает. Пехотой и артиллерией атаковать НТ разрешено без ограничений.

Дополнительно
DEFAULT_SAFEBASE_RADIUS = 50 - радиус действия скрипта по умолчанию на НТ (это радиус будит работать на тех картах, которые не указаны в скрипте!)
ALLOWED_SAFEBASEKILLS = 2 - количество предупреждений
примечание: если выставить 0, то техника будит сразу взрываться!
SAFEBASEKILL_TIMER_INTERVAL = 300 - время сгорание предупреждения

Параметры
Экспериментальным путем были заданы следующие радиусы для карт (в метрах от флага на НТ) в которых будит действовать скрипт:
Dalian Plant: PLA - 320, USMC - 100
Daqing Oilfields: PLA - 275, USMC - 180
Dragon Valley: USMC - 67
FuShe Pass: PLA - 120, USMC - 85
Gulf of Oman: MEC - 160, USMC - 100
Kubra Dam: USMC - 83
Operation Clean Sweep: USMC - 285
Road to Jalalabad: USMC - 50
Sharqi Peninsula: MEC - 60
Strike at Karkand: USMC - 160
Wake Island 2007: USMC - 135
Zatar Wetlands: MEC - 120, USMC - 100
Скрипт
Код
# ------------------------------------------------------------------------
# Module: AntiBaseRape.py
# Author: SHAnders
# Port to bf2cc/mm: graag42
#
# Version 1.2
#
# Changes:
#   v1.11 -> 1.2
#   Big improvements by REW (http://maxigame.by/bf2/)
#   v1.1 -> 1.11
#   Fixed the timer to only be started once
#   v1.0 -> 1.1
#   Implemted a baseRapeWarning attribute on players to count safe base kills
#   Implemted allowed amount of safe base kills (3)
#      up to this amount player only loses kill points + 1 score pr baseRapeWarning
#      over this amount player is allso killed
#   Implemtes a timer for removing 1 baseRapeWarning every 2 minutes
#
# Description:
#   Server side only admin script
#
#   This script will punish players who kill enemy within the area of a safe base
#
# Requirements:
#   None.
#
# Installation as Admin script:
#   1: Save this script as 'AntiBaseRape.py' in your <bf2>/admin/standard_admin directory.
#   2: Add the lines 'import AntiBaseRape' and 'AntiBaseRape.init()' to the file
#      '<bf2>/admin/standard_admin/__init__.py'.
#
# TODO:
#   Since not all maps are alike, the requirements for base rape protiction
#   should be able to be altered individualy for each control point.
#
# Thanks to:
#   Battlefield.no for inspiration from their pingkick.py script
#
# ------------------------------------------------------------------------

import host
import bf2
import math
import mm_utils
from bf2.stats.constants import *
from bf2 import g_debug

# Set the version of your module here
__version__ = 1.11

# Set the required module versions here
__required_modules__ = {
    'modmanager': 1.0
}

# Does this module support reload ( are all its reference closed on shutdown? )
__supports_reload__ = True

# Set the description of your module here
__description__ = "AntiBaseRape v%s" % __version__

# ------------------------------------------------------------------------
# Constants
# ------------------------------------------------------------------------

DEFAULT_SAFEBASE_RADIUS = 50 # Default safe area radius (normal commandpoint radius = 10)
ALLOWED_SAFEBASEKILLS = 2
SAFEBASEKILL_TIMER_INTERVAL = 300 # Intervals between removing a point from players.baseRapeWarning

# ------------------------------------------------------------------------
# Variables
# ------------------------------------------------------------------------

WarnReduceTimer = None # Timer that reduces the warnings at intervals

# ------------------------------------------------------------------------
# Init
# ------------------------------------------------------------------------

class BaseRape( object ) :

   def __init__( self, modManager ):
      # ModManager reference
      self.mm = modManager

      # Internal shutdown state
      self.__state = 0

   def init( self ):
      if g_debug: print "AntiBaseRape init"
      if 0 == self.__state:
         host.registerHandler('PlayerConnect', self.onPlayerConnect, 1)
         host.registerHandler('PlayerKilled', self.onPlayerKilled)

         # Update to the running state
         self.__state = 1

         # Start the timer that reduces warnings on the SAFEBASEKILL_TIMER_INTERVAL
         WarnReduceTimer = bf2.Timer(self.onSafeBaseKillTimer, SAFEBASEKILL_TIMER_INTERVAL, 1)
         WarnReduceTimer.setRecurring(SAFEBASEKILL_TIMER_INTERVAL)

         # Connect already connected players if reinitializing
         for p in bf2.playerManager.getPlayers():
            self.onPlayerConnect(p)
   # ------------------------------------------------------------------------


   # ------------------------------------------------------------------------
   #  onPlayerConnect
   # ------------------------------------------------------------------------
   def onPlayerConnect(self, player):
      self.resetPlayer(player)
   # ------------------------------------------------------------------------


   # ------------------------------------------------------------------------
   # onPlayerKilled
   # ------------------------------------------------------------------------
   def onPlayerKilled(self, victim, attacker, weapon, assists, object):
      # killed by self
      vehicle = attacker.getVehicle()
      vicvehicle = victim.getVehicle()
      rootVehicle = getRootParent(vehicle)
      vicrootVehicle = getRootParent(vicvehicle)
      #attackerVehicle = bf2.objectManager.getRootParent(weapon)
      if attacker == victim:
         pass

      # killed by enemy
      elif (attacker != None) and (attacker.getTeam() != victim.getTeam()) and (getVehicleType(rootVehicle.templateName) != VEHICLE_TYPE_SOLDIER) and (getVehicleType(vicrootVehicle.templateName) != VEHICLE_TYPE_AIRDEFENSE) and (getVehicleType(vicrootVehicle.templateName) != VEHICLE_TYPE_GRNDDEFENSE):
         attackerVehicle = bf2.objectManager.getRootParent(weapon)
         if attackerVehicle.isPlayerControlObject and attackerVehicle.getIsRemoteControlled():
            pass
         else:
            self.checkForSafeBase(attacker, victim, weapon)
   # ------------------------------------------------------------------------


   def shutdown( self ):
      """Shutdown and stop processing."""

      # Unregister game handlers and do any other
      # other actions to ensure your module no longer affects
      # the game in anyway
      if WarnReduceTimer:
        WarnReduceTimer.destroy()
        WarnReduceTimer = None

      # Flag as shutdown as there is currently way to:
      # host.unregisterHandler
      self.__state = 2

   # ------------------------------------------------------------------------
   # Reset the number of warnings
   # ------------------------------------------------------------------------
   def resetPlayer(self, player):
      player.baseRapeWarning = 0
   # ------------------------------------------------------------------------


   # ------------------------------------------------------------------------
   # Check if victim was killed within safebase area
   # ------------------------------------------------------------------------
   def checkForSafeBase(self, attacker, victim, weapon):
      currentmap = bf2.gameLogic.getMapName()
      if currentmap == "dalian_plant" and victim.getTeam() == 1:
         DEFAULT_SAFEBASE_RADIUS = 320
      if currentmap == "dalian_plant" and victim.getTeam() == 2:
         DEFAULT_SAFEBASE_RADIUS = 100
      if currentmap == "daqing_oilfields" and victim.getTeam() == 1:
         DEFAULT_SAFEBASE_RADIUS = 275
      if currentmap == "daqing_oilfields" and victim.getTeam() == 2:
         DEFAULT_SAFEBASE_RADIUS = 180
      if currentmap == "dragon_valley":
         DEFAULT_SAFEBASE_RADIUS = 67
      if currentmap == "fushe_pass" and victim.getTeam() == 1:
         DEFAULT_SAFEBASE_RADIUS = 120
      if currentmap == "fushe_pass" and victim.getTeam() == 2:
         DEFAULT_SAFEBASE_RADIUS = 85
      if currentmap == "gulf_of_oman" and victim.getTeam() == 1:
         DEFAULT_SAFEBASE_RADIUS = 160
      if currentmap == "gulf_of_oman" and victim.getTeam() == 2:
         DEFAULT_SAFEBASE_RADIUS = 100
      if currentmap == "kubra_dam":
         DEFAULT_SAFEBASE_RADIUS = 83
      if currentmap == "operation_clean_sweep":
         DEFAULT_SAFEBASE_RADIUS = 285
      if currentmap == "road_to_jalalabad":
         DEFAULT_SAFEBASE_RADIUS = 50
      if currentmap == "sharqi_peninsula":
         DEFAULT_SAFEBASE_RADIUS = 60
      if currentmap == "strike_at_karkand":
         DEFAULT_SAFEBASE_RADIUS = 160
      if currentmap == "wake_island_2007":
         DEFAULT_SAFEBASE_RADIUS = 135
      if currentmap == "zatar_wetlands" and victim.getTeam() == 1:
         DEFAULT_SAFEBASE_RADIUS = 120
      if currentmap == "zatar_wetlands" and victim.getTeam() == 2:
         DEFAULT_SAFEBASE_RADIUS = 100
      if currentmap == "strike_at_karkand_2":
         DEFAULT_SAFEBASE_RADIUS = 35
      if currentmap == "battleaxe_2008" and victim.getTeam() == 1:
         DEFAULT_SAFEBASE_RADIUS = 52
      if currentmap == "battleaxe_2008" and victim.getTeam() == 2:
         DEFAULT_SAFEBASE_RADIUS = 48
      if currentmap == "uluwatu_city":
         DEFAULT_SAFEBASE_RADIUS = 33
      if currentmap == "vulcan_island":
         DEFAULT_SAFEBASE_RADIUS = 55

      victimVehicle = victim.getVehicle()
      controlPoints = bf2.objectManager.getObjectsOfType('dice.hfe.world.ObjectTemplate.ControlPoint')
      for cp in controlPoints:
         if cp.cp_getParam('unableToChangeTeam') != 0 and cp.cp_getParam('team') != attacker.getTeam():
            distanceTo = self.getVectorDistance(victimVehicle.getPosition(), cp.getPosition())
            if DEFAULT_SAFEBASE_RADIUS > float(distanceTo):
               self.justify(attacker, victim, cp, distanceTo)
   # ------------------------------------------------------------------------


   # ------------------------------------------------------------------------
   # Punish attacker, give victim life back and inform all
   # ------------------------------------------------------------------------
   def justify(self, attacker, victim, controlPoint, distanceTo):
      vehicle = attacker.getVehicle()
      rootVehicle = getRootParent(vehicle)
      if getVehicleType(rootVehicle.templateName) != VEHICLE_TYPE_SOLDIER:
         attacker.baseRapeWarning += 1
         self.sendWarning(attacker, controlPoint, distanceTo)
      if attacker.baseRapeWarning > ALLOWED_SAFEBASEKILLS:
         attacker.score.TKs += 1
         victim.score.deaths += -1
         attacker.score.kills += -1
         attacker.score.score += -2 - attacker.baseRapeWarning
         if attacker.isAlive():
            if getVehicleType(rootVehicle.templateName) != VEHICLE_TYPE_SOLDIER:
               rootVehicle.setDamage(0.01)
               # a vehicle will likely explode within 1 sec killing entire crew,
               # not so sure about base defenses though
   # ------------------------------------------------------------------------


   # ------------------------------------------------------------------------
   # Send Warning
   # ------------------------------------------------------------------------
   def sendWarning(self, player, controlPoint, distanceTo):
      mapName = bf2.gameLogic.getMapName()
      if player.baseRapeWarning > ALLOWED_SAFEBASEKILLS:
         mm_utils.msg_server("§3" + player.getName() + " - is punished for repeated violation of the no kill rules within safe base area")
      else:
         mm_utils.msg_server("§3" + player.getName() + "has violated the no kill rules within safe base area! Warnings: " + str(player.baseRapeWarning) + "/" + str(ALLOWED_SAFEBASEKILLS))
   # ------------------------------------------------------------------------


   # ------------------------------------------------------------------------
   # remove baseRapeWarnings over time
   # ------------------------------------------------------------------------
   def onSafeBaseKillTimer(self, data):
      for p in bf2.playerManager.getPlayers():
         if p.baseRapeWarning <= 0:
            p.baseRapeWarning = 0
         else:
            p.baseRapeWarning += -1
   # ------------------------------------------------------------------------


   # ------------------------------------------------------------------------
   # get distance between two positions
   # ------------------------------------------------------------------------
   def getVectorDistance(self, pos1, pos2):
      diffVec = [0.0, 0.0, 0.0]
      diffVec[0] = math.fabs(pos1[0] - pos2[0])
      diffVec[1] = math.fabs(pos1[1] - pos2[1])
      diffVec[2] = math.fabs(pos1[2] - pos2[2])

      return math.sqrt(diffVec[0] * diffVec[0] + diffVec[1] * diffVec[1] + diffVec[2] * diffVec[2])
   # ------------------------------------------------------------------------


# ------------------------------------------------------------------------
# ModManager Init
# ------------------------------------------------------------------------
def mm_load( modManager ):
    """Creates and returns your object."""
    return BaseRape( modManager )
-Military-
ну это я понял, но почему у меня не идёт скрипт MapAutoSizer или dc_automap.py
-Military-
Раскрывающийся текст
[2012-01-30 12:30:43] Info: Module 'mm_logger' initialised
[2012-01-30 12:30:43] Info: Creating Multiplay, ModManager v2.0 for Battlefield 2 (www.multiplay.co.uk)
[2012-01-30 12:30:43] Info: Starting ModManager Rcon v6.1 on 188.226.126.160:4716
[2012-01-30 12:30:43] Info: Rcon command handler 'login' registered
[2012-01-30 12:30:43] Info: Rcon command handler 'logout' registered
[2012-01-30 12:30:43] Info: Rcon command handler 'users' registered
[2012-01-30 12:30:43] Info: Rcon command handler 'kick' registered
[2012-01-30 12:30:43] Info: Rcon command handler 'ban' registered
[2012-01-30 12:30:43] Info: Rcon command handler 'banby' registered
[2012-01-30 12:30:43] Info: Rcon command handler 'banlist' registered
[2012-01-30 12:30:43] Info: Rcon command handler 'unban' registered
[2012-01-30 12:30:43] Info: Rcon command handler 'clearbans' registered
[2012-01-30 12:30:43] Info: Rcon command handler 'list' registered
[2012-01-30 12:30:43] Info: Rcon command handler 'profileid' registered
[2012-01-30 12:30:43] Info: Rcon command handler 'profileids' registered
[2012-01-30 12:30:43] Info: Rcon command handler 'listlocked' registered
[2012-01-30 12:30:43] Info: Rcon command handler 'maplist' registered
[2012-01-30 12:30:43] Info: Rcon command handler 'map' registered
[2012-01-30 12:30:43] Info: Rcon command handler 'exec' registered
[2012-01-30 12:30:43] Info: Rcon command handler 'help' registered
[2012-01-30 12:30:43] Info: Rcon command handler '?' registered (alias)
[2012-01-30 12:30:43] Info: ModManager Rcon started
[2012-01-30 12:30:43] Info: Module 'mm_rcon' v6.1 loaded
[2012-01-30 12:30:43] Info: Module 'mm_rcon' initialised
[2012-01-30 12:30:43] Info: Module 'mm_banmanager' v3.6 loaded
[2012-01-30 12:30:43] Info: Rcon command handler 'bm' registered
[2012-01-30 12:30:43] Info: Module 'mm_banmanager' initialised
[2012-01-30 12:30:43] Info: Module 'mm_tk_punish' v2.2 loaded
[2012-01-30 12:30:43] Error: Failed to load module 'mm_mapautosizer' ( No module named mm_mapautosizer )
[2012-01-30 12:30:43] Error: Traceback (most recent call last):
File "admin\modmanager.py", line 588, in __loadModule
module = __import__( module_name )
ImportError: No module named mm_mapautosizer
[2012-01-30 12:30:43] Info: Module 'mm_kicker' v2.5 loaded
[2012-01-30 12:30:43] Info: Module 'mm_announcer' v1.7 loaded
[2012-01-30 12:30:43] Error: Failed to load module 'mm_ingameadmin' ( invalid syntax (mm_ingameadmin.py, line 38) )
[2012-01-30 12:30:43] Error: Traceback (most recent call last):
File "admin\modmanager.py", line 588, in __loadModule
module = __import__( module_name )
File "admin/modules\mm_ingameadmin.py", line 38
superadmins = [,'4fd6bf0770d634a2a0af8fb184705258','']
^
SyntaxError: invalid syntax
[2012-01-30 12:30:43] Error: Failed to load module 'mm_baserape_v1' ( unindent does not match any outer indentation level (mm_baserape_v1.py, line 214) )
[2012-01-30 12:30:43] Error: Traceback (most recent call last):
File "admin\modmanager.py", line 588, in __loadModule
module = __import__( module_name )
IndentationError: unindent does not match any outer indentation level (mm_baserape_v1.py, line 214)
[2012-01-30 12:30:43] Info: Module 'mm_bf2cc' v7.0 loaded
[2012-01-30 12:30:43] Info: Module 'mm_autobalance' v2.3 loaded
[2012-01-30 12:30:43] Info: Module 'mm_reserver' v0.7 loaded
[2012-01-30 12:30:43] Info: Loaded 6 additional modules
[2012-01-30 12:30:43] Info: Rcon command handler 'mm' registered
[2012-01-30 12:30:43] Info: Module 'mm_tk_punish' initialised
[2012-01-30 12:30:43] Info: Rcon command handler 'kicker' registered
[2012-01-30 12:30:43] Info: Module 'mm_kicker' initialised
[2012-01-30 12:30:43] Info: Rcon command handler 'announcer' registered
[2012-01-30 12:30:43] Info: Module 'mm_announcer' initialised
[2012-01-30 12:30:43] Info: Rcon command handler 'bf2cc' registered
[2012-01-30 12:30:43] Info: Module 'mm_bf2cc' initialised
[2012-01-30 12:30:43] Info: Module 'mm_autobalance' initialised
[2012-01-30 12:30:43] Info: Rcon command handler 'reserver' registered
[2012-01-30 12:30:43] Info: Module 'mm_reserver' initialised
[2012-01-30 12:30:43] Info: Initialised 6 modules
[2012-01-30 12:31:02] Info: Validating maplist...
[2012-01-30 12:31:02] Info: No maplist changes required

вот что лог теперь кажет
mayor_alex
Помогите разобраться с установкой скрипта Scripts:AutoMap с http://bf2tech.org/index.php/Scripts:AutoMap, после установки перестает работать скрип автобалланса. Делаю так:

1. Создал файл /bf2/admin/standart_admin/dc_automap.py
2. Прописал в нем скрипт.
3. Далее в инструкции сказано добавить срочки

Код
import dc_automap
dc_automap.init()


в файл _init_.py , у меня их два:

/bf2/admin/standart_admin/_init_.py
и /bf2/admin/_init_.py

/bf2/admin/_init_.py пустой а, /bf2/admin/standart_admin/_init_.py судя по содержимому содержит скрипты: автобалланс, тимкиллпаниш и т.п

Код
import autobalance
import tk_punish
import playerconnect

autobalance.init()
tk_punish.init()
playerconnect.init()


после редактирования получаем

Код
import autobalance
import tk_punish
import playerconnect
import dc_automap

autobalance.init()
tk_punish.init()
playerconnect.init()
dc_automap.init()


перезагружаю сервер и не работает скрипт автобалланса игроков, лог питона пишет:

Раскрывающийся текст
Persistant stats module initialized.
Snapshot module initialized
Medal awarding module initialized
Global key string: &info=rank,ktm-,dfcp,rpar,vtm-,bksk,scor,wdsk,wkl-,heal,dsab,cdsc,tsql,tsqm,wins,vkl-,twsc,time,kill,rsup,tcdr,vac-
initializing default admin/rcon module
Traceback (most recent call last):
File "admin/default.py", line 380, in init
import standard_admin
File "admin/standard_admin/__init__.py", line 4, in ?
import dc_automap
File "admin/standard_admin/dc_automap.py", line 9
maps_run_tracking = 3
^
SyntaxError: invalid syntax
Reset orderiterator to 0 based on highest pid kept
Reloading players


ткните пожалуйста носом в чем ошибка и как исправить
mayor_alex
Проблему нашел, при копировании кода скрипта в начало каждой строки подставился символ пробела, после удаления все заработало
maiorBoltach
у кого нибудь имеется данный скрипт для бф2142. от бф2 он не подходит - выдаёт:

Цитата
[2012-02-10 10:32:24] Error: Failed to load module 'mm_AntiBaseRape' ( unindent does not match any outer indentation level (mm_AntiBaseRape.py, line 214) )
[2012-02-10 10:32:24] Error: Traceback (most recent call last):
File "admin\modmanager.py", line 588, in __loadModule
module = __import__( module_name )
IndentationError: unindent does not match any outer indentation level (mm_AntiBaseRape.py, line 214)


seanman
sorry can i ask which anti baserape script that works for punish attacker who use infantry and vehicle?

the second script just works for vehicle is that right?
the first script can work to vehicle and infantry?
seanman
i cant use the edit feature cry.gif it was said sorry bla bla.. so im gonna double post im sorry here.

i found a good anti baserape script
can someone found it's working?

Раскрывающийся текст
# Module: AntiBaseRape 2 for Battlefield 2 Server bf2.wildpark.net(closed server only for WildPark users).
# Author: orion.
# Tester: Skuuka (thx)
#
# Version 1.4
#
# Description:
# Server side only admin script.
#
# This script will punish players who kill enemy within the area of a safe base.
#
# Requirements:
# modmanager
#
# ATTENTION!!!
# You must add string
# def getnoVehicles(self): return host.ss_getParam('noVehicles')
# in file /python/bf2/GameLogic.py for class ServerSettings.
#
#
# Have fun
#

import bf2
import host
import mm_utils
from bf2.stats.constants import *
from bf2 import g_debug
import math
import time


# Set the version of your module here
__version__ = 1.4

# Set the required module versions here
__required_modules__ = {
'modmanager': 1.0
}

# Does this module support reload ( are all its reference closed on shutdown? )
__supports_reload__ = False

# Set the description of your module here
__description__ = "AntiBaseRape 2 v%s" % __version__


class fStt(object):
def __init__(self, player):
self.timedeath = 0
self.warning = 0
self.enterVeh = 0

class new_baserape_maps(object):
def __init__(self, map, num_cp, army):
if map == "daqing_oilfields":
if army == 1:
self.tch_x = [ {'x':-246, 'y':380.5, 'z':165, 'h':25, 'r':85}, {'x':-110, 'y':533, 'z':155, 'h':18, 'r':90} ] # PLA(NB, VPP)
else:
self.tch_x = [ {'x':346, 'y':-578, 'z':120, 'h':38, 'r':150} ] # USA(NB)
if map == "dalian_plant":
if army == 1:
self.tch_x = [ {'x':-707, 'y':-367, 'z':180, 'h':25, 'r':115}, {'x':-796, 'y':-125.5, 'z':180, 'h':25, 'r':30} ] # PLA(NB, VPP)
else:
self.tch_x = [ {'x':763, 'y':-13, 'z':155, 'h':35, 'r':50} ] # USA(NB)
if map == "gulf_of_oman":
if army == 1:
self.tch_x = [ {'x':310, 'y':240, 'z':24, 'h':25, 'r':50}, {'x':127.5, 'y':250, 'z':23, 'h':25, 'r':40} ] # MEC(NB, heli)
else:
self.tch_x = [ {'x':-677, 'y':-490, 'z':38, 'h':35, 'r':60} ] # USA(NB)
if map == "operation_clean_sweep":
if army == 1:
self.tch_x = [ {'x':-121, 'y':-555, 'z':31, 'h':8, 'r':16, 'point':'smallairstrip', 'owner':1, 'c':13}, {'x':703.5, 'y':83, 'z':29, 'h':15, 'r':25, 'point':'mecairfield', 'owner':1, 'c':13}, {'x':256.3, 'y':-397.8, 'z':37, 'h':15, 'r':9, 'point':'communicationcentral', 'owner':1, 'c':13} ] # MEC(VPP, VPP(base), heli)
else:
self.tch_x = [ {'x':-552, 'y':544, 'z':29, 'h':15, 'r':50}, {'x':-428, 'y':667.5, 'z':36, 'h':20, 'r':48}, {'x':-328, 'y':682, 'z':36, 'h':25, 'r':50} ] # USA(NB, VPP, VPP)
if map == "kubra_dam":
if army == 1:
self.tch_x = [ {'x':-496.5, 'y':-730, 'z':66, 'h':10, 'r':40, 'point':'intake', 'owner':1, 'c':13}, {'x':-458.5, 'y':-584, 'z':65, 'h':25, 'r':25, 'point':'intake', 'owner':1, 'c':13} ] # MEC(VPP, heli)
else:
self.tch_x = [ {'x':158.5, 'y':125.5, 'z':60, 'h':20, 'r':65}, {'x':519, 'y':332.5, 'z':75, 'h':30, 'r':85} ] # USA(NB, VPP)
if map == "wake_island_2007":
if army == 1:
self.tch_x = [ {'x':408, 'y':-374, 'z':100, 'h':10, 'r':15, 'point':'airfield', 'owner':1, 'c':9}, {'x':373, 'y':-350, 'z':100, 'h':15, 'r':15, 'point':'airfield', 'owner':1, 'c':9} ] # PLA(VPP, heli)
else:
self.tch_x = [ {'x':-745.5, 'y':633.5, 'z':98, 'h':30, 'r':55} ] # USA(NB)
if map == "zatar_wetlands":
if army == 1:
self.tch_x = [ {'x':727, 'y':-401, 'z':60, 'h':17, 'r':75}, {'x':795, 'y':-510, 'z':60, 'h':25, 'r':45} ] # MEC(NB, VPP)
else:
if num_cp == 7:
self.tch_x = [ {'x':-772, 'y':102, 'z':41, 'h':20, 'r':80}, {'x':-849, 'y':153.5, 'z':38, 'h':25, 'r':40} ] # USA(NB, NB(VPP))
else:
self.tch_x = [ {'x':-386, 'y':921, 'z':48, 'h':25, 'r':60}, {'x':-565, 'y':482, 'z':30, 'h':15, 'r':85} ] # USA(NB(VPP), NB)
if map == "fushe_pass":
if army == 1:
if num_cp == 6:
self.tch_x = [ {'x':-531.5, 'y':231.7, 'z':90, 'h':30, 'r':70} ] # PLA(NB)
else:
self.tch_x = [ {'x':-668, 'y':-493.8, 'z':115, 'h':40, 'r':130} ] # PLA(NB)
else:
if num_cp == 6:
self.tch_x = [ {'x':302, 'y':-203, 'z':80, 'h':30, 'r':60} ] # USA(NB)
else:
self.tch_x = [ {'x':608.5, 'y':576.8, 'z':85, 'h':25, 'r':80}, {'x':734.5, 'y':712, 'z':87, 'h':35, 'r':65} ] # USA(NB, VPP)
if map == "dragon_valley":
if army == 1:
if num_cp == 6:
self.tch_x = [ {'x':92.5, 'y':-679, 'z':100, 'h':25, 'r':30, 'point':'refinery', 'owner':1, 'c':13} ] # PLA(Heli)
else:
self.tch_x = [ {'x':92.5, 'y':-679, 'z':100, 'h':25, 'r':30, 'point':'refinery', 'owner':1, 'c':13}, {'x':185.5, 'y':-647, 'z':100, 'h':20, 'r':35, 'point':'refinery', 'owner':1, 'c':13} ] # PLA(Heli, VPP)
else:
if num_cp == 6:
self.tch_x = [ {'x':116, 'y':314, 'z':51, 'h':25, 'r':40} ] # USA(NB)
else:
self.tch_x = [ {'x':338.5, 'y':846, 'z':67, 'h':30, 'r':55} ] # USA(NB)
if map == "highway_tampa":
if army == 1:
self.tch_x = [ {'x':-493, 'y':636.5, 'z':25, 'h':25, 'r':105} ] # MEC(NB)
else:
self.tch_x = [ {'x':608, 'y':-526, 'z':25, 'h':15, 'r':50},{'x':706, 'y':-466.5, 'z':26, 'h':25, 'r':50} ] # USA(NB, VPP)
if map == "taraba_quarry":
if army == 1:
if num_cp == 5:
self.tch_x = [ {'x':18.5, 'y':186.4, 'z':120, 'h':25, 'r':35} ] # MEC(NB)
else:
self.tch_x = [ {'x':-489, 'y':-553, 'z':155, 'h':25, 'r':70}, {'x':-645.5, 'y':-525, 'z':160, 'h':20, 'r':50} ] # MEC(NB, VPP)
else:
if num_cp == 7:
self.tch_x = [ {'x':427, 'y':-461.5, 'z':155, 'h':20, 'r':60}, {'x':575.5, 'y':-420, 'z':160, 'h':20, 'r':45} ] # EURO(NB, VPP)
if map == "operationsmokescreen":
if army == 1:
self.tch_x = [ {'x':72.5, 'y':-522, 'z':96, 'h':15, 'r':60}, {'x':108, 'y':-629, 'z':87, 'h':30, 'r':70} ] # MEC(NB, VPP)
else:
self.tch_x = [ {'x':7, 'y':430.5, 'z':96, 'h':15, 'r':55}, {'x':87, 'y':528.5, 'z':97, 'h':30, 'r':80} ] # EURO(NB, VPP)
if map == "road_to_jalalabad":
if army == 2:
self.tch_x = [ {'x':-205.4, 'y':7.7, 'z':40, 'h':15, 'r':45} ] # USA(NB)
if map == "sharqi_peninsula":
if army == 1:
if num_cp == 4:
self.tch_x = [ {'x':-316.3, 'y':-226.2, 'z':78, 'h':6, 'r':25} ] # MEC(NB)
else:
self.tch_x = [ {'x':-647, 'y':205, 'z':90, 'h':15, 'r':27}, {'x':-605, 'y':-201, 'z':90, 'h':15, 'r':35}, {'x':-288.5, 'y':-597, 'z':70, 'h':15, 'r':25}, {'x':-247.5, 'y':-585, 'z':75, 'h':20, 'r':18} ] # MEC(NB, NB, NB, Heli)
else:
if num_cp > 4:
self.tch_x = [ {'x':-98.25, 'y':-144.25, 'z':128, 'h':15, 'r':15, 'point':'tvstation', 'owner':2, 'c':13} ] # USA(Heli)
if map == "strike_at_karkand":
if army == 2:
self.tch_x = [ {'x':-160, 'y':-282, 'z':159, 'h':10, 'r':40} ] # USA(NB)
if map == "operation_blue_pearl":
if num_cp > 4:
if army == 2:
self.tch_x = [ {'x':282, 'y':-123, 'z':15, 'h':20, 'r':58} ] # USA(island)
if map == "midnight_sun":
if num_cp > 4:
if army == 2:
self.tch_x = [ {'x':533, 'y':-40, 'z':110, 'h':25, 'r':65}, {'x':607, 'y':61, 'z':110, 'h':25, 'r':75} ] # USA()
else:
self.tch_x = [ {'x':-735, 'y':-382, 'z':96, 'h':20, 'r':75}, {'x':-664, 'y':-346, 'z':103, 'h':20, 'r':82} ] # PLA()
if map == "operationharvest":
if army == 2:
if num_cp == 5:
self.tch_x = [ {'x':471.7, 'y':436, 'z':30, 'h':20, 'r':59} ] # USA(NB)
if num_cp == 8:
self.tch_x = [ {'x':-405, 'y':-561, 'z':32, 'h':25, 'r':47}, {'x':-455, 'y':-495, 'z':28, 'h':25, 'r':51} ] # USA(NB, heli)
if num_cp == 9:
self.tch_x = [ {'x':-405, 'y':-561, 'z':32, 'h':25, 'r':47}, {'x':-442, 'y':-483, 'z':28, 'h':25, 'r':42}, {'x':340, 'y':-486, 'z':48, 'h':25, 'r':31} ] # USA(NB, heli)
else:
if num_cp == 8:
self.tch_x = [ {'x':245, 'y':678, 'z':35, 'h':25, 'r':42}, {'x':215, 'y':560, 'z':28, 'h':25, 'r':48} ] # MEC(heli,NB)
if num_cp == 9:
self.tch_x = [ {'x':245, 'y':678, 'z':35, 'h':25, 'r':42} ] # MEC(heli)
if map == "operationroadrage":
if army == 2:
if num_cp == 5:
self.tch_x = [ {'x':329, 'y':127.5, 'z':50, 'h':15, 'r':57} ] # USA()
if num_cp == 7:
self.tch_x = [ {'x':-130, 'y':818, 'z':50, 'h':20, 'r':47}, {'x':45, 'y':808, 'z':45, 'h':20, 'r':35} ] # USA()
else:
if num_cp == 5:
self.tch_x = [ {'x':-169, 'y':-188, 'z':40, 'h':20, 'r':62} ] # MEC()
if num_cp == 7:
self.tch_x = [ {'x':32, 'y':-738, 'z':45, 'h':20, 'r':67}, {'x':-148.5, 'y':-738, 'z':45, 'h':20, 'r':43} ] # MEC(heli,NB)

class old_baserape_maps(object):
def __init__(self, map, army):
self.r = 0
if map == "greatwall" and army==1:
self.r = 50
if map == "greatwall" and army==2:
self.r = 30
if map == "jibbel_city" and army==2:
self.r = 30
if map == "bocage_2005" and army==1:
self.r = 65
if map == "bocage_2005" and army==2:
self.r = 40
if map == "strike_at_karkand_2" and army==2:
self.r = 40
if map == "berlin" and army==2:
self.r = 18
if map == "heliwar" and army==2:
self.r = 125
if map == "heliwar" and army==1:
self.r = 115
if map == "rising_city" and army==2:
self.r = 30
if map == "vulcan_island" and army==2:
self.r = 35


check_new_maps = { "daqing_oilfields":[7,9], "gulf_of_oman":[7,9], "dalian_plant":[6,8], "operation_clean_sweep":[4,6,8], "kubra_dam":[8,9],
"wake_island_2007":[6],"zatar_wetlands":[7,9],"dragon_valley":[6,11],"fushe_pass":[6,10],"highway_tampa":[6,8],"taraba_quarry":[5,7],
"operationsmokescreen":[7],"road_to_jalalabad":[7,8],"sharqi_peninsula":[4,8,9], "strike_at_karkand":[7,9],"operation_blue_pearl":[7,8],
"midnight_sun":[6,8],"operationharvest":[5,8,9],"operationroadrage":[5,7]
}

check_old_maps = ["greatwall","jibbel_city","stream","bocage_2005","strike_at_karkand_2","berlin","cp_abadan","vulcan_island","rising_city", "heliwar"]

check_noVeh_maps = ["greatwall","sharqi_peninsula","road_to_jalalabad","jibbel_city","berlin"]

mapName = ""
noVehicles = 0
num_cp = 0


class new_baserape2( object ):
def __init__( self, modManager ):
self.mm = modManager
self.__state = 0

def onEnterVehicle( self, player, vehicle, freeSoldier):
plVehicle = player.getVehicle()
pl_Vehicle = bf2.objectManager.getRootParent(plVehicle)
if ((getVehicleType(pl_Vehicle.templateName) == VEHICLE_TYPE_HELICOPTER) or (getVehicleType(pl_Vehicle.templateName) == VEHICLE_TYPE_AVIATOR)):
player.faa.enterVeh = int(time.time())


def onExitVehicle(self, player, vehicle):
if not player.isAlive():
player.faa.enterVeh = 0
return

if player.faa.enterVeh > 0:
plVehicle = player.getVehicle()
pl_Vehicle = bf2.objectManager.getRootParent(plVehicle)
if (getVehicleType(pl_Vehicle.templateName) == VEHICLE_TYPE_SOLDIER):
player.faa.enterVeh = 0


def onPlayerKilled(self, victim, attacker, weapon, assists, object):
if (attacker == None) or (attacker.getTeam() == victim.getTeam()) or (victim == None) or (weapon == None):
return

if int(noVehicles) == 1:
if mapName not in check_noVeh_maps:
return

if (mapName == "sharqi_peninsula") and (victim.getTeam() == 2):
return
else:
if(victim.faa.enterVeh>0):
delta = int(time.time()) - victim.faa.enterVeh
if int(delta) > 20:
return

victimVehicle = victim.getVehicle()
vic_Vehicle = bf2.objectManager.getRootParent(victimVehicle)
attackerVehicle = attacker.getVehicle()
att_Vehicle = bf2.objectManager.getRootParent(attackerVehicle)

attackerVehicle = bf2.objectManager.getRootParent(weapon)
if (attackerVehicle.isPlayerControlObject and attackerVehicle.getIsRemoteControlled()): # AOIE AOOEIIAOEN, OI DOIЃ~AONAI
pass
else: # AOIE OIIAAO EIE Ѓ~ AA OI Ѓ~UEIA
if (getVehicleType(att_Vehicle.templateName) == VEHICLE_TYPE_SOLDIER) or (getVehicleType(vic_Vehicle.templateName) == VEHICLE_TYPE_AIRDEFENSE):
return

if check_new_maps.has_key(mapName) and num_cp in check_new_maps[mapName]:
self.checkForSafeBase(victim, attacker, mapName, num_cp)

if mapName in check_old_maps:
tx = old_baserape_maps(mapName, victim.getTeam())
if tx.r > 0:
victimVehicle = victim.getVehicle()
controlPoints = bf2.objectManager.getObjectsOfType('dice.hfe.world.ObjectTemplate.ControlPoint')
for cp in controlPoints:
if cp.cp_getParam('unableToChangeTeam') != 0 and cp.cp_getParam('team') != attacker.getTeam():
distanceTo = self.getVectorDistance(victimVehicle.getPosition(), cp.getPosition())
if float(distanceTo) < tx.r:
mm_utils.msg_server("Ѓ˜3" + attacker.getName() + " - is punished for violating of the no kill rules within Ѓ˜C1001safe base areaЃ˜C1001")
self.mm.info("BASERAPE! att=" + str(attacker.getName()) + " vic=" + str(victim.getName()) +" Radius=" + str(tx.r) + " Distance=" + str(distanceTo) )
self.justify(attacker, victim)


def checkForSafeBase(self, victim, attacker, mapName, num_cp):
victimVehicle = victim.getVehicle()
coor_X = victimVehicle.getPosition()[0]
coor_Y = victimVehicle.getPosition()[2]
coor_Z = victimVehicle.getPosition()[1]

tx = new_baserape_maps(mapName, num_cp, victim.getTeam())
for cp in tx.tch_x:
if (float(coor_Z) > cp['z']) and (float(coor_Z) < (cp['z'] + cp['h'])):
dist = math.sqrt( (float(coor_X) - float(cp['x']))**2 + (float(coor_Y) - float(cp['y']))**2 )
if float(dist) < cp['r']:
if cp.has_key('point'):
attackerVehicle = attacker.getVehicle()
att_Vehicle = bf2.objectManager.getRootParent(attackerVehicle)
if ((getVehicleType(att_Vehicle.templateName) == VEHICLE_TYPE_ARMOR) or (getVehicleType(att_Vehicle.templateName) == VEHICLE_TYPE_TRANSPORT)):
return

for obj in bf2.objectManager.getObjectsOfType('dice.hfe.world.ObjectTemplate.ControlPoint'):
namepoint = obj.templateName.lower()[cp['c']:]
if (namepoint == cp['point']):
ownerteam = int(obj.cp_getParam('team'))
if (ownerteam != cp['owner']):
return

mm_utils.msg_server("Ѓ˜3" + attacker.getName() + " - is punished for violating of the no kill rules within Ѓ˜C1001safe base areaЃ˜C1001")
self.mm.info("BASERAPE! att=" + str(attacker.getName()) + " vic=" + str(victim.getName()) +" Radius=" + str(cp['r']) + " Distance=" + str(dist) )
self.justify(attacker, victim)


def justify(self, attacker, victim):
victim.timedeath = int(time.time())
victim.score.deaths += -1
attacker.score.kills += -1
attacker.score.score += -4
# attacker.score.TKs += 1
attacker.faa.warning += 1
if attacker.isAlive():
vehicle = attacker.getVehicle()
rootVehicle = getRootParent(vehicle)
if getVehicleType(rootVehicle.templateName) == VEHICLE_TYPE_SOLDIER:
rootVehicle.setDamage(0)
else:
rootVehicle.setDamage(1)
if attacker.isCommander():
team = attacker.getTeam()
enemyteam = 3 - team
attacker.setTeam(enemyteam)
attacker.setTeam(team)
if attacker.faa.warning > 3:
host.rcon_invoke('game.sayall "Player %s kicked for violating of the no kill rules within safe base area"' % (attacker.getName() ) )
host.rcon_invoke('pb_sv_kick "%s" %i "You kicked for violating of the no kill rules within safe base area"' % (attacker.getName(), 15) )


def getVectorDistance(self, pos1, pos2):
diffVec = [0.0, 0.0, 0.0]
diffVec[0] = math.fabs(pos1[0] - pos2[0])
diffVec[1] = math.fabs(pos1[1] - pos2[1])
diffVec[2] = math.fabs(pos1[2] - pos2[2])

return math.sqrt(diffVec[0] * diffVec[0] + diffVec[1] * diffVec[1] + diffVec[2] * diffVec[2])


def onGameStatusChanged( self, status ):
if status == bf2.GameStatus.Playing:
global num_cp, mapName, noVehicles
controlPoints = bf2.objectManager.getObjectsOfType('dice.hfe.world.ObjectTemplate.ControlPoint')
num_cp = len(controlPoints)
mapName = bf2.gameLogic.getMapName()
noVehicles = int(bf2.serverSettings.getnoVehicles())
for player in bf2.playerManager.getPlayers():
player.faa.timedeath = 0
player.faa.warning = 0
player.faa.enterVeh = 0


def onPlayerRevived(self, attacker, victim):
if int(attacker.timedeath) > 0:
timex = int(time.time()) - int(attacker.timedeath)
if int(timex) < 16:
attacker.score.deaths += 1
attacker.timedeath = 0


def onPlayerConnect(self, player):
player.faa = fStt(player)


def init( self ):
host.registerGameStatusHandler( self.onGameStatusChanged )

if 0 == self.__state:
host.registerHandler('PlayerConnect', self.onPlayerConnect, 1 )
host.registerHandler('PlayerKilled', self.onPlayerKilled )
host.registerHandler('PlayerRevived', self.onPlayerRevived )
host.registerHandler('EnterVehicle', self.onEnterVehicle )
host.registerHandler('ExitVehicle', self.onExitVehicle )

self.__state = 1


def mm_load( modManager ):
"""Creates and returns your object."""
return new_baserape2( modManager )


and here is my mmmanager.log
Раскрывающийся текст

[2012-09-08 09:53:44] Info: Module 'mm_logger' initialised
[2012-09-08 09:53:44] Info: Creating Multiplay, ModManager v2.0 for Battlefield 2 (www.multiplay.co.uk)
[2012-09-08 09:53:44] Info: Starting ModManager Rcon v5.8 on 0.0.0.0:4711
[2012-09-08 09:53:44] Info: Rcon command handler 'login' registered
[2012-09-08 09:53:44] Info: Rcon command handler 'logout' registered
[2012-09-08 09:53:44] Info: Rcon command handler 'users' registered
[2012-09-08 09:53:44] Info: Rcon command handler 'kick' registered
[2012-09-08 09:53:44] Info: Rcon command handler 'ban' registered
[2012-09-08 09:53:44] Info: Rcon command handler 'banby' registered
[2012-09-08 09:53:44] Info: Rcon command handler 'banlist' registered
[2012-09-08 09:53:44] Info: Rcon command handler 'unban' registered
[2012-09-08 09:53:44] Info: Rcon command handler 'clearbans' registered
[2012-09-08 09:53:44] Info: Rcon command handler 'list' registered
[2012-09-08 09:53:44] Info: Rcon command handler 'profileid' registered
[2012-09-08 09:53:44] Info: Rcon command handler 'profileids' registered
[2012-09-08 09:53:44] Info: Rcon command handler 'listlocked' registered
[2012-09-08 09:53:44] Info: Rcon command handler 'maplist' registered
[2012-09-08 09:53:44] Info: Rcon command handler 'map' registered
[2012-09-08 09:53:44] Info: Rcon command handler 'exec' registered
[2012-09-08 09:53:44] Info: Rcon command handler 'help' registered
[2012-09-08 09:53:44] Info: Rcon command handler '?' registered (alias)
[2012-09-08 09:53:44] Info: ModManager Rcon started
[2012-09-08 09:53:44] Info: Module 'mm_rcon' v5.8 loaded
[2012-09-08 09:53:44] Info: Module 'mm_rcon' initialised
[2012-09-08 09:53:44] Info: Module 'mm_banmanager' v3.6 loaded
[2012-09-08 09:53:44] Info: Rcon command handler 'bm' registered
[2012-09-08 09:53:44] Info: Module 'mm_banmanager' initialised
[2012-09-08 09:53:44] Info: Module 'mm_tk_punish' v2.2 loaded
[2012-09-08 09:53:44] Warn: Legacy module 'mm_baserape' v1.4 detected assuming 'Battlefield 2' support
[2012-09-08 09:53:44] Info: Module 'mm_baserape' v1.4 loaded
[2012-09-08 09:53:44] Info: Module 'mm_kicker' v2.5 loaded
[2012-09-08 09:53:44] Info: Module 'mm_announcer' v1.7 loaded
[2012-09-08 09:53:44] Info: Module 'mm_bf2cc' v6.8 loaded
[2012-09-08 09:53:44] Info: Module 'mm_autobalance' v2.3 loaded
[2012-09-08 09:53:44] Info: Loaded 6 additional modules
[2012-09-08 09:53:44] Info: Rcon command handler 'mm' registered
[2012-09-08 09:53:44] Info: Module 'mm_tk_punish' initialised
[2012-09-08 09:53:44] Info: Module 'mm_baserape' initialised
[2012-09-08 09:53:44] Info: Rcon command handler 'kicker' registered
[2012-09-08 09:53:44] Info: Module 'mm_kicker' initialised
[2012-09-08 09:53:44] Info: Rcon command handler 'announcer' registered
[2012-09-08 09:53:44] Info: Module 'mm_announcer' initialised
[2012-09-08 09:53:44] Info: Rcon command handler 'bf2cc' registered
[2012-09-08 09:53:44] Info: Module 'mm_bf2cc' initialised
[2012-09-08 09:53:44] Info: Module 'mm_autobalance' initialised
[2012-09-08 09:53:44] Info: Initialised 6 modules
[2012-09-08 09:53:53] Info: Validating maplist...
[2012-09-08 09:53:53] Info: No maplist changes required


it was said
[2012-09-08 09:53:44] Warn: Legacy module 'mm_baserape' v1.4 detected assuming 'Battlefield 2' support
warn? is it works i couldnt test it for now.
sh@rk
mm_baserape_v3.py
Описание
Запрещено убивать противника артиллерией и любой техникой, кроме противника находящегося
в противовоздушной технике(стационарной или передвижной), на НТ, вертолетных площадках,
самолетных ангарах и просто точек респа самолетов, если хотя бы у одной стороны на карте есть НТ.
Т.е. не работает, к примеру, на daqing 16x, dragon16x на вертолетных площадках,
но работает на Operation Clean Sweep 16x в ангаре у меков.

Дополнительно
-n/a-

Параметры
-n/a-

p.s: скприт настроин на конкретно точки(радиус/зоны), если надумайти эти точки изменить то сперва подумайти сможите или нет, размижения радиуса можно посмотреть чере bf2editer, там будут эти точки показыватся, для этого вам нужно будит загрузить карту для редактирования...
Скрипт
Код
# Module: AntiBaseRape 2 for Battlefield 2 Server bf2.wildpark.net(closed server only for WildPark users).
# Author: orion.
# Tester: Skuuka (thx)
#
# * Описание:
# Запрещено убивать противника артиллерией и любой техникой, кроме противника находящегося
# в противовоздушной технике(стационарной или передвижной), на НТ, вертолетных площадках,
# самолетных ангарах и просто точек респа самолетов, если хотя бы у одной стороны на карте есть НТ.
# Т.е. не работает, к примеру, на daqing 16x, dragon16x на вертолетных площадках,
# но работает на Operation Clean Sweep 16x в ангаре у меков.
#
# * Важные моменты:
#
# - работает в режиме с техникой и без
#
# - возможны разные правила для карт 16x, 32x, 64x.
#
# - элементарно добавляются карты для "классического" определения атаки на НТ(радиус от НТ),
# для способа привязки к координатам тоже не сложно но уже надо приложить усилия.
#
# - скрипт покрывает точки респа самолетов и вертолетов также на картах 1. Op. Clean Sweep(mec),
# 2. Dragon Valley(pla), 3. Sharqi Peninsula(mec), 4. Wake Island 2007(pla), у сторон(указаны в скобках)
# которых нет НТ, но работает только в том случае если ближайшие точки 1. Small Airstrip и
# Communication central, 2. Refinery, 3. Intake, 4. TV Station не заняты противником!
#
# - запрет убивать артиллерией, но разрешено пехотинцем
#
# - скрипт не действует, если враг находится в Air Defense.
#
# - скрипт не действует, если самолет/вертолет вернулся в зону его обычного действия, точнее не действует по прошествии 20 секунд(тут 1 косячок есть, если вертолетчик пересаживается с пилота на стрелка, то будет действовать, ситуация довольно редкая - влом фиксить )
#
# - есть также карты из EF и некоторые не стандартные.
#
# Version 1.4
#
# Description:
#   Server side only admin script
#
#   This script will punish players who kill enemy within the area of a safe base.
#
# Requirements:
#   modmanager
#
# ATTENTION!!!
#   You must add string
#          def getnoVehicles(self): return host.ss_getParam('noVehicles')
#   in file /python/bf2/GameLogic.py for class ServerSettings.
#
#
# Please play fair.
#



import bf2
import host
import mm_utils
from bf2.stats.constants import *
from bf2 import g_debug
import math
import time


# Set the version of your module here
__version__ = 1.4

# Set the required module versions here
__required_modules__ = {
    'modmanager': 1.0
}

# Does this module support reload ( are all its reference closed on shutdown? )
__supports_reload__ = False

# Set the description of your module here
__description__ = "AntiBaseRape 2 v%s" % __version__


class fStt(object):
    def __init__(self, player):
        self.timedeath = 0
        self.warning = 0
    self.enterVeh = 0

class new_baserape_maps(object):
    def __init__(self, map, num_cp, army):
    if map == "daqing_oilfields":
        if army == 1:
        self.tch_x = [ {'x':-246, 'y':380.5, 'z':165, 'h':25, 'r':85}, {'x':-110, 'y':533, 'z':155, 'h':18, 'r':90} ]        # PLA(NB, VPP)
        else:
        self.tch_x = [ {'x':346, 'y':-578, 'z':120, 'h':38, 'r':150} ]                                # USA(NB)
    if map == "dalian_plant":
        if army == 1:
        self.tch_x = [ {'x':-707, 'y':-367, 'z':180, 'h':25, 'r':115}, {'x':-796, 'y':-125.5, 'z':180, 'h':25, 'r':30} ]    # PLA(NB, VPP)
        else:
        self.tch_x = [ {'x':763, 'y':-13, 'z':155, 'h':35, 'r':50} ]                                # USA(NB)
    if map == "gulf_of_oman":
        if army == 1:
        self.tch_x = [ {'x':310, 'y':240, 'z':24, 'h':25, 'r':50}, {'x':127.5, 'y':250, 'z':23, 'h':25, 'r':40} ]        # MEC(NB, heli)
        else:
        self.tch_x = [ {'x':-677, 'y':-490, 'z':38, 'h':35, 'r':60} ]                                # USA(NB)
    if map == "operation_clean_sweep":
        if army == 1:
        self.tch_x = [ {'x':-121, 'y':-555, 'z':31, 'h':8, 'r':16, 'point':'smallairstrip', 'owner':1, 'c':13}, {'x':703.5, 'y':83, 'z':29, 'h':15, 'r':25, 'point':'mecairfield', 'owner':1, 'c':13}, {'x':256.3, 'y':-397.8, 'z':37, 'h':15, 'r':9, 'point':'communicationcentral', 'owner':1, 'c':13} ]        # MEC(VPP, VPP(base), heli)
        else:
        self.tch_x = [ {'x':-552, 'y':544, 'z':29, 'h':15, 'r':50}, {'x':-428, 'y':667.5, 'z':36, 'h':20, 'r':48}, {'x':-328, 'y':682, 'z':36, 'h':25, 'r':50} ] # USA(NB, VPP, VPP)
    if map == "kubra_dam":
        if army == 1:
        self.tch_x = [ {'x':-496.5, 'y':-730, 'z':66, 'h':10, 'r':40, 'point':'intake', 'owner':1, 'c':13}, {'x':-458.5, 'y':-584, 'z':65, 'h':25, 'r':25, 'point':'intake', 'owner':1, 'c':13} ]        # MEC(VPP, heli)
        else:
        self.tch_x = [ {'x':158.5, 'y':125.5, 'z':60, 'h':20, 'r':65}, {'x':519, 'y':332.5, 'z':75, 'h':30, 'r':85} ]        # USA(NB, VPP)
    if map == "wake_island_2007":
        if army == 1:
        self.tch_x = [ {'x':408, 'y':-374, 'z':100, 'h':10, 'r':15, 'point':'airfield', 'owner':1, 'c':9}, {'x':373, 'y':-350, 'z':100, 'h':15, 'r':15, 'point':'airfield', 'owner':1, 'c':9} ]        # PLA(VPP, heli)
        else:
        self.tch_x = [ {'x':-745.5, 'y':633.5, 'z':98, 'h':30, 'r':55} ]                            # USA(NB)
    if map == "zatar_wetlands":
        if army == 1:
        self.tch_x = [ {'x':727, 'y':-401, 'z':60, 'h':17, 'r':75}, {'x':795, 'y':-510, 'z':60, 'h':25, 'r':45} ]        # MEC(NB, VPP)
        else:
        if num_cp == 7:
            self.tch_x = [ {'x':-772, 'y':102, 'z':41, 'h':20, 'r':80}, {'x':-849, 'y':153.5, 'z':38, 'h':25, 'r':40} ]        # USA(NB, NB(VPP))
        else:
            self.tch_x = [ {'x':-386, 'y':921, 'z':48, 'h':25, 'r':60}, {'x':-565, 'y':482, 'z':30, 'h':15, 'r':85} ]        # USA(NB(VPP), NB)
    if map == "fushe_pass":
        if army == 1:
        if num_cp == 6:
            self.tch_x = [ {'x':-531.5, 'y':231.7, 'z':90, 'h':30, 'r':70} ]                            # PLA(NB)
        else:
            self.tch_x = [ {'x':-668, 'y':-493.8, 'z':115, 'h':40, 'r':130} ]                            # PLA(NB)
        else:
        if num_cp == 6:
            self.tch_x = [ {'x':302, 'y':-203, 'z':80, 'h':30, 'r':60} ]                            # USA(NB)
        else:
            self.tch_x = [ {'x':608.5, 'y':576.8, 'z':85, 'h':25, 'r':80}, {'x':734.5, 'y':712, 'z':87, 'h':35, 'r':65} ]    # USA(NB, VPP)
    if map == "dragon_valley":
        if army == 1:
        if num_cp == 6:
            self.tch_x = [ {'x':92.5, 'y':-679, 'z':100, 'h':25, 'r':30, 'point':'refinery', 'owner':1, 'c':13} ]        # PLA(Heli)
        else:
            self.tch_x = [ {'x':92.5, 'y':-679, 'z':100, 'h':25, 'r':30, 'point':'refinery', 'owner':1, 'c':13}, {'x':185.5, 'y':-647, 'z':100, 'h':20, 'r':35, 'point':'refinery', 'owner':1, 'c':13} ]    # PLA(Heli, VPP)
        else:
        if num_cp == 6:
            self.tch_x = [ {'x':116, 'y':314, 'z':51, 'h':25, 'r':40} ]                                # USA(NB)
        else:
            self.tch_x = [ {'x':338.5, 'y':846, 'z':67, 'h':30, 'r':55} ]                            # USA(NB)
    if map == "highway_tampa":
        if army == 1:
        self.tch_x = [ {'x':-493, 'y':636.5, 'z':25, 'h':25, 'r':105} ]                                # MEC(NB)
        else:
        self.tch_x = [ {'x':608, 'y':-526, 'z':25, 'h':15, 'r':50},{'x':706, 'y':-466.5, 'z':26, 'h':25, 'r':50} ]        # USA(NB, VPP)
    if map == "taraba_quarry":
        if army == 1:
        if num_cp == 5:
            self.tch_x = [ {'x':18.5, 'y':186.4, 'z':120, 'h':25, 'r':35} ]                            # MEC(NB)
        else:
            self.tch_x = [ {'x':-489, 'y':-553, 'z':155, 'h':25, 'r':70}, {'x':-645.5, 'y':-525, 'z':160, 'h':20, 'r':50} ]    # MEC(NB, VPP)
          else:
        if num_cp == 7:
            self.tch_x = [ {'x':427, 'y':-461.5, 'z':155, 'h':20, 'r':60}, {'x':575.5, 'y':-420, 'z':160, 'h':20, 'r':45} ]    # EURO(NB, VPP)
    if map == "operationsmokescreen":
        if army == 1:
        self.tch_x = [ {'x':72.5, 'y':-522, 'z':96, 'h':15, 'r':60}, {'x':108, 'y':-629, 'z':87, 'h':30, 'r':70} ]        # MEC(NB, VPP)
        else:
        self.tch_x = [ {'x':7, 'y':430.5, 'z':96, 'h':15, 'r':55}, {'x':87, 'y':528.5, 'z':97, 'h':30, 'r':80} ]        # EURO(NB, VPP)
    if map == "road_to_jalalabad":
        if army == 2:
        self.tch_x = [ {'x':-205.4, 'y':7.7, 'z':40, 'h':15, 'r':45} ]                                # USA(NB)
    if map == "sharqi_peninsula":
        if army == 1:
        if num_cp == 4:
            self.tch_x = [ {'x':-316.3, 'y':-226.2, 'z':78, 'h':6, 'r':25} ]                            # MEC(NB)
        else:
            self.tch_x = [ {'x':-647, 'y':205, 'z':90, 'h':15, 'r':27}, {'x':-605, 'y':-201, 'z':90, 'h':15, 'r':35}, {'x':-288.5, 'y':-597, 'z':70, 'h':15, 'r':25}, {'x':-247.5, 'y':-585, 'z':75, 'h':20, 'r':18} ]    # MEC(NB, NB, NB, Heli)
        else:
        if num_cp > 4:
            self.tch_x = [ {'x':-98.25, 'y':-144.25, 'z':128, 'h':15, 'r':15, 'point':'tvstation', 'owner':2, 'c':13} ]        # USA(Heli)
    if map == "strike_at_karkand":
        if army == 2:
        self.tch_x = [ {'x':-160, 'y':-282, 'z':159, 'h':10, 'r':40} ]                                # USA(NB)


class old_baserape_maps(object):
    def __init__(self, map, army):
    self.r = 0
    if map == "greatwall" and army==1:
        self.r = 50
    if map == "greatwall" and army==2:
        self.r = 30
    if map == "jibbel_city" and army==2:
        self.r = 30
    if map == "bocage_2005" and army==1:
        self.r = 65
    if map == "bocage_2005" and army==2:
        self.r = 40
    if map == "strike_at_karkand_2" and army==2:
        self.r = 40
    if map == "berlin" and army==2:
        self.r = 18
    if map == "heliwar" and army==2:
        self.r = 125
    if map == "heliwar" and army==1:
        self.r = 115
    if map == "cp_abadan" and army==2:
        self.r = 20
    if map == "rising_city" and army==2:
        self.r = 30
    if map == "vulcan_island" and army==2:
        self.r = 35


check_new_maps = { "daqing_oilfields":[7,9], "gulf_of_oman":[7,9], "dalian_plant":[6,8], "operation_clean_sweep":[4,6,8], "kubra_dam":[8,9],
        "wake_island_2007":[6],"zatar_wetlands":[7,9],"dragon_valley":[6,11],"fushe_pass":[6,10],"highway_tampa":[6,8],"taraba_quarry":[5,7],
        "operationsmokescreen":[7],"road_to_jalalabad":[7,8],"sharqi_peninsula":[4,8,9], "strike_at_karkand":[7,9]
        }

check_old_maps = ["greatwall","jibbel_city","stream","bocage_2005","strike_at_karkand_2","berlin","cp_abadan","vulcan_island","rising_city", "heliwar"]

check_noVeh_maps = ["greatwall","sharqi_peninsula","road_to_jalalabad","jibbel_city","berlin","cp_abadan"]

mapName = ""
noVehicles = 0
num_cp = 0


class new_baserape2( object ):
    def __init__( self, modManager ):
        self.mm = modManager
        self.__state = 0

        def onEnterVehicle( self, player, vehicle, freeSoldier):
        plVehicle = player.getVehicle()
        pl_Vehicle = bf2.objectManager.getRootParent(plVehicle)
            if ((getVehicleType(pl_Vehicle.templateName) == VEHICLE_TYPE_HELICOPTER) or (getVehicleType(pl_Vehicle.templateName) == VEHICLE_TYPE_AVIATOR)):
            player.faa.enterVeh = int(time.time())


    def onExitVehicle(self, player, vehicle):
        if not player.isAlive():
            player.faa.enterVeh = 0
        return

            if player.faa.enterVeh > 0:
            plVehicle = player.getVehicle()
        pl_Vehicle = bf2.objectManager.getRootParent(plVehicle)
                if (getVehicleType(pl_Vehicle.templateName) == VEHICLE_TYPE_SOLDIER):
                    player.faa.enterVeh = 0


    def onPlayerKilled(self, victim, attacker, weapon, assists, object):
        if (attacker == None) or (attacker.getTeam() == victim.getTeam()) or (victim == None) or (weapon == None):
        return

        if int(noVehicles) == 1:                                        
        if mapName not in check_noVeh_maps:                                
            return

        if (mapName == "sharqi_peninsula") and (victim.getTeam() == 2):                    
            return
        else:
        if(victim.faa.enterVeh>0):
                delta = int(time.time()) - victim.faa.enterVeh
            if int(delta) > 20:
            return

        victimVehicle = victim.getVehicle()                            
        vic_Vehicle = bf2.objectManager.getRootParent(victimVehicle)
            attackerVehicle = attacker.getVehicle()
        att_Vehicle = bf2.objectManager.getRootParent(attackerVehicle)

            attackerVehicle = bf2.objectManager.getRootParent(weapon)
        if (attackerVehicle.isPlayerControlObject and attackerVehicle.getIsRemoteControlled()):        # ЕУМЙ БТФЙММЕТЙС, ФП РТПЧЕТСЕН
            pass
        else:                                                # ЕУМЙ УПМДБФ ЙМЙ Ч AA ФП ЧЩИПД
            if (getVehicleType(att_Vehicle.templateName) == VEHICLE_TYPE_SOLDIER) or (getVehicleType(vic_Vehicle.templateName) == VEHICLE_TYPE_AIRDEFENSE):
            return

        if check_new_maps.has_key(mapName) and num_cp in check_new_maps[mapName]:
        self.checkForSafeBase(victim, attacker, mapName, num_cp)

        if mapName in check_old_maps:
        tx = old_baserape_maps(mapName, victim.getTeam())
        if tx.r > 0:
            victimVehicle = victim.getVehicle()
                controlPoints = bf2.objectManager.getObjectsOfType('dice.hfe.world.ObjectTemplate.ControlPoint')
                for cp in controlPoints:
                if cp.cp_getParam('unableToChangeTeam') != 0 and cp.cp_getParam('team') != attacker.getTeam():
                    distanceTo = self.getVectorDistance(victimVehicle.getPosition(), cp.getPosition())
                    if float(distanceTo) < tx.r:
                    mm_utils.msg_server("§3" + attacker.getName() + " - is punished for violating of the no kill rules within §C1001safe base area§C1001")
                    self.mm.info("BASERAPE! att=" + str(attacker.getName()) + " vic=" + str(victim.getName()) +" Radius=" + str(tx.r) + " Distance=" + str(distanceTo) )
                        self.justify(attacker, victim)


    def checkForSafeBase(self, victim, attacker, mapName, num_cp):
        victimVehicle = victim.getVehicle()
        coor_X = victimVehicle.getPosition()[0]
        coor_Y = victimVehicle.getPosition()[2]
        coor_Z = victimVehicle.getPosition()[1]

        tx = new_baserape_maps(mapName, num_cp, victim.getTeam())
        for cp in tx.tch_x:
            if (float(coor_Z) > cp['z']) and (float(coor_Z) < (cp['z'] + cp['h'])):
                dist = math.sqrt( (float(coor_X) - float(cp['x']))**2 + (float(coor_Y) - float(cp['y']))**2 )
                if float(dist) < cp['r']:
                if cp.has_key('point'):
                    attackerVehicle = attacker.getVehicle()
                att_Vehicle = bf2.objectManager.getRootParent(attackerVehicle)
                  if ((getVehicleType(att_Vehicle.templateName) == VEHICLE_TYPE_ARMOR) or (getVehicleType(att_Vehicle.templateName) == VEHICLE_TYPE_TRANSPORT)):
                return

                for obj in bf2.objectManager.getObjectsOfType('dice.hfe.world.ObjectTemplate.ControlPoint'):
                namepoint = obj.templateName.lower()[cp['c']:]
                if (namepoint == cp['point']):
                    ownerteam = int(obj.cp_getParam('team'))
                    if (ownerteam != cp['owner']):
                    return

                mm_utils.msg_server("§3" + attacker.getName() + " - is punished for violating of the no kill rules within §C1001safe base area§C1001")
                self.mm.info("BASERAPE! att=" + str(attacker.getName()) + " vic=" + str(victim.getName()) +" Radius=" + str(cp['r']) + " Distance=" + str(dist) )
                    self.justify(attacker, victim)


    def justify(self, attacker, victim):
            victim.timedeath = int(time.time())
        victim.score.deaths += -1
        attacker.score.kills += -1
        attacker.score.score += -4
#        attacker.score.TKs += 1
        attacker.faa.warning += 1
        if attacker.isAlive():
            vehicle = attacker.getVehicle()
            rootVehicle = getRootParent(vehicle)
            if getVehicleType(rootVehicle.templateName) == VEHICLE_TYPE_SOLDIER:
                rootVehicle.setDamage(0)
        else:
                rootVehicle.setDamage(1)
        if attacker.isCommander():
            team = attacker.getTeam()
        enemyteam = 3 - team
        attacker.setTeam(enemyteam)
        attacker.setTeam(team)
        if attacker.faa.warning > 3:
            host.rcon_invoke('game.sayall "Player %s kicked for violating of the no kill rules within safe base area"' % (attacker.getName() ) )
            host.rcon_invoke('pb_sv_kick "%s" %i "You kicked for violating of the no kill rules within safe base area"' % (attacker.getName(), 15) )
        

    def getVectorDistance(self, pos1, pos2):
        diffVec = [0.0, 0.0, 0.0]
        diffVec[0] = math.fabs(pos1[0] - pos2[0])
        diffVec[1] = math.fabs(pos1[1] - pos2[1])
        diffVec[2] = math.fabs(pos1[2] - pos2[2])

            return math.sqrt(diffVec[0] * diffVec[0] + diffVec[1] * diffVec[1] + diffVec[2] * diffVec[2])


    def onGameStatusChanged( self, status ):
        if status == bf2.GameStatus.Playing:
        global num_cp, mapName, noVehicles
            controlPoints = bf2.objectManager.getObjectsOfType('dice.hfe.world.ObjectTemplate.ControlPoint')
        num_cp = len(controlPoints)
        mapName = bf2.gameLogic.getMapName()
            noVehicles = int(bf2.serverSettings.getnoVehicles())
        for player in bf2.playerManager.getPlayers():
                player.faa.timedeath = 0
                player.faa.warning = 0
                player.faa.enterVeh = 0


    def onPlayerRevived(self, attacker, victim):
        if int(attacker.timedeath) > 0:
            timex = int(time.time()) - int(attacker.timedeath)
        if int(timex) < 16:
            attacker.score.deaths += 1
            attacker.timedeath = 0


    def onPlayerConnect(self, player):
        player.faa = fStt(player)


    def init( self ):
        host.registerGameStatusHandler( self.onGameStatusChanged )

        if 0 == self.__state:
                host.registerHandler('PlayerConnect', self.onPlayerConnect, 1 )
                host.registerHandler('PlayerKilled', self.onPlayerKilled )
        host.registerHandler('PlayerRevived', self.onPlayerRevived )
                host.registerHandler('EnterVehicle', self.onEnterVehicle  )
                host.registerHandler('ExitVehicle', self.onExitVehicle )

        self.__state = 1


def mm_load( modManager ):
    """Creates and returns your object."""
    return new_baserape2( modManager )
seanman
errr.. i cant read well with Russian language so i used translate google, im sorry im not introducing myself, that im from Indonesia.

btw i've try that mm_baserape_v3.py and it's only for vehicle, rite?


Can you show how to make anti baserape script for both infantry and vehicle?
i was try it and always failed with infantry. Vehicle always works but infantry nope.
seanman
oh ya i run your script, i modified your script here is the script so much thx smile.gif, it can works on infant and vehicle

Раскрывающийся текст
# ------------------------------------------------------------------------
# Module: AntiBaseRape.py
# Author: SHAnders
# Port to bf2cc/mm: graag42
#
# Version 1.2
#
# Changes:
# v1.11 -> 1.2
# Big improvements by REW (http://maxigame.by/bf2/)
# v1.1 -> 1.11
# Fixed the timer to only be started once
# v1.0 -> 1.1
# Implemted a baseRapeWarning attribute on players to count safe base kills
# Implemted allowed amount of safe base kills (3)
# up to this amount player only loses kill points + 1 score pr baseRapeWarning
# over this amount player is allso killed
# Implemtes a timer for removing 1 baseRapeWarning every 2 minutes
#
# Description:
# Server side only admin script
#
# This script will punish players who kill enemy within the area of a safe base
#
# Requirements:
# None.
#
# Installation as Admin script:
# 1: Save this script as 'AntiBaseRape.py' in your <bf2>/admin/standard_admin directory.
# 2: Add the lines 'import AntiBaseRape' and 'AntiBaseRape.init()' to the file
# '<bf2>/admin/standard_admin/__init__.py'.
#
# TODO:
# Since not all maps are alike, the requirements for base rape protiction
# should be able to be altered individualy for each control point.
#
# Thanks to:
# Battlefield.no for inspiration from their pingkick.py script
#
# ------------------------------------------------------------------------

import host
import bf2
import math
import mm_utils
from bf2.stats.constants import *
from bf2 import g_debug

# Set the version of your module here
__version__ = 1.11

# Set the required module versions here
__required_modules__ = {
'modmanager': 1.0
}

# Does this module support reload ( are all its reference closed on shutdown? )
__supports_reload__ = True

# Set the description of your module here
__description__ = "AntiBaseRape v%s" % __version__

# ------------------------------------------------------------------------
# Constants
# ------------------------------------------------------------------------

DEFAULT_SAFEBASE_RADIUS = 50 # Default safe area radius (normal commandpoint radius = 10)
ALLOWED_SAFEBASEKILLS = 2
SAFEBASEKILL_TIMER_INTERVAL = 300 # Intervals between removing a point from players.baseRapeWarning

# ------------------------------------------------------------------------
# Variables
# ------------------------------------------------------------------------

WarnReduceTimer = None # Timer that reduces the warnings at intervals

# ------------------------------------------------------------------------
# Init
# ------------------------------------------------------------------------

class BaseRape( object ) :

def __init__( self, modManager ):
# ModManager reference
self.mm = modManager

# Internal shutdown state
self.__state = 0

def init( self ):
if g_debug: print "AntiBaseRape init"
if 0 == self.__state:
host.registerHandler('PlayerConnect', self.onPlayerConnect, 1)
host.registerHandler('PlayerKilled', self.onPlayerKilled)

# Update to the running state
self.__state = 1

# Start the timer that reduces warnings on the SAFEBASEKILL_TIMER_INTERVAL
WarnReduceTimer = bf2.Timer(self.onSafeBaseKillTimer, SAFEBASEKILL_TIMER_INTERVAL, 1)
WarnReduceTimer.setRecurring(SAFEBASEKILL_TIMER_INTERVAL)

# Connect already connected players if reinitializing
for p in bf2.playerManager.getPlayers():
self.onPlayerConnect(p)
# ------------------------------------------------------------------------


# ------------------------------------------------------------------------
# onPlayerConnect
# ------------------------------------------------------------------------
def onPlayerConnect(self, player):
self.resetPlayer(player)
# ------------------------------------------------------------------------


# ------------------------------------------------------------------------
# onPlayerKilled
# ------------------------------------------------------------------------
def onPlayerKilled(self, victim, attacker, weapon, assists, object):
# killed by self
#vehicle = attacker.getVehicle()
#vicvehicle = victim.getVehicle()
#rootVehicle = getRootParent(vehicle)
#vicrootVehicle = getRootParent(vicvehicle)
#attackerVehicle = bf2.objectManager.getRootParent(weapon)
if attacker == victim:
pass
elif attacker != None and attacker.getTeam() != victim.getTeam():

self.checkForSafeBase(attacker, victim, weapon)
# killed by enemy
#elif (attacker != None) and (attacker.getTeam() != victim.getTeam()) and (getVehicleType(rootVehicle.templateName) != VEHICLE_TYPE_SOLDIER) and (getVehicleType(vicrootVehicle.templateName) != VEHICLE_TYPE_AIRDEFENSE) and (getVehicleType(vicrootVehicle.templateName) != VEHICLE_TYPE_GRNDDEFENSE):
#attackerVehicle = bf2.objectManager.getRootParent(weapon)
#if attackerVehicle.isPlayerControlObject and attackerVehicle.getIsRemoteControlled():
# pass
#else:

# ------------------------------------------------------------------------


def shutdown( self ):
"""Shutdown and stop processing."""

# Unregister game handlers and do any other
# other actions to ensure your module no longer affects
# the game in anyway
if WarnReduceTimer:
WarnReduceTimer = None
WarnReduceTimer.destroy()

# Flag as shutdown as there is currently way to:
# host.unregisterHandler
self.__state = 2

# ------------------------------------------------------------------------
# Reset the number of warnings
# ------------------------------------------------------------------------
def resetPlayer(self, player):
player.baseRapeWarning = 0
# ------------------------------------------------------------------------


# ------------------------------------------------------------------------
# Check if victim was killed within safebase area
# ------------------------------------------------------------------------
def checkForSafeBase(self, attacker, victim, weapon):
currentmap = bf2.gameLogic.getMapName()
if currentmap == "dalian_plant" and victim.getTeam() == 1:
DEFAULT_SAFEBASE_RADIUS = 320
if currentmap == "dalian_plant" and victim.getTeam() == 2:
DEFAULT_SAFEBASE_RADIUS = 100
if currentmap == "daqing_oilfields" and victim.getTeam() == 1:
DEFAULT_SAFEBASE_RADIUS = 275
if currentmap == "daqing_oilfields" and victim.getTeam() == 2:
DEFAULT_SAFEBASE_RADIUS = 180
if currentmap == "dragon_valley":
DEFAULT_SAFEBASE_RADIUS = 94
if currentmap == "fushe_pass" and victim.getTeam() == 1:
DEFAULT_SAFEBASE_RADIUS = 75
if currentmap == "fushe_pass" and victim.getTeam() == 2:
DEFAULT_SAFEBASE_RADIUS = 54
if currentmap == "gulf_of_oman" and victim.getTeam() == 1:
DEFAULT_SAFEBASE_RADIUS = 80
if currentmap == "gulf_of_oman" and victim.getTeam() == 2:
DEFAULT_SAFEBASE_RADIUS = 95
if currentmap == "kubra_dam":
DEFAULT_SAFEBASE_RADIUS = 83
if currentmap == "operation_blue_pearl":
DEFAULT_SAFEBASE_RADIUS = 200
if currentmap == "operation_clean_sweep":
DEFAULT_SAFEBASE_RADIUS = 39
if currentmap == "road_to_jalalabad":
DEFAULT_SAFEBASE_RADIUS = 50
if currentmap == "sharqi_peninsula":
DEFAULT_SAFEBASE_RADIUS = 24
if currentmap == "strike_at_karkand":
DEFAULT_SAFEBASE_RADIUS = 54
if currentmap == "wake_island_2007":
DEFAULT_SAFEBASE_RADIUS = 150
if currentmap == "zatar_wetlands" and victim.getTeam() == 1:
DEFAULT_SAFEBASE_RADIUS = 90
if currentmap == "zatar_wetlands" and victim.getTeam() == 2:
DEFAULT_SAFEBASE_RADIUS = 68
if currentmap == "mass_destruction":
DEFAULT_SAFEBASE_RADIUS = 23
if currentmap == "warlord":
DEFAULT_SAFEBASE_RADIUS = 55
if currentmap == "highway_tampa":
DEFAULT_SAFEBASE_RADIUS = 130
if currentmap == "greatwall":
DEFAULT_SAFEBASE_RADIUS = 55
if currentmap == "insurgency_on_alcatraz_island":
DEFAULT_SAFEBASE_RADIUS = 20
if currentmap == "iron_gator":
DEFAULT_SAFEBASE_RADIUS = 55
if currentmap == "midnight_sun":
DEFAULT_SAFEBASE_RADIUS = 108
if currentmap == "atom":
DEFAULT_SAFEBASE_RADIUS = 130
if currentmap == "leviathan":
DEFAULT_SAFEBASE_RADIUS = 55
if currentmap == "night_flight":
DEFAULT_SAFEBASE_RADIUS = 30
if currentmap == "operationharvest":
DEFAULT_SAFEBASE_RADIUS = 100
if currentmap == "operationroadrage":
DEFAULT_SAFEBASE_RADIUS = 100
if currentmap == "operationsmokescreen":
DEFAULT_SAFEBASE_RADIUS = 100
if currentmap == "taraba_quarry":
DEFAULT_SAFEBASE_RADIUS = 130

victimVehicle = victim.getVehicle()
controlPoints = bf2.objectManager.getObjectsOfType('dice.hfe.world.ObjectTemplate.ControlPoint')
for cp in controlPoints:
if cp.cp_getParam('unableToChangeTeam') != 0 and cp.cp_getParam('team') != attacker.getTeam():
distanceTo = self.getVectorDistance(victimVehicle.getPosition(), cp.getPosition())
if DEFAULT_SAFEBASE_RADIUS > float(distanceTo):
self.justify(attacker, victim, cp, distanceTo)
# ------------------------------------------------------------------------


# ------------------------------------------------------------------------
# Punish attacker, give victim life back and inform all
# ------------------------------------------------------------------------
def justify(self, attacker, victim, controlPoint, distanceTo):

victim.score.deaths += -1
attacker.score.kills += -2
attacker.score.score += -4 - attacker.baseRapeWarning
attacker.baseRapeWarning += 1
self.sendWarning(attacker, controlPoint, distanceTo)
vehicle = attacker.getVehicle()
rootVehicle = getRootParent(vehicle)
if getVehicleType(rootVehicle.templateName) == VEHICLE_TYPE_SOLDIER:
attacker.baseRapeWarning += 2
self.sendWarning(attacker, controlPoint, distanceTo)
if getVehicleType(rootVehicle.templateName) != VEHICLE_TYPE_SOLDIER:
attacker.baseRapeWarning += 2
self.sendWarning(attacker, controlPoint, distanceTo)
if attacker.baseRapeWarning > ALLOWED_SAFEBASEKILLS:
attacker.baseRapeWarning += 1
attacker.score.TKs += 1
victim.score.deaths += -2
attacker.score.kills += -4
attacker.score.score += -6 - attacker.baseRapeWarning
self.sendWarning(attacker, controlPoint, distanceTo)
if attacker.isAlive():
if getVehicleType(rootVehicle.templateName) != VEHICLE_TYPE_SOLDIER:
rootVehicle.setDamage(0.01)
# a vehicle will likely explode within 1 sec killing entire crew,
# not so sure about base defenses though
# ------------------------------------------------------------------------


# ------------------------------------------------------------------------
# Send Warning
# ------------------------------------------------------------------------
def sendWarning(self, player, controlPoint, distanceTo):
mapName = bf2.gameLogic.getMapName()
if player.baseRapeWarning > ALLOWED_SAFEBASEKILLS:
mm_utils.msg_server("§3" + player.getName() + " - BASERAPER smile.gif §C1001(FIX BASE ATTACK)§C1001")
else:
mm_utils.msg_server("§C1001" + player.getName() + "§C1001 - FIX BASE ATTACK! Warnings: §C1001" + str(player.baseRapeWarning) + "§C1001/" + str(ALLOWED_SAFEBASEKILLS))
# ------------------------------------------------------------------------


# ------------------------------------------------------------------------
# remove baseRapeWarnings over time
# ------------------------------------------------------------------------
def onSafeBaseKillTimer(self, data):
for p in bf2.playerManager.getPlayers():
if p.baseRapeWarning <= 0:
p.baseRapeWarning = 0
else:
p.baseRapeWarning += -1
# ------------------------------------------------------------------------


# ------------------------------------------------------------------------
# get distance between two positions
# ------------------------------------------------------------------------
def getVectorDistance(self, pos1, pos2):
diffVec = [0.0, 0.0, 0.0]
diffVec[0] = math.fabs(pos1[0] - pos2[0])
diffVec[1] = math.fabs(pos1[1] - pos2[1])
diffVec[2] = math.fabs(pos1[2] - pos2[2])

return math.sqrt(diffVec[0] * diffVec[0] + diffVec[1] * diffVec[1] + diffVec[2] * diffVec[2])
# ------------------------------------------------------------------------


# ------------------------------------------------------------------------
# ModManager Init
# ------------------------------------------------------------------------
def mm_load( modManager ):
"""Creates and returns your object."""
return BaseRape( modManager )
seanman
cant edit sorry about triple post >.<..
here i want to ask about map 1.5 patch safe base radius..
is it okay with radius for 64 players map?
how to calculate the radius?

Раскрывающийся текст
if currentmap == "operation_blue_pearl":
DEFAULT_SAFEBASE_RADIUS = 200
if currentmap == "highway_tampa":
DEFAULT_SAFEBASE_RADIUS = 250
if currentmap == "greatwall":
DEFAULT_SAFEBASE_RADIUS = 85
if currentmap == "midnight_sun":
DEFAULT_SAFEBASE_RADIUS = 200
if currentmap == "operationharvest":
DEFAULT_SAFEBASE_RADIUS = 150
if currentmap == "operationroadrage":
DEFAULT_SAFEBASE_RADIUS = 275
if currentmap == "operationsmokescreen":
DEFAULT_SAFEBASE_RADIUS = 230
if currentmap == "taraba_quarry":
DEFAULT_SAFEBASE_RADIUS = 200
Tema567
You should be Squad Leader on the server running necessary map and then just place "Move" marker on the uncaptureable flag
For best measurements you must place it on exact point for flag pole/holder.
Then game will show you allowed distance in meters, which accepted by this script (distance tools may be disabled by Alt button in game)
How you may be noticed from geometry course, it means spherical space for safe base
All distances used in your script works on any map layer 16/32/64
seanman
Thx tema567 smile.gif.. btw i've another made a baserape script with more points it works for infant and vehicle

Раскрывающийся текст
# Module: AntiBaseRape 2 for Battlefield 2 Server bf2.wildpark.net(closed server only for WildPark users).
# Author: orion.
# Tester: Skuuka (thx)
# Author :watdezig aka seanman
# Version 1.5
#
# Description:
# Server side only admin script.
#
# This script will punish players who kill enemy within the area of a safe base.
# credit to:shander as the 1st maker.
#Lotus Developer Team, Kaskus, Orion. as maker
#tester 1.5 : arie "capulet[2]nd"
# Requirements:
# modmanager
#infant and vehcle works biggrin.gif.
# ATTENTION!!!
# You must add string
# def getnoVehicles(self): return host.ss_getParam('noVehicles')
# in file /python/bf2/GameLogic.py for class ServerSettings.
#
#
# Have fun
#

import bf2
import host
import mm_utils
from bf2.stats.constants import *
from bf2 import g_debug
import math
import time


# Set the version of your module here
__version__ = 1.5

# Set the required module versions here
__required_modules__ = {
'modmanager': 1.0
}

# Does this module support reload ( are all its reference closed on shutdown? )
__supports_reload__ = False

# Set the description of your module here
__description__ = "AntiBaseRape 2 v%s" % __version__


class fStt(object):
def __init__(self, player):
self.timedeath = 0
self.warning = 0
self.enterVeh = 0

class new_baserape_maps(object):
def __init__(self, map, num_cp, army):
if map == "daqing_oilfields":
if army == 1:
self.tch_x = [ {'x':-246, 'y':380.5, 'z':165, 'h':25, 'r':85}, {'x':-110, 'y':533, 'z':155, 'h':18, 'r':90} ] # PLA(NB, VPP)
else:
self.tch_x = [ {'x':346, 'y':-578, 'z':120, 'h':38, 'r':150} ] # USA(NB)
if map == "dalian_plant":
if army == 1:
self.tch_x = [ {'x':-707, 'y':-367, 'z':180, 'h':25, 'r':115}, {'x':-796, 'y':-125.5, 'z':180, 'h':25, 'r':30} ] # PLA(NB, VPP)
else:
self.tch_x = [ {'x':763, 'y':-13, 'z':155, 'h':35, 'r':50} ] # USA(NB)
if map == "gulf_of_oman":
if army == 1:
self.tch_x = [ {'x':310, 'y':240, 'z':24, 'h':25, 'r':50}, {'x':127.5, 'y':250, 'z':23, 'h':25, 'r':40} ] # MEC(NB, heli)
else:
self.tch_x = [ {'x':-677, 'y':-490, 'z':38, 'h':35, 'r':60} ] # USA(NB)
if map == "operation_clean_sweep":
if army == 1:
self.tch_x = [ {'x':-121, 'y':-555, 'z':31, 'h':8, 'r':16, 'point':'smallairstrip', 'owner':1, 'c':13}, {'x':703.5, 'y':83, 'z':29, 'h':15, 'r':25, 'point':'mecairfield', 'owner':1, 'c':13}, {'x':256.3, 'y':-397.8, 'z':37, 'h':15, 'r':9, 'point':'communicationcentral', 'owner':1, 'c':13} ] # MEC(VPP, VPP(base), heli)
else:
self.tch_x = [ {'x':-552, 'y':544, 'z':29, 'h':15, 'r':50}, {'x':-428, 'y':667.5, 'z':36, 'h':20, 'r':48}, {'x':-328, 'y':682, 'z':36, 'h':25, 'r':50} ] # USA(NB, VPP, VPP)
if map == "kubra_dam":
if army == 1:
self.tch_x = [ {'x':-496.5, 'y':-730, 'z':66, 'h':10, 'r':40, 'point':'intake', 'owner':1, 'c':13}, {'x':-458.5, 'y':-584, 'z':65, 'h':25, 'r':25, 'point':'intake', 'owner':1, 'c':13} ] # MEC(VPP, heli)
else:
self.tch_x = [ {'x':158.5, 'y':125.5, 'z':60, 'h':20, 'r':65}, {'x':519, 'y':332.5, 'z':75, 'h':30, 'r':85} ] # USA(NB, VPP)
if map == "wake_island_2007":
if army == 1:
self.tch_x = [ {'x':408, 'y':-374, 'z':100, 'h':10, 'r':15, 'point':'airfield', 'owner':1, 'c':9}, {'x':373, 'y':-350, 'z':100, 'h':15, 'r':15, 'point':'airfield', 'owner':1, 'c':9} ] # PLA(VPP, heli)
else:
self.tch_x = [ {'x':-745.5, 'y':633.5, 'z':98, 'h':30, 'r':55} ] # USA(NB)
if map == "zatar_wetlands":
if army == 1:
self.tch_x = [ {'x':727, 'y':-401, 'z':60, 'h':17, 'r':75}, {'x':795, 'y':-510, 'z':60, 'h':25, 'r':45} ] # MEC(NB, VPP)
else:
if num_cp == 7:
self.tch_x = [ {'x':-772, 'y':102, 'z':41, 'h':20, 'r':80}, {'x':-849, 'y':153.5, 'z':38, 'h':25, 'r':40} ] # USA(NB, NB(VPP))
else:
self.tch_x = [ {'x':-386, 'y':921, 'z':48, 'h':25, 'r':60}, {'x':-565, 'y':482, 'z':30, 'h':15, 'r':85} ] # USA(NB(VPP), NB)
if map == "fushe_pass":
if army == 1:
if num_cp == 6:
self.tch_x = [ {'x':-531.5, 'y':231.7, 'z':90, 'h':30, 'r':70} ] # PLA(NB)
else:
self.tch_x = [ {'x':-668, 'y':-493.8, 'z':115, 'h':40, 'r':130} ] # PLA(NB)
else:
if num_cp == 6:
self.tch_x = [ {'x':302, 'y':-203, 'z':80, 'h':30, 'r':60} ] # USA(NB)
else:
self.tch_x = [ {'x':608.5, 'y':576.8, 'z':85, 'h':25, 'r':80}, {'x':734.5, 'y':712, 'z':87, 'h':35, 'r':65} ] # USA(NB, VPP)
if map == "dragon_valley":
if army == 1:
if num_cp == 6:
self.tch_x = [ {'x':92.5, 'y':-679, 'z':100, 'h':25, 'r':30, 'point':'refinery', 'owner':1, 'c':13} ] # PLA(Heli)
else:
self.tch_x = [ {'x':92.5, 'y':-679, 'z':100, 'h':25, 'r':30, 'point':'refinery', 'owner':1, 'c':13}, {'x':185.5, 'y':-647, 'z':100, 'h':20, 'r':35, 'point':'refinery', 'owner':1, 'c':13} ] # PLA(Heli, VPP)
else:
if num_cp == 6:
self.tch_x = [ {'x':116, 'y':314, 'z':51, 'h':25, 'r':40} ] # USA(NB)
else:
self.tch_x = [ {'x':338.5, 'y':846, 'z':67, 'h':30, 'r':55} ] # USA(NB)
if map == "highway_tampa":
if army == 1:
self.tch_x = [ {'x':-493, 'y':636.5, 'z':25, 'h':25, 'r':105} ] # MEC(NB)
else:
self.tch_x = [ {'x':608, 'y':-526, 'z':25, 'h':15, 'r':50},{'x':706, 'y':-466.5, 'z':26, 'h':25, 'r':50} ] # USA(NB, VPP)
if map == "taraba_quarry":
if army == 1:
if num_cp == 5:
self.tch_x = [ {'x':18.5, 'y':186.4, 'z':120, 'h':25, 'r':35} ] # MEC(NB)
else:
self.tch_x = [ {'x':-489, 'y':-553, 'z':155, 'h':25, 'r':70}, {'x':-645.5, 'y':-525, 'z':160, 'h':20, 'r':50} ] # MEC(NB, VPP)
else:
if num_cp == 7:
self.tch_x = [ {'x':427, 'y':-461.5, 'z':155, 'h':20, 'r':60}, {'x':575.5, 'y':-420, 'z':160, 'h':20, 'r':45} ] # EURO(NB, VPP)
if map == "operationsmokescreen":
if army == 1:
self.tch_x = [ {'x':72.5, 'y':-522, 'z':96, 'h':15, 'r':60}, {'x':108, 'y':-629, 'z':87, 'h':30, 'r':70} ] # MEC(NB, VPP)
else:
self.tch_x = [ {'x':7, 'y':430.5, 'z':96, 'h':15, 'r':55}, {'x':87, 'y':528.5, 'z':97, 'h':30, 'r':80} ] # EURO(NB, VPP)
if map == "road_to_jalalabad":
if army == 2:
self.tch_x = [ {'x':-205.4, 'y':7.7, 'z':40, 'h':15, 'r':45} ] # USA(NB)
if map == "sharqi_peninsula":
if army == 1:
if num_cp == 4:
self.tch_x = [ {'x':-316.3, 'y':-226.2, 'z':78, 'h':6, 'r':25} ] # MEC(NB)
else:
self.tch_x = [ {'x':-647, 'y':205, 'z':90, 'h':15, 'r':27}, {'x':-605, 'y':-201, 'z':90, 'h':15, 'r':35}, {'x':-288.5, 'y':-597, 'z':70, 'h':15, 'r':25}, {'x':-247.5, 'y':-585, 'z':75, 'h':20, 'r':18} ] # MEC(NB, NB, NB, Heli)
else:
if num_cp > 4:
self.tch_x = [ {'x':-98.25, 'y':-144.25, 'z':128, 'h':15, 'r':15, 'point':'tvstation', 'owner':2, 'c':13} ] # USA(Heli)
if map == "strike_at_karkand":
if army == 2:
self.tch_x = [ {'x':-160, 'y':-282, 'z':159, 'h':10, 'r':40} ] # USA(NB)
if map == "operation_blue_pearl":
if num_cp > 4:
if army == 2:
self.tch_x = [ {'x':282, 'y':-123, 'z':15, 'h':20, 'r':58} ] # USA(island)
if map == "midnight_sun":
if num_cp > 4:
if army == 2:
self.tch_x = [ {'x':533, 'y':-40, 'z':110, 'h':25, 'r':65}, {'x':607, 'y':61, 'z':110, 'h':25, 'r':75} ] # USA()
else:
self.tch_x = [ {'x':-735, 'y':-382, 'z':96, 'h':20, 'r':75}, {'x':-664, 'y':-346, 'z':103, 'h':20, 'r':82} ] # PLA()
if map == "operationharvest":
if army == 2:
if num_cp == 5:
self.tch_x = [ {'x':471.7, 'y':436, 'z':30, 'h':20, 'r':59} ] # USA(NB)
if num_cp == 8:
self.tch_x = [ {'x':-405, 'y':-561, 'z':32, 'h':25, 'r':47}, {'x':-455, 'y':-495, 'z':28, 'h':25, 'r':51} ] # USA(NB, heli)
if num_cp == 9:
self.tch_x = [ {'x':-405, 'y':-561, 'z':32, 'h':25, 'r':47}, {'x':-442, 'y':-483, 'z':28, 'h':25, 'r':42}, {'x':340, 'y':-486, 'z':48, 'h':25, 'r':31} ] # USA(NB, heli)
else:
if num_cp == 8:
self.tch_x = [ {'x':245, 'y':678, 'z':35, 'h':25, 'r':42}, {'x':215, 'y':560, 'z':28, 'h':25, 'r':48} ] # MEC(heli,NB)
if num_cp == 9:
self.tch_x = [ {'x':245, 'y':678, 'z':35, 'h':25, 'r':42} ] # MEC(heli)
if map == "operationroadrage":
if army == 2:
if num_cp == 5:
self.tch_x = [ {'x':329, 'y':127.5, 'z':50, 'h':15, 'r':57} ] # USA()
if num_cp == 7:
self.tch_x = [ {'x':-130, 'y':818, 'z':50, 'h':20, 'r':47}, {'x':45, 'y':808, 'z':45, 'h':20, 'r':35} ] # USA()
else:
if num_cp == 5:
self.tch_x = [ {'x':-169, 'y':-188, 'z':40, 'h':20, 'r':62} ] # MEC()
if num_cp == 7:
self.tch_x = [ {'x':32, 'y':-738, 'z':45, 'h':20, 'r':67}, {'x':-148.5, 'y':-738, 'z':45, 'h':20, 'r':43} ] # MEC(heli,NB)

class old_baserape_maps(object):
def __init__(self, map, army):
self.r = 0
if map == "greatwall" and army==1:
self.r = 50
if map == "greatwall" and army==2:
self.r = 30
if map == "jibbel_city" and army==2:
self.r = 30
if map == "bocage_2005" and army==1:
self.r = 65
if map == "bocage_2005" and army==2:
self.r = 40
if map == "strike_at_karkand_2" and army==2:
self.r = 40
if map == "berlin" and army==2:
self.r = 18
if map == "heliwar" and army==2:
self.r = 125
if map == "heliwar" and army==1:
self.r = 115
if map == "rising_city" and army==2:
self.r = 30
if map == "vulcan_island" and army==2:
self.r = 35


check_new_maps = { "daqing_oilfields":[7,9], "gulf_of_oman":[7,9], "dalian_plant":[6,8], "operation_clean_sweep":[4,6,8], "kubra_dam":[8,9],
"wake_island_2007":[6],"zatar_wetlands":[7,9],"dragon_valley":[6,11],"fushe_pass":[6,10],"highway_tampa":[6,8],"taraba_quarry":[5,7],
"operationsmokescreen":[7],"road_to_jalalabad":[7,8],"sharqi_peninsula":[4,8,9], "strike_at_karkand":[7,9],"operation_blue_pearl":[7,8],
"midnight_sun":[6,8],"operationharvest":[5,8,9],"operationroadrage":[5,7]
}

check_old_maps = ["greatwall","jibbel_city","stream","bocage_2005","strike_at_karkand_2","berlin","cp_abadan","vulcan_island","rising_city", "heliwar"]

check_noVeh_maps = ["greatwall","sharqi_peninsula","road_to_jalalabad","jibbel_city","berlin"]

mapName = ""
noVehicles = 0
num_cp = 0


class new_baserape2( object ):
def __init__( self, modManager ):
self.mm = modManager
self.__state = 0

def onEnterVehicle( self, player, vehicle, freeSoldier):
plVehicle = player.getVehicle()
pl_Vehicle = bf2.objectManager.getRootParent(plVehicle)
if ((getVehicleType(pl_Vehicle.templateName) == VEHICLE_TYPE_HELICOPTER) or (getVehicleType(pl_Vehicle.templateName) == VEHICLE_TYPE_AVIATOR)):
player.faa.enterVeh = int(time.time())


def onExitVehicle(self, player, vehicle):
if not player.isAlive():
player.faa.enterVeh = 0
return

if player.faa.enterVeh > 0:
plVehicle = player.getVehicle()
pl_Vehicle = bf2.objectManager.getRootParent(plVehicle)
if (getVehicleType(pl_Vehicle.templateName) == VEHICLE_TYPE_SOLDIER):
player.faa.enterVeh = 0


def onPlayerKilled(self, victim, attacker, weapon, assists, object):
if (attacker == None) or (attacker.getTeam() == victim.getTeam()) or (victim == None) or (weapon == None):
return

if int(noVehicles) == 1:
if mapName not in check_noVeh_maps:
return

if (mapName == "sharqi_peninsula") and (victim.getTeam() == 2):
return
else:
if(victim.faa.enterVeh>0):
delta = int(time.time()) - victim.faa.enterVeh
if int(delta) > 20:
return

#victimVehicle = victim.getVehicle()
#vic_Vehicle = bf2.objectManager.getRootParent(victimVehicle)
#attackerVehicle = attacker.getVehicle()
#att_Vehicle = bf2.objectManager.getRootParent(attackerVehicle)

#attackerVehicle = bf2.objectManager.getRootParent(weapon)
#if attacker == (attackerVehicle.isPlayerControlObject and attackerVehicle.getIsRemoteControlled()):
#pass
#else:
#if (getVehicleType(att_Vehicle.templateName) == VEHICLE_TYPE_SOLDIER) or (getVehicleType(vic_Vehicle.templateName) == VEHICLE_TYPE_AIRDEFENSE):
#return

if attacker == victim:
pass
elif attacker != None and attacker.getTeam() != victim.getTeam():
self.checkForSafeBase(victim, attacker, mapName, num_cp)

if check_new_maps.has_key(mapName) and num_cp in check_new_maps[mapName]:
self.checkForSafeBase(victim, attacker, mapName, num_cp)

if mapName in check_old_maps:
tx = old_baserape_maps(mapName, victim.getTeam())
if tx.r > 0:
victimVehicle = victim.getVehicle()
controlPoints = bf2.objectManager.getObjectsOfType('dice.hfe.world.ObjectTemplate.ControlPoint')
for cp in controlPoints:
if cp.cp_getParam('unableToChangeTeam') != 0 and cp.cp_getParam('team') != attacker.getTeam():
distanceTo = self.getVectorDistance(victimVehicle.getPosition(), cp.getPosition())
if float(distanceTo) < tx.r:
mm_utils.msg_server (" §3" + attacker.getName() + " - §C1001 Jangan Pantek Cok §C1001")
self.mm.info("BASERAPE! att=" + str(attacker.getName()) + " vic=" + str(victim.getName()) +" Radius=" + str(tx.r) + " Distance=" + str(distanceTo) )
self.justify(attacker, victim)


def checkForSafeBase(self, victim, attacker, mapName, num_cp):
victimVehicle = victim.getVehicle()
coor_X = victimVehicle.getPosition()[0]
coor_Y = victimVehicle.getPosition()[2]
coor_Z = victimVehicle.getPosition()[1]

tx = new_baserape_maps(mapName, num_cp, victim.getTeam())
for cp in tx.tch_x:
if (float(coor_Z) > cp['z']) and (float(coor_Z) < (cp['z'] + cp['h'])):
dist = math.sqrt( (float(coor_X) - float(cp['x']))**2 + (float(coor_Y) - float(cp['y']))**2 )
if float(dist) < cp['r']:
if cp.has_key('point'):
attackerVehicle = attacker.getVehicle()
att_Vehicle = bf2.objectManager.getRootParent(attackerVehicle)
if ((getVehicleType(att_Vehicle.templateName) == VEHICLE_TYPE_ARMOR) or (getVehicleType(att_Vehicle.templateName) == VEHICLE_TYPE_TRANSPORT)):
return

for obj in bf2.objectManager.getObjectsOfType('dice.hfe.world.ObjectTemplate.ControlPoint'):
namepoint = obj.templateName.lower()[cp['c']:]
if (namepoint == cp['point']):
ownerteam = int(obj.cp_getParam('team'))
if (ownerteam != cp['owner']):
return

mm_utils.msg_server(" §3" + attacker.getName() + " - §C1001 Jangan Pantek Cok §C1001")
self.mm.info("BASERAPE! att=" + str(attacker.getName()) + " vic=" + str(victim.getName()) +" Radius=" + str(cp['r']) + " Distance=" + str(dist) )
self.justify(attacker, victim)


def justify(self, attacker, victim):
vehicle = attacker.getVehicle()
rootVehicle = getRootParent(vehicle)

victim.timedeath = int(time.time())
victim.score.deaths += -1
attacker.score.kills += -2
attacker.score.score += -2 - attacker.faa.warning
attacker.score.TKs += 1
attacker.faa.warning += 1
#if getVehicleType(rootVehicle.templateName) != VEHICLE_TYPE_SOLDIER:
# attacker.faa.warning +=1
#if attacker.faa.warning > 3:
#victim.score.deaths += -1
#attacker.score.kills += -2
#attacker.score.score += -4 - attacker.faa.warning
# attacker.score.TKs += 1
#vehicle = aattacker.getVehicle()
#rootVehicle = getRootParent(vehicle)
#if getVehicleType(rootVehicle.templateName) == VEHICLE_TYPE_SOLDIER:
#attacker.faa.warning += 1
#if getVehicleType(rootVehicle.templateName) != VEHICLE_TYPE_SOLDIER:
#attacker.faa.warning += 1
if attacker.isAlive():
#vehicle = attacker.getVehicle()
#rootVehicle = getRootParent(vehicle)
#if getVehicleType(rootVehicle.templateName) != VEHICLE_TYPE_SOLDIER:
# attacker.faa.warning += 1
if getVehicleType(rootVehicle.templateName) != VEHICLE_TYPE_SOLDIER:
#attacker.faa.warning += 1
rootVehicle.setDamage(0.01)
#else:
#attacker.faa.warning += 1
#rootVehicle.setDamage(1)
if attacker.isCommander():
team = attacker.getTeam()
enemyteam = 3 - team
attacker.setTeam(enemyteam)
attacker.setTeam(team)
if attacker.faa.warning > 4:
#victim.score.deaths += -1
#attacker.score.kills += -2
#attacker.score.score += -4
#attacker.score.TKs += 1
#attacker.faa.warning += 1
mm_utils.msg_server (" - §3 §C1001 Nah Kan Batoe Seh Loe §C1001")
host.rcon_invoke('game.sayall "Player %s kicked for violating of the no kill rules within safe base area"' % (attacker.getName() ) )
host.rcon_invoke('admin.kickplayer "%s" %i "You kicked for violating of the no kill rules within safe base area"' % (attacker.getName(), 15) )


def getVectorDistance(self, pos1, pos2):
diffVec = [0.0, 0.0, 0.0]
diffVec[0] = math.fabs(pos1[0] - pos2[0])
diffVec[1] = math.fabs(pos1[1] - pos2[1])
diffVec[2] = math.fabs(pos1[2] - pos2[2])

return math.sqrt(diffVec[0] * diffVec[0] + diffVec[1] * diffVec[1] + diffVec[2] * diffVec[2])


def onGameStatusChanged( self, status ):
if status == bf2.GameStatus.Playing:
global num_cp, mapName, noVehicles
controlPoints = bf2.objectManager.getObjectsOfType('dice.hfe.world.ObjectTemplate.ControlPoint')
num_cp = len(controlPoints)
mapName = bf2.gameLogic.getMapName()
noVehicles = int(bf2.serverSettings.getnoVehicles())
for player in bf2.playerManager.getPlayers():
player.faa.timedeath = 0
player.faa.warning = 0
player.faa.enterVeh = 0


def onPlayerRevived(self, attacker, victim):
if int(attacker.timedeath) > 0:
timex = int(time.time()) - int(attacker.timedeath)
if int(timex) < 16:
attacker.score.deaths += 1
attacker.timedeath = 0


def onPlayerConnect(self, player):
player.faa = fStt(player)


def init( self ):
host.registerGameStatusHandler( self.onGameStatusChanged )

if 0 == self.__state:
host.registerHandler('PlayerConnect', self.onPlayerConnect, 1 )
host.registerHandler('PlayerKilled', self.onPlayerKilled )
host.registerHandler('PlayerRevived', self.onPlayerRevived )
host.registerHandler('EnterVehicle', self.onEnterVehicle )
host.registerHandler('ExitVehicle', self.onExitVehicle )

self.__state = 1


def mm_load( modManager ):
"""Creates and returns your object."""
return new_baserape2( modManager )


and this one antispawnrape for modmanager

Раскрывающийся текст

# -*- coding: cp1252 -*-
# This script has been modifed by Titch2349, of the BF2s Forums.
# Website: http://www.mattlunn.me.uk
# Contact: matt@mattlunn.me.uk
# -*- coding: cp1252 -*-
#thx matlunn i made it for modmanager by watdezig aka seanman from kaskus.co.id
# This script is based on the AntiBaseRape.py, created by SANders.

import host
import bf2
import math
import mm_utils
from bf2.stats.constants import *
from bf2 import g_debug

# ------ DON'T EDIT ABOVE THIS LINE UNLESS YOU KNOW WHAT YOU ARE DOING! ----------
__version__ = 1.2

__required_modules__ = {
'modmanager': 1.0
}

__supports_reload__ = True

__description__ = "AntiSpawnRape 2 v%s" % __version__

ALLOWED_SPAWNRAPEKILLS = 5 # This is the amount of spawn kills allowed before getting kicked
SPAWNRAPE_TIME = 4 # The amount of time after a player spawns (in seconds), after which a kill is no longer deemed as spawnrape.
SPAWNRAPE_DEDUCTION_INTERVAL = 120 # Intervals between removing a point from players.spawnRapeWarning

# ------ DON'T EDIT BELOW THIS LINE UNLESS YOU KNOW WHAT YOU ARE DOING! ----------

WarnReduceTimer = None # Timer that reduces the warnings at intervals

class SpawnRape( object ) :

def __init__( self, modManager ):
# ModManager reference
self.mm = modManager

# Internal shutdown state
self.__state = 0

def init(self):
if g_debug: print "AntiSpawnRape init"
if 0 == self.__state:
host.registerHandler('PlayerConnect', self.onPlayerConnect, 1)
host.registerHandler('PlayerKilled', self.onPlayerKilled)
host.registerHandler('PlayerSpawn', self.onPlayerSpawn)

self.__state=1

WarnReduceTimer = bf2.Timer(self.onSafeBaseKillTimer, SPAWNRAPE_DEDUCTION_INTERVAL, 1)
WarnReduceTimer.setRecurring(SPAWNRAPE_DEDUCTION_INTERVAL)
for p in bf2.playerManager.getPlayers():
self.onPlayerConnect(p)





def onPlayerConnect(self, player):
self.resetPlayer(player)

def onPlayerSpawn(self, player,soldier):
bf2.Timer(self.cancelPlayerSpawn, SPAWNRAPE_TIME, 1, player)
player.hasJustSpawned = 1

def cancelPlayerSpawn(self, player):
player.hasJustSpawned = 0

def onPlayerKilled(self, victim, attacker, weapon, assists, object):
if attacker == victim:
pass
elif attacker != None and attacker.getTeam() != victim.getTeam():
self.checkForJustSpawned(attacker, victim)
def shutdown( self ):
"""Shutdown and stop processing."""

# Unregister game handlers and do any other
# other actions to ensure your module no longer affects
# the game in anyway
if WarnReduceTimer:
WarnReduceTimer = None
WarnReduceTimer.destroy()

# Flag as shutdown as there is currently way to:
# host.unregisterHandler
self.__state = 2

def resetPlayer(self, player):
player.spawnRapeWarning = 0
def checkForJustSpawned(self, attacker, victim):
victimVehicle = victim.getVehicle()
if victim.hasJustSpawned == 1:
self.justify(attacker, victim)




def justify(self, attacker, victim):
victim.score.deaths += -1
attacker.score.kills += -1
attacker.score.score += -2 - attacker.spawnRapeWarning
attacker.spawnRapeWarning += 1
self.sendWarning(attacker)
#vehicle = attacker.getVehicle()
#rootVehicle = getRootParent(vehicle)
#if getVehicleType(rootVehicle.templateName) == VEHICLE_TYPE_SOLDIER:
# attacker.spawnRapewWarning +=1
# sendWarning(attacker)
#if getVehicleType(rootVehicle.templateName) == VEHICLE_TYPE_SOLDIER:
# attacker.spawnRapewWarning +=1
# sendWarning(attacker)
if attacker.spawnRapeWarning > ALLOWED_SPAWNRAPEKILLS:
# victim.score.deaths += -1
# attacker.score.kills += -1
# attacker.score.score += -2 - attacker.spawnRapeWarning
# attacker.spawnRapeWarning += 1
# sendWarning(attacker)
host.rcon_invoke("admin.kickPlayer " + str(attacker.index))

def sendWarning(self, player):
if player.spawnRapeWarning > ALLOWED_SPAWNRAPEKILLS:
mm_utils.msg_server(" §3 §C1001 duh g ngrti lg dch w ma u" + player.getName())
else:
mm_utils.msg_server(" §3 " + player.getName() + ",§3 §C1001 Nah Yaaaa!!! (" + str(player.spawnRapeWarning) + ")")

def onSafeBaseKillTimer(self, data):
for p in bf2.playerManager.getPlayers():
if p.spawnRapeWarning <= 0:
p.spawnRapeWarning = 0
else:
p.spawnRapeWarning += -1

def sendMsgAll(self, msg):
host.rcon_invoke("game.sayAll \"" + str(msg) + "\"")


def mm_load( modManager ):
"""Creates and returns your object."""
return SpawnRape( modManager )


enjoy and thx for this forum smile.gif.
Tema567
Цитата(seanman @ Понедельник, 10 Сентября 2012, 21:02:29) [snapback]1749056[/snapback]

Thx tema567 smile.gif.. btw i've another made a baserape script with more points it works for infant and vehicle
enjoy and thx for this forum smile.gif.

Thanks for your scripts, man it will be useful, already stored in my collection.

Also i've written some scripts and doing new functions on our servers. maybe you have ideas what's should be implemented as bonus in addition to these great scripts.
seanman
rolleyes.gif errr.. ahahaha i dont have it for now but later yes i will share it to you and this forum smile.gif

and so thanks to sh@rk biggrin.gif too.
Для просмотра полной версии этой страницы, пожалуйста, пройдите по ссылке.
Форум IP.Board © 2001-2024 IPS, Inc.