Closed alimsahy closed 4 years ago
Hi,
When i try to call plugin function in 'OnPlayerConnect' or any callback, i always getting this error. Why? Where am I doing wrong?
#include <sampgdk/core.h> #include <sampgdk/sdk.h> #include "Players.h" extern void* pAMXFunctions; PLUGIN_EXPORT bool PLUGIN_CALL OnGameModeInit() { return true; } AMX_NATIVE_INFO PluginNatives[] = { {"SetPlayerFaction", Players::SetPlayerFaction}, {"GetPlayerFaction", Players::GetPlayerFaction}, {0, 0} }; PLUGIN_EXPORT unsigned int PLUGIN_CALL Supports() { return sampgdk::Supports() | SUPPORTS_PROCESS_TICK | SUPPORTS_AMX_NATIVES; } PLUGIN_EXPORT bool PLUGIN_CALL Load(void** ppData) { pAMXFunctions = ppData[PLUGIN_DATA_AMX_EXPORTS]; sampgdk_logprintf("Shit is working...."); return true; } PLUGIN_EXPORT void PLUGIN_CALL Unload() { sampgdk::Unload(); } PLUGIN_EXPORT int PLUGIN_CALL AmxLoad(AMX* amx) { return amx_Register(amx, PluginNatives, -1); } PLUGIN_EXPORT int PLUGIN_CALL AmxUnload(AMX* amx) { return AMX_ERR_NONE; }
Pawn file:
public OnGameModeInit() { printf ("Loaded"); return 1; } public OnPlayerConnect(playerid) { SetPlayerFaction(playerid, 10); // Native function not found: SetPVarInt return 1; }
FIXED: It seems we should use it after OnGameModeInit.
Ex:
public OnGameModeInit() { return1; } public OnPlayerConnect(playerid) { SetPlayerFaction(playerid, 10); // Worked return 1; }
Hi,
When i try to call plugin function in 'OnPlayerConnect' or any callback, i always getting this error. Why? Where am I doing wrong?
Pawn file: