Talk:Scripts:AntiBaseRape

From BF2 Technical Information Wiki
Jump to: navigation, search
# ------------------------------------------------------------------------
# onGameStatusChanged
# ------------------------------------------------------------------------
def onGameStatusChanged(status):
   if status == bf2.GameStatus.Playing:
      host.registerHandler('PlayerKilled', onPlayerKilled)
# ------------------------------------------------------------------------

This seems a little redundant, since players can't be killed while in any other mode than 'playing', and it seems like the third paramenter for host.registerHandler is a boolean that, when set to false, only handles events thrown during that 'Playing' gamemode. --dst 07:31, 1 Aug 2005 (MDT)

Contents

DOSENT WORK

hi i tried this script but it dosent worked? i m not eaven get massages in the server text.. it chages absolutly nothing at me?


Suggestion

I've been running the script and I've noticed that the warnings for players always remain at 1... It seems the timer starts multiple instances (on every GameStatusChanged to Playing) and thus always reducing the number of warnings back to 0 very fast???

So I would like to suggest the next rewrite:

- Remove the 'onGameStatusChanged' part.

- Replace the 'Init' part with:

 # ------------------------------------------------------------------------
 # Variables
 # ------------------------------------------------------------------------
 
 WarnReduceTimer = None # Timer that reduces the warnings at intervals
 
 # ------------------------------------------------------------------------
 # Init
 # ------------------------------------------------------------------------
 
 def init():
    if g_debug: print "AntiBaseRape init"
    host.registerHandler('PlayerConnect', onPlayerConnect, 1)   
    host.registerHandler('PlayerKilled', onPlayerKilled)
 
    # Start the timer that reduces warnings on the SAFEBASEKILL_TIMER_INTERVAL
    WarnReduceTimer = bf2.Timer(onSafeBaseKillTimer, SAFEBASEKILL_TIMER_INTERVAL, 1)
    WarnReduceTimer.setRecurring(SAFEBASEKILL_TIMER_INTERVAL)
 
    # Connect already connected players if reinitializing
    for p in bf2.playerManager.getPlayers():
       onPlayerConnect(p)
 # ------------------------------------------------------------------------

(You might want to check this modification, for I'm not really a python expert ;) ) --Xlr8or 04:43, 4 Aug 2005 (MDT)

The init() function is only ever called once. It is never "reinitialized". --dst 07:37, 4 Aug 2005 (MDT)

Script updated !

I agree, and have updated the script part with your suggestion !

Summer holiday have prevented me from any more gameplay, programming and testing before now, sorrry for the wait.

Compatibility with 1.21 & 1.22

Just a question: Is it working with new Patches 1.21 & 1.22? I installed like you told us, but it is not working for me.

Thanks in advance for your answer!

Personal tools
Namespaces

Variants
Actions
Navigation
Toolbox