This wiki is archived and useful information is being migrated to the main bzflag.org website
bz_getPlayerTeam
From BZFlagWiki
Revision as of 06:05, 19 October 2011 by Sigonasr2 (Talk | contribs) (Removed version 2.99.x requirement. Added an example.)
bz_eTeamType bz_getPlayerTeam (int playerID)
Returns the player's team.
Parameters:
playerID - Player to lookup.
Returns:
Team the player belongs to.
Example
Display what team the player joined as a welcome message.
case bz_ePlayerJoinEvent: { char myteam[8]; if (bz_getPlayerTeam(((bz_PlayerJoinPartEventData_V1*)eventData)->playerID)==eBlueTeam) {strcpy(myteam,"Blue");} else if (bz_getPlayerTeam(((bz_PlayerJoinPartEventData_V1*)eventData)->playerID)==eRogueTeam) {strcpy(myteam,"Rogue");} else if (bz_getPlayerTeam(((bz_PlayerJoinPartEventData_V1*)eventData)->playerID)==eRedTeam) {strcpy(myteam,"Red");} else if (bz_getPlayerTeam(((bz_PlayerJoinPartEventData_V1*)eventData)->playerID)==eGreenTeam) {strcpy(myteam,"Green");} else if (bz_getPlayerTeam(((bz_PlayerJoinPartEventData_V1*)eventData)->playerID)==ePurpleTeam) {strcpy(myteam,"Purple");} else if (bz_getPlayerTeam(((bz_PlayerJoinPartEventData_V1*)eventData)->playerID)==eHunterTeam) {strcpy(myteam,"Hunter");} else if (bz_getPlayerTeam(((bz_PlayerJoinPartEventData_V1*)eventData)->playerID)==eObservers) {strcpy(myteam,"Observer");} else {strcpy(myteam,"Unknown");} bz_sendTextMessagef(BZ_SERVER,((bz_PlayerJoinPartEventData_V1*)eventData)->playerID,"Welcome! You joined the %s team!",myteam); }break;