прошу помощи с данным куском кода у опытных людей, может подскажите куда копать.
4-5 часов перебирал код по разному, и пришёл к такому виду детища.
надеюсь, опытные люди укажут на ошибки и в какую сторону копать чтобы привести данного чудотворца в рабочее состояние.
критику приму.
Из того что делал с кодом:
делал регистрацию нативов, форвардов, использовал enum.
- Код: Выделить всё
#include <amxmodx>
#include <amxmisc>
#define PLUGIN "Core Plugin"
#define VERSION "Alpha"
#define AUTHOR "drip"
new g_CoreIsLoaded = 0;
new g_DependencyCount = 0;
enum PluginDependency {
PLUGIN_NAME[32],
FUNCTION_NAME[32]
};
// Define a macro for the number of dependencies
#define NUM_PLUGIN_DEPENDENCIES 1 // Update this if you add more dependencies
// Declare the dependency array as a global constant, explicitly sized
new const g_PluginDependencies[NUM_PLUGIN_DEPENDENCIES][PluginDependency] = {
{ "example_plugin", "example_func" }
// { "another_plugin", "another_func" }
};
#define NUM_DEPENDENCIES NUM_PLUGIN_DEPENDENCIES // Use the macro to define NUM_DEPENDENCIES
// Forward declarations for public functions
forward bool:core_is_loaded();
forward core_add_dependency();
forward core_remove_dependency();
forward bool:core_check_function(const plugin_name[], const function_name[]);
public plugin_init() {
register_plugin(PLUGIN, VERSION, AUTHOR);
// Register native function library
register_library("core", 1);
// Register the forward functions as natives, use string names
register_native("core_is_loaded", "core_is_loaded", 0);
register_native("core_add_dependency", "core_add_dependency", 0);
register_native("core_remove_dependency", "core_remove_dependency", 0);
register_native("core_check_function", "core_check_function", 2);
g_CoreIsLoaded = 1
set_task(0.1, "CheckDependencies", 0, "", 0, "b");
log_amx("Core plugin loaded (initial). Waiting for dependencies and functions.");
}
// Implementation of native functions
public core_is_loaded() {
return bool:g_CoreIsLoaded;
}
public core_add_dependency() {
g_DependencyCount++;
return 1;
}
public core_remove_dependency() {
if (g_DependencyCount > 0) {
g_DependencyCount--;
}
return 1;
}
public bool:core_check_function(const plugin_name[], const function_name[]) {
new funcid = get_func_id(function_name, plugin_name);
if (funcid == -1) {
log_amx("[CORE ERROR] Function '%s' not found in plugin '%s'", function_name, plugin_name);
return false;
}
return true;
}
public CheckDependencies() {
if (g_DependencyCount == 0) {
log_amx("Core plugin: No dependencies found, disabling.");
g_CoreIsLoaded = 0;
set_fail_state();
} else {
for (new i = 0; i < NUM_DEPENDENCIES; i++) {
if (!core_check_function(g_PluginDependencies[i][PLUGIN_NAME], g_PluginDependencies[i][FUNCTION_NAME])) {
log_amx("Core plugin: Required function missing, disabling.");
g_CoreIsLoaded = 0;
set_fail_state();
return;
}
}
log_amx("Core plugin: Found dependencies and all required functions, working.");
}
}
ошибки компиляции:
- Код: Выделить всё
plugin.sma(29) : error 025: function heading differs from prototype plugin.sma(38) : error 088: number of arguments does not match definition plugin.sma(54) : error 025: function heading differs from prototype plugin.sma(71) : error 035: argument type mismatch (argument 2) plugin.sma(83) : error 088: number of arguments does not match definition plugin.sma(89) : error 088: number of arguments does not match definition
