All pastes #203076 Raw Edit

Mine

public cpp v1 · immutable
#203076 ·published 2006-10-14 22:28 UTC
rendered paste body
// SmallTeams.cpp : Defines the entry point for the DLL application.//#include "bzfsAPI.h"#include <string>#include <cstdlib>#include <ctime>#include "../../include/TextUtils.h"#include <sstream>BZ_GET_PLUGIN_VERSIONclass SmallTeamsRules : public bz_EventHandler{public:        bool do_flagreset;      int maxTanks;        virtual void process(bz_EventData *eventData);        bool enforce_rules;};SmallTeamsRules SmallTeams;BZF_PLUGIN_CALL int bz_Load (const char* commandLine){        int intCommandLine = 0;        std::istringstream command(commandLine)        command >> intCommandLine;        if (intCommandLine > 0)                SmallTeams.maxTanks = intCommandLine;        else SmallTeams.maxTanks=4;        std::string result = TextUtils::format("SmallTeamsRules plugin loaded (%i players)", SmallTeams.maxTanks);        bz_sendTextMessage (BZ_SERVER, BZ_ALLUSERS, result.c_str());        SmallTeams.enforce_rules = false;  bz_registerEvent (bz_ePlayerDieEvent, &SmallTeams);  bz_debugMessage(4,"Small Team Rules plugin loaded");  return 0;}BZF_PLUGIN_CALL int bz_Unload ( void ){  bz_removeEvent (bz_ePlayerDieEvent, &SmallTeams);  bz_debugMessage(4,"SmallTeamsRules plugin unloaded");  return 0;}void SmallTeamsRules::process(bz_EventData *eventData){        int totalTanks =                bz_getTeamCount (eRogueTeam) +                bz_getTeamCount (eRedTeam) +                bz_getTeamCount (eGreenTeam) +                bz_getTeamCount (eBlueTeam) +                bz_getTeamCount (ePurpleTeam) +                bz_getTeamCount (eRabbitTeam);        if (totalTanks <= maxTanks)        {                if (!enforce_rules)                {                        enforce_rules = true;                        std::string result = TextUtils::format("Small team rules are in effect (%i players)", maxTanks);                        bz_sendTextMessage (BZ_SERVER, BZ_ALLUSERS, result.c_str());                }        }        else        {                if (enforce_rules)                {                        enforce_rules = false;                        bz_sendTextMessage (BZ_SERVER, BZ_ALLUSERS, "Small team rules have been lifted.");                }        }        if (enforce_rules)        {                bz_PlayerDieEventData* killdata = (bz_PlayerDieEventData*)eventData;                //team flags don't count                if (killdata->flagKilledWith != "R*" && killdata->flagKilledWith != "G*" && killdata->flagKilledWith != "B*" && killdata->flagKilledWith != "P*")                {                                bz_removePlayerFlag(killdata->killerID);                }        }}// Local Variables: ***// mode:C++ ***// tab-width: 8 ***// c-basic-offset: 2 ***// indent-tabs-mode: t ***// End: ***// ex: shiftwidth=2 tabstop=8