This wiki is archived and useful information is being migrated to the main bzflag.org website
Difference between revisions of "Bz getPlayerTeam"
From BZFlagWiki
(Removed version 2.99.x requirement. Added an example.) |
(Oh my god was the example fugly) |
||
Line 11: | Line 11: | ||
Display what team the player joined as a welcome message. | Display what team the player joined as a welcome message. | ||
case bz_ePlayerJoinEvent: { | 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; | + | } |
+ | 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;