Advertisement
Guest User

Untitled

a guest
May 16th, 2010
139
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 2.21 KB | None | 0 0
  1. /* flagResetOnCap Plugin (No Parameters
  2.    
  3.    Original plugin written by flying_popcorn but
  4.    never publicly released and modified by allejo
  5.    to reset all flags excluding team flags.
  6.    
  7.    How to load:
  8.  
  9.    In a conf file add: -loadplugin /path/to/flagResetOnCap.so,<number of teams in the CTF map>
  10.    In the game type: /loadplugin /path/to/flagResetOnCap.so,<number of teams in the CTF map>
  11.  
  12.    Purpose:
  13.  
  14.    After every time that a flag is captured this plugin will reset all super flags and bad
  15.    flags to make sure that the flags are evenly spread out. This also prevents players from
  16.    over using a certain flag. Please note this plugin only resets flags after someone
  17.    captures the flag, this plugin will NOT reset the flags in a FFA, KOTH, or Rabbit Hunt.
  18.    
  19.    If there is a team in existence playing in the CTF game there is going to be a player
  20.    limit for that team, now the plugin checks that player limit and if it's more than one
  21.    player for a certain them than it will assume it is a 1-Way CTF. It then will check the
  22.    next team and if it's more than one player it will assume it is a 2-Way CTF. And so on.
  23.    
  24.    License: GPLv3
  25. */
  26.  
  27. #include "bzfsAPI.h"
  28. #include <string>
  29.  
  30. #define TOTAL_CTF_TEAMS 4
  31.  
  32. BZ_GET_PLUGIN_VERSION
  33.  
  34. // event handler callback
  35. class ONCAPHandler : public bz_EventHandler
  36.   {
  37.   public:
  38.     virtual void    process ( bz_EventData *eventData );
  39.   };
  40.  
  41. ONCAPHandler    OnCapHandler;
  42.  
  43. BZF_PLUGIN_CALL int bz_Load ( const char* commandLine)
  44. {
  45.   bz_debugMessage(4,"flagResetOnCap plugin loaded");
  46.   bz_registerEvent(bz_eCaptureEvent,&OnCapHandler);
  47.   return 0;
  48. }
  49.  
  50. BZF_PLUGIN_CALL int bz_Unload ( void )
  51. {
  52.   bz_removeEvent(bz_eCaptureEvent,&OnCapHandler);
  53.   bz_debugMessage(4,"flagResetOnCap plugin unloaded");
  54.   return 0;
  55. }
  56.  
  57. unsigned int getNumTeams()
  58. {
  59.   return TOTAL_CTF_TEAMS - (!bz_getTeamPlayerLimit(eRedTeam) +
  60.                             !bz_getTeamPlayerLimit(eGreenTeam) +
  61.                             !bz_getTeamPlayerLimit(eBlueTeam) +
  62.                             !bz_getTeamPlayerLimit(ePurpleTeam));
  63. }
  64.  
  65. void ONCAPHandler::process ( bz_EventData *eventData )
  66. {
  67.   for(int i = getNumTeams(); i < bz_getNumFlags(); i++)
  68.     bz_resetFlag(i);
  69. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement