Esempio n. 1
0
void observerChat::Event ( bz_EventData *eventData )
{
  switch (eventData->eventType)
  {
  case bz_eRawChatMessageEvent:
    {
      bz_ChatEventData_V1 *data = (bz_ChatEventData_V1*)eventData;
      int from = data->from;
      bool isObserver = bz_getPlayerTeam(from) == eObservers;
      bool canSpawn = bz_hasPerm(from,bz_perm_spawn);
      const char* duringTheGame = "";

      if (!isObserver && canSpawn) return;
      if (data->to != BZ_ALLUSERS && (isObserver || data->team == eNoTeam)) return;
      if (bz_hasPerm(from,permName) || bz_getAdmin(from)) return;

      std::string variableValue = makelower(bz_getBZDBString(variableName).c_str());
      if (variableValue == "off" || variableValue == "disable" || variableValue == "disabled" || variableValue == "no") return;
      else if (!(variableValue == "on" || variableValue == "always" || variableValue == "alwayson" || variableValue == "enable" || variableValue == "enabled" || variableValue == "yes")) {
        if (!bz_isCountDownActive()) return;
        duringTheGame = " during the game";
      }

      bz_sendTextMessagef(BZ_SERVER,from,"You are not allowed to send global messages%s.",duringTheGame);
      bz_sendTextMessagef(BZ_SERVER,from,"Please use observer chat only.");
      data->message = "";
    }
    break;
  default:
    break;
  }
}
Esempio n. 2
0
 bool MapChangeCommandHandler::handle ( int playerID, bz_ApiString command, bz_ApiString message, bz_APIStringList *params )
 {
   std::string cmd;
   tolower(command.c_str(),cmd);

   std::string param;
   if ( params && params->size() )
     param = params->get(0).c_str();

   if ( cmd == "mapnext" )
   {
     if (bz_getAdmin (playerID) || bz_hasPerm(playerID,"mapchange"))
      nextMap();
     else
      bz_sendTextMessage(BZ_SERVER,playerID,"You do not have permision to change maps");
     return true;
   }
   else if ( cmd == "mapreset" )
   {
     if (bz_getAdmin (playerID) || bz_hasPerm(playerID,"mapchange"))
     {
       resetGames();
       currentIndex = -1;
       nextMap();
     }
     else
       bz_sendTextMessage(BZ_SERVER,playerID,"You do not have permision to reset map rotation");
     return true;
   }
   else if ( cmd == "mapcyclemode" )
   {
     if (param.size())
     {
       if (bz_getAdmin (playerID) || bz_hasPerm(playerID,"mapchange"))
       {
	cycleMode = cycleFromString(param.c_str());
	std::string mode = "Map Rotation Mode changed to ";
	mode += param.c_str();
	bz_sendTextMessage(BZ_SERVER,BZ_ALLUSERS,mode.c_str());
       }
       else
	 bz_sendTextMessage(BZ_SERVER,playerID,"You do not have permision to set map modes");
    }
     else
     {
       std::string mode = "Current Map Rotation Mode:";
       mode += cycleToString(cycleMode);
       bz_sendTextMessage(BZ_SERVER,playerID,mode.c_str());
     }
     return true;
   }
   else if ( cmd == "mapendmode" )
   {
     if (param.size())
     {
	if (bz_getAdmin (playerID) || bz_hasPerm(playerID,"mapchange"))
	{
	  startTime = bz_getCurrentTime();
	  endCond = condFromString(param);
	  std::string mode = "Map End Condition changed to ";
	  mode += param;
	  bz_sendTextMessage(BZ_SERVER,BZ_ALLUSERS,mode.c_str());
	}
	else
	  bz_sendTextMessage(BZ_SERVER,playerID,"You do not have permision to set map modes");
     }
     else
     {
       std::string mode = "Current End Condtion:";
       mode += condToString(endCond);
       bz_sendTextMessage(BZ_SERVER,playerID,mode.c_str());
     }
     return true;
   }
   else if ( cmd == "maplist" )
   {
     bz_sendTextMessage(BZ_SERVER,playerID,"Maps In Rotation");
     for (int i = 0; i < (int)gameList.size(); i++ )
	 bz_sendTextMessage(BZ_SERVER,playerID,gameList[i].mapFile.c_str());
     return true;
   }
   else if ( cmd == "maplimit" )
   {
     if (endCond == eNoPlayers || endCond == eManual )
     {
       bz_sendTextMessage(BZ_SERVER,playerID,"The currnet mode has no numeric limit");
       return true;
     }

     if (param.size())
     {
       if (bz_getAdmin (playerID) || bz_hasPerm(playerID,"mapchange"))
       {
	 std::string mode = "Map Change limit changed to ";
	if (endCond == eTimedGame)
	{
	  startTime = bz_getCurrentTime();
	  timeLimit = atof(param.c_str())*60;
	  mode += param.c_str();
	  mode += "minutes";
	}
	else
	{
	  scoreCapLimit = atoi(param.c_str());
	  mode += param.c_str();
	  if (endCond == eMaxKillScore)
	    mode += " Kills";
	  else
	    mode += " Caps";
	}
	bz_sendTextMessage(BZ_SERVER,BZ_ALLUSERS,mode.c_str());
       }
       else
       {
	 std::string mode = "Map Change limit is ";
	 if (endCond == eTimedGame)
	   mode += format("%f minutes", timeLimit/60.0);
	 else
	 {
	    mode += format("%d", scoreCapLimit);
	   if (endCond == eMaxKillScore)
	     mode += " Kills";
	   else
	     mode += " Caps";
	 }
	 bz_sendTextMessage(BZ_SERVER,playerID,"You do not have permision to set map limits");
       }
     }
     else
     {
       std::string mode = "Current End Condtion:";
       mode += condToString(endCond);
       bz_sendTextMessage(BZ_SERVER,playerID,mode.c_str());
     }
     return true;
   }
   return false;
 }