This wiki is archived and useful information is being migrated to the main bzflag.org website
Difference between revisions of "Bz getPlayerTeam"
From BZFlagWiki
m (returnType -> returntype) |
(Removed version 2.99.x requirement. Added an example.) |
||
Line 7: | Line 7: | ||
| returntype = bz_eTeamType | | returntype = bz_eTeamType | ||
| returns = 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: { | ||
+ | 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; |
Revision as of 06:05, 19 October 2011
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;