bz_IPBanUser

From BZFlagWiki
Jump to: navigation, search

bool bz_IPBanUser (int bannedByIndex, const char* ip, int duration, const char* reason)


Sets up a new IP Rule in the ban list. Note that if the player is currently playing when their IP address is banned it will not take effect immediately until they rejoin. This can be counteracted by kicking the player upon the ban, or using bz_IDBanUser() instead.

Parameters:
bannedByIndex  -  The player ID that is banning the IP Address. NOTE: This has to be a player that is currently on the server, so at least one player must be present for a ban to be created.
ip  -  The IP Address string to ban. Note that this can contain wildcard (*) characters for higher level bans.
duration  -  The amount of time in minutes to ban the player.
reason  -  The reason that is displayed to the banned user upon failure to join.
Returns:
Whether or not the ban was executed successfully.


Example[edit]

This code will check if the TK ratio is greater than 0.3 (30%) after at least 5 rounds of play. If so, the player will be IP Banned and kicked. This is basically an auto TK ban method.

case bz_ePlayerDieEvent: {
	if ((double)bz_getPlayerTKs(((bz_PlayerDieEventData_V1*)eventData)->killerID)
	/(double)(bz_getPlayerWins(((bz_PlayerDieEventData_V1*)eventData)->killerID)
		+bz_getPlayerLosses(((bz_PlayerDieEventData_V1*)eventData)->killerID))
	>0.3
	&&
	bz_getPlayerWins(((bz_PlayerDieEventData_V1*)eventData)->killerID)
		+bz_getPlayerLosses(((bz_PlayerDieEventData_V1*)eventData)->killerID)
		+bz_getPlayerTKs(((bz_PlayerDieEventData_V1*)eventData)->killerID)>=5) {
			//Ban the teamkiller and kick them
			bz_IPBanUser(((bz_PlayerDieEventData_V1*)eventData)->killerID,
				bz_getPlayerIPAddress(((bz_PlayerDieEventData_V1*)eventData)->killerID),
				60,"Auto Ban for Intentional Teamkilling.");
			bz_kickUser(((bz_PlayerDieEventData_V1*)eventData)->killerID,
				"Auto Ban for Intentional Teamkilling.",true);
		};
}break;

More information on this function can be found on the BZFS_API_2.4_Upgrade page.