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 getPublicAddr: Difference between revisions
		
		
		
		Jump to navigation
		Jump to search
		
 Create API Function Page. Include Example.  | 
				m Meh, forgot to update the description.  | 
				||
| Line 3: | Line 3: | ||
| returns       = A string containing the public address of the server.  | | returns       = A string containing the public address of the server.  | ||
| returntype    = [[bz_ApiString]]  | | returntype    = [[bz_ApiString]]  | ||
| description   =   | | description   = Returns the string that was specified with the BZFS option '''-publicaddr''' or the default address that is used when starting up a public server.  | ||
}}  | }}  | ||
Latest revision as of 10:43, 19 October 2011
bz_ApiString bz_getPublicAddr ()
Returns the string that was specified with the BZFS option -publicaddr or the default address that is used when starting up a public server.
Returns: 
A string containing the public address of the server.
Example
A simple greeting that tells the player what server and port they are on. This may be useful to remove the hassle of modifying greetings for a server that hosts many ports.
case bz_ePlayerJoinEvent: {
	if (bz_getPublic()) {
		bz_sendTextMessagef(BZ_SERVER,((bz_PlayerJoinPartEventData_V1*)eventData)->playerID,"Welcome!");
		bz_sendTextMessagef(BZ_SERVER,((bz_PlayerJoinPartEventData_V1*)eventData)->playerID,
			"You are playing on %s",bz_getPublicDescription().c_str());
		bz_sendTextMessagef(BZ_SERVER,((bz_PlayerJoinPartEventData_V1*)eventData)->playerID,
			"           @ %s:%d",bz_getPublicAddr().c_str(),bz_getPublicPort());
	}
}break;