bz_getPlayerTeam

From BZFlagWiki
Revision as of 10:42, 4 December 2013 by Allejo (Talk | contribs) (Oh my god was the example fugly)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

bz_eTeamType bz_getPlayerTeam (int playerID)


Returns the player's team.

Parameters:
playerID  -  Player to lookup.
Returns:
Team the player belongs to.

Example[edit]

Display what team the player joined as a welcome message.

case bz_ePlayerJoinEvent: {
   bz_PlayerJoinPartEventData_V1 *join = (bz_PlayerJoinPartEventData_V1*)eventData;
   std::string teamColor = "Unknown";    

   if (bz_getPlayerTeam(join->playerID) == eRogueTeam)
       teamColor = "rogue";
   else if (bz_getPlayerTeam(join->playerID) == eRedTeam)
       teamColor = "red";
   else if (bz_getPlayerTeam(join->playerID) == eGreenTeam)
       teamColor = "green";
   else if (bz_getPlayerTeam(join->playerID) == eBlueTeam)
       teamColor = "blue";
   else if (bz_getPlayerTeam(join->playerID) == ePurpleTeam)
       teamColor = "purple";
   else if (bz_getPlayerTeam(join->playerID) == eObservers)
       teamColor = "observer";

   bz_sendTextMessagef(BZ_SERVER, join->playerID, "Welcome! You joined the %s team!", teamColor.c_str());
}
break;