Difference between revisions of "Bz getPlayerTeam"

From BZFlagWiki
Jump to: navigation, search
(Added bz_getPlayerTeam)
 
(Oh my god was the example fugly)
 
(4 intermediate revisions by 2 users not shown)
Line 5: Line 5:
 
| param1type  = int
 
| param1type  = int
 
| param1desc  = Player to lookup.
 
| param1desc  = Player to lookup.
| returnType = bz_eTeamType
+
| returntype = bz_eTeamType
| return     = Team the player belongs to.
+
| returns     = Team the player belongs to.
 
}}
 
}}
 +
===Example===
 +
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;

Latest revision as of 10:42, 4 December 2013

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;