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
Sigonasr2 (talk | contribs)
Removed version 2.99.x requirement. Added an example.
Allejo (talk | contribs)
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: {
char myteam[8];
    bz_PlayerJoinPartEventData_V1 *join = (bz_PlayerJoinPartEventData_V1*)eventData;
if (bz_getPlayerTeam(((bz_PlayerJoinPartEventData_V1*)eventData)->playerID)==eBlueTeam)
    std::string teamColor = "Unknown";  
{strcpy(myteam,"Blue");} else
if (bz_getPlayerTeam(((bz_PlayerJoinPartEventData_V1*)eventData)->playerID)==eRogueTeam)
    if (bz_getPlayerTeam(join->playerID) == eRogueTeam)
{strcpy(myteam,"Rogue");} else
        teamColor = "rogue";
if (bz_getPlayerTeam(((bz_PlayerJoinPartEventData_V1*)eventData)->playerID)==eRedTeam)
    else if (bz_getPlayerTeam(join->playerID) == eRedTeam)
{strcpy(myteam,"Red");} else
        teamColor = "red";
if (bz_getPlayerTeam(((bz_PlayerJoinPartEventData_V1*)eventData)->playerID)==eGreenTeam)
    else if (bz_getPlayerTeam(join->playerID) == eGreenTeam)
{strcpy(myteam,"Green");} else
        teamColor = "green";
if (bz_getPlayerTeam(((bz_PlayerJoinPartEventData_V1*)eventData)->playerID)==ePurpleTeam)
    else if (bz_getPlayerTeam(join->playerID) == eBlueTeam)
{strcpy(myteam,"Purple");} else
        teamColor = "blue";
if (bz_getPlayerTeam(((bz_PlayerJoinPartEventData_V1*)eventData)->playerID)==eHunterTeam)
    else if (bz_getPlayerTeam(join->playerID) == ePurpleTeam)
{strcpy(myteam,"Hunter");} else
        teamColor = "purple";
if (bz_getPlayerTeam(((bz_PlayerJoinPartEventData_V1*)eventData)->playerID)==eObservers)
    else if (bz_getPlayerTeam(join->playerID) == eObservers)
{strcpy(myteam,"Observer");} else
        teamColor = "observer";
{strcpy(myteam,"Unknown");}
bz_sendTextMessagef(BZ_SERVER,((bz_PlayerJoinPartEventData_V1*)eventData)->playerID,"Welcome! You joined the %s team!",myteam);
    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

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;