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.
BZFS API Updates: Difference between revisions
Added some information on the new plugin loading for 2.4 |
basic merge and start of page |
||
| (One intermediate revision by the same user not shown) | |||
| Line 1: | Line 1: | ||
The BZFS API was first introduced in BZFlag 2.0.4. Since then, there has been numerous changes, including the massive overhaul from 2.0 to 2.4.x (More information on this can be found on the [[BZFS_API_2.4_Upgrade]] page.) | |||
<!-- This page covers the majority of changes within a major version, but changes in major versions are covered within their own page. --> | |||
=2.0.x= | |||
=2.4.x= | |||
==Init== | |||
===Code Example=== | ===Code Example=== | ||
void SAMPLE_PLUGIN::Init ( const char* /*commandLine*/ ) { | void SAMPLE_PLUGIN::Init ( const char* /*commandLine*/ ) { | ||
| Line 6: | Line 18: | ||
===Functions=== | ===Functions=== | ||
The | The '''Init''' function is required for all plugins 2.4 and higher. This function replaces the [[bz_Load]] function. In this function all debug messages, events, map objects, and slash commands are registered. Available functions for this are as follows: | ||
* [[bz_debugMessage]] | * [[bz_debugMessage]] | ||
* [[Register]] | * [[Register]] | ||
| Line 12: | Line 24: | ||
* [[bz_registerCustomSlashCommand]] | * [[bz_registerCustomSlashCommand]] | ||
==Register== | |||
===Example=== | |||
void SAMPLE_PLUGIN::Init ( const char* /*commandLine*/ ) | |||
{ | |||
Register(bz_ePlayerUpdateEvent); | |||
} | |||
==Cleanup== | |||
===Code Example=== | |||
void SAMPLE_PLUGIN::Cleanup( void ) { | |||
Flush(); //This removes all events that were registered with Registered() | |||
bz_debugMessage(4,"SAMPLE_PLUGIN plugin unloaded"); | |||
return 0; | |||
} | |||
===Functions=== | |||
The [[Cleanup]] function is required for all plugins. This function replaces the [[bz_Unload]] function in plugins written for 2.4 or higher. In this function all debug messages, events, map objects, and slash commands are unregistered. Available functions for this are as follows: | |||
* [[bz_debugMessage]] | |||
* Flush() | |||
* [[bz_removeCustomSlashCommand]] | |||
* [[bz_removeCustomMapObject]] | |||
The Flush() function is called once in 2.4 plugins instead of having to a [[bz_removeEvent]] remove each registered event individually. | |||
Latest revision as of 01:42, 24 November 2025
The BZFS API was first introduced in BZFlag 2.0.4. Since then, there has been numerous changes, including the massive overhaul from 2.0 to 2.4.x (More information on this can be found on the BZFS_API_2.4_Upgrade page.)
2.0.x
2.4.x
Init
Code Example
void SAMPLE_PLUGIN::Init ( const char* /*commandLine*/ ) {
bz_debugMessage(4,"SAMPLE_PLUGIN plugin loaded");
return 0;
}
Functions
The Init function is required for all plugins 2.4 and higher. This function replaces the bz_Load function. In this function all debug messages, events, map objects, and slash commands are registered. Available functions for this are as follows:
Register
Example
void SAMPLE_PLUGIN::Init ( const char* /*commandLine*/ )
{
Register(bz_ePlayerUpdateEvent);
}
Cleanup
Code Example
void SAMPLE_PLUGIN::Cleanup( void ) {
Flush(); //This removes all events that were registered with Registered()
bz_debugMessage(4,"SAMPLE_PLUGIN plugin unloaded");
return 0;
}
Functions
The Cleanup function is required for all plugins. This function replaces the bz_Unload function in plugins written for 2.4 or higher. In this function all debug messages, events, map objects, and slash commands are unregistered. Available functions for this are as follows:
The Flush() function is called once in 2.4 plugins instead of having to a bz_removeEvent remove each registered event individually.