示例#1
0
void resetTeamFlag (bz_ApiString flagSent)
{
	for ( unsigned int i = 0; i < bz_getNumFlags(); i++ )
	{
		if (flagSent == bz_getFlagName(i))
			bz_resetFlag (i);
	}
}
示例#2
0
void flagResetTimerHandler::Event(bz_EventData *eventData)
{
    switch (eventData->eventType)
    {
        case bz_eTickEvent:
        {
            double timeLimitSeconds = timeLimitMinutes*60;
            std::string flagname = bz_getName(0).c_str();
            
            if(flagname=="R*" || flagname=="G*" || flagname=="B*" || flagname=="P*")
            {
                gameStyle = "ctf";
            }
            
            if(nextReset<bz_getCurrentTime())
            {
                if(gameStyle=="ctf")
                {
                    for(unsigned int i = getNumTeams(); i < bz_getNumFlags(); i++)
                    {
                          if(bz_flagPlayer(i)==-1)
                              bz_resetFlag(i);
                      }
                }
                else
                {
                    for(unsigned int i = 0; i < bz_getNumFlags(); i++)
                    {
                          if(bz_flagPlayer(i)==-1)
                              bz_resetFlag(i);
                    }
                }
                
                nextReset = bz_getCurrentTime()+timeLimitSeconds;
            }
        }
        break;
        
        default:break;
    }
}
示例#3
0
bool autoFlagReset::ResetUnusedSuperflag(unsigned int flagID)
{
    // Sanity check.
    if (flagID >= bz_getNumFlags())
        return false;

    // Make sure the flag isn't held.
    if (bz_flagPlayer(flagID) != -1)
        return false;

    // Make sure it's not a teamflag.
    bz_ApiString flagType = bz_getFlagName(flagID);
    if (flagType == "R*" || flagType == "G*" || flagType == "B*" || flagType == "P*" ||  flagType == "")
        return false;

    // Looks ok, reset it.
    return bz_resetFlag(flagID);
}
示例#4
0
bool flagResetTimerHandler::SlashCommand (int playerID, bz_ApiString _command, bz_ApiString _message, bz_APIStringList *params)
{
    std::string command = _command.c_str();
    std::string message = _message.c_str();
        
    bz_BasePlayerRecord *playerdata;
    playerdata = bz_getPlayerByIndex(playerID);
    
    if(command == "flagresetunused" && (bz_hasPerm(playerID, "flagMaster")||bz_hasPerm(playerID, "FLAGMASTER")))
    {
        if(gameStyle=="ctf")
        {
            for(unsigned int i = getNumTeams(); i < bz_getNumFlags(); i++)
            {
                  if(bz_flagPlayer(i)==-1)
                      bz_resetFlag(i);
            }
        }
        else
        {
            for(unsigned int i = 0; i < bz_getNumFlags(); i++)
            {
                  if(bz_flagPlayer(i)==-1)
                      bz_resetFlag(i);
            }
        }
        
        nextReset = bz_getCurrentTime()+(timeLimitMinutes*60);
        
        return 1;
    }
    else if(command == "frsettime" && (bz_hasPerm(playerID, "flagMaster")||bz_hasPerm(playerID, "FLAGMASTER")))
    {
        double invalue = ConvertToInteger(message);
        
        if (invalue > 0)
        {
            timeLimitMinutes=invalue;
            bz_sendTextMessagef (BZ_SERVER, BZ_ALLUSERS, "Flag reset time has been set to %i minutes by %s.", timeLimitMinutes,playerdata->callsign.c_str());
            nextReset = bz_getCurrentTime()+(timeLimitMinutes*60);
        }
        else
        {
            bz_sendTextMessagef (BZ_SERVER, playerID, "Flag reset time invalid: must be between 1 and 120 minutes.");
        }

        return 1;
    }
    else if(command == "frcurrenttime")
    {
        bz_sendTextMessagef (BZ_SERVER, playerID, "Current flag reset time is set to: %i minute(s).",timeLimitMinutes);
    }
    else
    {
        bz_sendTextMessage(BZ_SERVER,playerID,"You do not have the permission to run the flag reset commands.");
    }
    
    bz_freePlayerRecord(playerdata);
    
    return 1;
}