Advertisement
obernardovieira

Base of SA-MP plugin

Aug 20th, 2013
185
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.15 KB | None | 0 0
  1. //Source file (*.cpp)
  2.  
  3. #include "SDK\amx\amx.h"
  4. #include "SDK\plugincommon.h"
  5.  
  6.  
  7. typedef void (*logprintf_t)(char* format, ...);
  8.  
  9.  
  10. logprintf_t logprintf;
  11. extern void *pAMXFunctions;
  12.  
  13.  
  14. cell AMX_NATIVE_CALL HelloWorld(AMX* amx, cell* params)
  15. {
  16.     logprintf("This was printed from the Test plugin! Yay!");
  17.     return 1;
  18. }
  19.  
  20. PLUGIN_EXPORT unsigned int PLUGIN_CALL Supports()
  21. {
  22.     return SUPPORTS_VERSION | SUPPORTS_AMX_NATIVES;
  23. }
  24.  
  25. PLUGIN_EXPORT bool PLUGIN_CALL Load(void **ppData)
  26. {
  27.     pAMXFunctions = ppData[PLUGIN_DATA_AMX_EXPORTS];
  28.     logprintf = (logprintf_t) ppData[PLUGIN_DATA_LOGPRINTF];
  29.  
  30.     logprintf(" * Test plugin was loaded.");
  31.     return true;
  32. }
  33.  
  34. PLUGIN_EXPORT void PLUGIN_CALL Unload()
  35. {
  36.     logprintf(" * Test plugin was unloaded.");
  37. }
  38.  
  39. AMX_NATIVE_INFO PluginNatives[] =
  40. {
  41.     {"HelloWorld", HelloWorld},
  42.     {0, 0}
  43. };
  44.  
  45. PLUGIN_EXPORT int PLUGIN_CALL AmxLoad( AMX *amx )
  46. {
  47.     return amx_Register(amx, PluginNatives, -1);
  48. }
  49.  
  50.  
  51. PLUGIN_EXPORT int PLUGIN_CALL AmxUnload( AMX *amx )
  52. {
  53.     return AMX_ERR_NONE;
  54. }
  55.  
  56. //Module definition file (*.def)
  57.  
  58. EXPORTS
  59.     Supports
  60.     Load
  61.     Unload
  62.     AmxLoad
  63.     AmxUnload
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement