Events
A plugin is basically useless if it can't react to events in game. To allow this
a plugin needs to tell bzfs that it would like to listen for events. To do that
the plugin will need to call the following function:
bool bz_registerEvent ( bz_teEventType eventType, bz_EventHandler* eventHandler
);
where
eventType
is one of the following enumerations;
bz_eCaptureEvent
|
A team flag is captured in a CTF game |
bz_ePlayerDieEvent
|
A player gets killed
|
bz_ePlayerSpawnEvent
|
A player joins as a tank |
bz_eZoneEntryEvent
|
A player enters a zone ( not implemented )
|
bz_eZoneExitEvent
|
A player exits a zone ( not implemented ) |
bz_ePlayerJoinEvent
|
A user joins the server ( player or observer ) |
bz_ePlayerPartEvent
|
A user leaves the server ( player or observer ) |
bz_eChatMessageEvent
|
A chat message is sent
|
bz_eUnknownSlashCommand
|
A "/" command was issued but not handled |
bz_eGetPlayerSpawnPosEvent
|
The server needs a spawn position for a player |
bz_eGetAutoTeamEvent
|
The server is assigning a player to a team automatically |
bz_eAllowPlayer |
The server is about to allow or disallow a player |
bz_eTickEvent |
The server has executed one of it's normal event loops
|
bz_eGenerateWorldEvent
|
The server is generating or loading a world |
bz_eGetPlayerInfoEvent
|
The server needs the info bits about a player |
bz_eAllowSpawn |
The server is about to allow a player to spawn |
bz_eListServerUpdateEvent
|
The game server is about to send a list server update |
bz_eBanEvent
|
A user was banned |
bz_eHostBanEvent
|
A user was hostbanned /td>
|
bz_eKickEvent
|
A user was kicked from the server |
bz_eKillEvent
|
The /kill command was called |
bz_ePlayerPausedEvent
|
A player has requested a pause |
bz_eMessagFilteredEvent
|
A chat message was filtered and changed by the chat filter |
bz_eGameStartEvent
|
A game timer was started |
bz_eGameEndEvent
|
A game timer ends |
bz_eSlashCommandEvent
|
A server command was issued |
bz_ePlayerAuthEvent
|
Player authentication status change |
bz_eServerMsgEvent
|
A server message was sent |
eventHandler
is a pointer to a event handler class. Plugins should derive their own versions
of the event handler class from bz_EventHandler and pass this pointer into the
function. When the event happens the process function of the class will be
called so that the plugin can perform any actions it desires.
When the plugin's unload function is called, the plugin must remove any events
it has loaded by calling:
bool bz_removeEvent (
bz_teEventType eventType, bz_EventHandler* eventHandler );
Failure to do so may cause crashes if the plugin is manually unloaded at run
time.
The event handler is a pure virtual class. It does not perform any logic or
actions, but simply provides a framework for a plugin to use. You need to
derive your own version of an event handler before you can use it, providing
your own code in the "process" method.
virtual void process ( bz_EventData *eventData );
When the process method is called, the eventData will be a pointer to a data
class. There are a number of different data classes all derived from
bz_EventData. The eventType member of the base class will tell you what type
the data is. This allows for the same handler to be used for more then one type
of event.
The event data for the various event types are as follows, along with their
associated data items. Some events may share event data types.
bz_eCaptureEvent
provides the following data
|
bz_CTFCaptureEventData
{
bz_eTeamType teamCapped; // the team that had there flag
captured
bz_eTeamType teamCapping; // the team that did the capturing
int playerCapping; // the player ID who did the capture
float pos[3]; // the last known position of the player
float rot; // the last known angle of the player
double time; // the time in seconds of the capture
}
|
Handle this event when you want to do something when ever someone captures a
team flag. It is useful for events like clearing bases, tracking scores, or
playing sounds.
|
|
bz_ePlayerDieEvent
provides the following data |
bz_PlayerDieEventData
{
int playerID; // the ID of the player who died
bz_eTeamType team; // the team of the player who died
int killerID; // the ID of the player doing the killing
bz_eTeamType killerTeam; // the team that the killer was on
bzApiString flagKilledWith; // the flag the killer had when killing
float pos[3]; // the last known position of the victim
float rot; // the last known rotation of the victim
double time; // the time of the death
}
|
This event is called whenever a player is killed. |
|
bz_ePlayerSpawnEvent
provides the following data |
bz_PlayerSpawnEventData
{
int playerID // the ID of the player that has spawned;
bz_eTeamType team; // the team the spawning player is a member of
float pos[3]; // the position of the spawn
float rot; // the rotation of the spawn
double time; // the time of the spawn
}
|
Track this event when you wish to know if someone has spawned, and where they
have spawned at. This event does not let you set the spawn position, it is only
called AFTER the spawn has been computed and sent to the players. |
|
bz_ePlayerJoinEvent
AND
bz_ePlayerPartEvent
both provide the following data |
bz_PlayerJoinPartEventData
{
int playerID; // the ID of the user that has joined or
parted
bzApiString globalUser; // if globally identified, global user id
bool verified; // whether the player if verified
bz_eTeamType team; // the team ID of the user
bzApiString callsign; // the callsign used by the user
bzApiString email; // the email used by the user
bzApiString reason; // if a part event, the reason for the part
bzApiString ipAdress; // the IP adress of the player
double time; // the time of the event
}
|
These events are called when ever a user joins or leaves the server. These
events are called for both players and observers.
|
|
bz_eChatMessageEvent
provides the following data |
bz_ChatEventData
{
int from; // the player ID of who the message is from
int to; // the player ID of who the message is for
bz_eTeamType team; // The team the message is to, if a team message
bzApiString message; // the message itself
double time; // the time of the message
}
|
This event is called whenever the server is asked to deliver a chat message.
This includes private messages, team messages, and general chat. ANYTHING that
is not a / command goes in here. The plugin CAN change the chat message before
it is sent. This can allow for a plugin to filter chat text or insert
additional text. If the plugin clears the message text, then the chat message
will not be sent. The text sent to this plugin may have been filtered by
another plugin first. If the chat is to all players to will be set to the
define BZ_ALLUSERS and the team field will be set to eNoTeam, If the chat is to
the admin channel or a team then the to field will be set to BZ_NULLUSER and
the team will be set to the appropriate team ( admin channel is a fake team ) |
|
bz_eUnknownSlashCommand
provides the following data |
bz_UnknownSlashCommandEventData
{
int from; // the ID of the player who sent the command
bool handled; // flag that tells if the command was handled.
// if the plugin handles this command it must
// set this value to true before it returns
bzApiString message; // the command itself
double time; // the time the command was issued
}
|
This event is called when a user attempts to use a / command that does not
exist. It is not very useful for anything other then error reporting. If you
wish to install your own custom / command then it's recommended that you use
the customSlashCommand functions. |
|
bz_eGetPlayerSpawnPosEvent
provides the following data |
bz_GetPlayerSpawnPosEventData
{
int playerID; // the player ID of who needs to be spawned
bool handled; // if the action has been/will be handled
float pos[3]; // the proposed spawn position
float rot; // the proposed spawn rotation
double time; // the time of the request
}
|
This event is called when ever a player spawn position is needed. The standard
spawn position will be set in the pos and rot fields. The plugin may modify or
set new spawn data if it wishes to. This can allow a plugin to do its own spawn
calculations. The position may have been modified by another plugin first if
multiple plugins are handling the event. If so the "handled" field should be
true. If your plugin modifies the spawn data it too should set the "handled"
bit to true.
|
|
bz_eAllowPlayer
provides the following data |
bz_AllowPlayerEventData
{
int playerID; // the player ID of the joining player
bzApiString callsign; // the callsign of the player
bzApiString ipAddress; // the IP address the player is connecting from
bzApiString reason; // a reason string with the reason the player is to be
disallowed to join
bool allow; // flag to allow or disallow the player.
double time; // the time of the request
}
|
This event is called every time a user joins a server. The server will do its
normal ban/disallow logic then pass the value to the plugin in the allow field.
The plugin can then choose to allow or disallow the player as it sees fit. If the
player is to be disallowed, then please provide a reason.
|
|
bz_eTickEvent
provides the following data |
bz_TickEventData
{
double time; // time of the event.
}
|
This event is not called due to any user or player interaction. This event is
called automatically by bzfs every time it has completed one of its normal
execution loops. This event is useful when plugins need to perform update
actions, periodic maintenance, or other actions that are not directly tied to a
user event, like checking to see if it is time to start a match. A plugin can
set the maximum allowable time between calls to this event using the function
bz_setMaxWaitTime described below.
|
|
bz_eGenerateWorldEvent
provides the following data |
bz_GenerateWorldEventData
{
bool handled; // flag to set to true if the plugin has
generated the world
bool ctf; // true if the world is a CTF world
double time; // the time of the request
}
|
This event is called by bzfs when it begins to build or load the world. The
event is called BEFORE any map file is loaded. If the plugin wishes to define
the world, it must call any world creation functions during this event, and
then set the handled flag to true. If the plugin generates the world, then bzfs
will NOT load the map file, and will NOT generate a random world. Calls to any
world creation functions outside this event will fail. |
|
bz_eListServerUpdateEvent
provides the following data |
bz_ListServerUpdateEvent
{
bzApiString address; // the address to be used for the server
bzApiString description; // the description to be used for the server
bzApiString groups; // the groups to be used for the "advertise"
bool handled; // set to true if a plugin has already handled it, set this to true if THIS plugin has handled it
double time; // the time of the request
}
|
This event is called by bzfs when it is about to do a list server update. The plugin can change any of the strings and the modified version will be used before the send. This is most useful for making your server "unlist" when you wish to go into private or match mode. Or for updating the description based on changing data. |
|
bz_eBanEvent
provides the following data |
bz_BanEventData
{
int bannerID; // the ID of the player doing the ban
int banneeID; // the ID of the player who is about to be banned
int duration; // the duration of the ban ( in seconds )
bzApiString ipAddress; // the banned users IP address or range
bzApiString reason; // the reason given for the ban
}
|
This event is called by bzfs when an admin bans a user. |
|
bz_eHostBanEvent
provides the following data |
bz_HostBanEventData
{
int bannerID; // the person doing the ban
int duration; // the duration of the ban
bzApiString hostPattern; // the mask that was banned
bzApiString reason; // the reason given for the ban
}
|
This event is called by bzfs when an admin hostbans a user. |
|
bz_eKickEvent
provides the following data |
bz_KickEventData
{
int kickerID; // the person doing the kick
int kickedID; // the person being kicked
bzApiString reason; // the reason given for the kick
}
|
This event is called by bzfs when an admin kicks a user from the server. |
|
bz_eKillEvent
provides the following data |
bz_KillEventData
{
int killerID; // the person doing the kill command
int killedID; // the person being killed
bzApiString reason; // the reason given for the kill
}
|
This event is called by bzfs when an admin uses the /kill command. |
|
bz_ePlayerPausedEvent
provides the following data |
bz_PlayerPausedEventData
{
int player; // the player pausing
double time; // the time of the event
}
|
This event is called when a user uses the pause function on the client and notifies the server |
|
bz_eMessagFilteredEvent
provides the following data |
bz_MessageFilteredEventData
{
int player; // the player who sent the message
double time; // the time the message was sent
bzApiString rawMessage; // the unfiltered message
bzApiString filteredMessage; // the filtered message
}
|
This event is called when a user sends a chat message that gets changed in the chat filter. |
|
bz_eGameStartEvent AND bz_eGameEndEvent
provide the following data |
bz_GameStartEndEventData
{
double time; // the time that the game was started/ended
double duration; // the duration of the game timer
}
|
These events are called when a game timer starts or ends. |
|
bz_eSlashCommandEvent
provides the following data |
bz_SlashCommandEventData
{
int from; // the ID of the player who sent the command
bzApiString message; // the command itself
double time; // the time the command was issued
}
|
This event is called for any user entered server command. The command text is unprocessed and not checked as a valid command when this event occurs. |
|
bz_ePlayerAuthEvent
provides the following data |
bz_PlayerAuthEventData
{
int playerID; // the ID of the player whose authentication status changed
}
|
This event is called when a player manually identifies to the server or issues the server password. |
|
bz_eServerMsgEvent
provides the following data |
bz_ServerMsgEventData
{
int to; // the player ID the message is sent to
bz_eTeamType team; // The team the message is to, if a team message
bzApiString message; // the text of the message
double time; // the time of the message
}
|
This event is called whenever the server issues a message.
The message can be to a specific player, team, or a general broadcast.
If the server message is to all players to will be set to the
define BZ_ALLUSERS and the team field will be set to eNoTeam, If the server message is to
the admin channel or a team then the to field will be set to BZ_NULLUSER and
the team will be set to the appropriate team ( admin channel is a fake team )
The plugin cannot change the contents of the message.
This event is mainly useful for logging. |
|
|