This wiki was in read-only mode for many years, but can now be edited again. A lot of information will need to be updated.

Bz getPlayerTeam: Difference between revisions

From BZFlagWiki
Jump to navigation Jump to search
Yassen (talk | contribs)
m returnType -> returntype
Sigonasr2 (talk | contribs)
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.
| version      = 2.99.x or later
}}
}}
===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;