Guest User

Invoke Problem

a guest
May 9th, 2012
192
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.42 KB | None | 0 0
  1. #include "SDK\amx\amx.h"
  2. #include "SDK\plugincommon.h"
  3. #include "SDK\Invoke.h"
  4.  
  5. typedef void (*logprintf_t)(char* format, ...);
  6.  
  7. logprintf_t logprintf;
  8. extern void *pAMXFunctions;
  9.  
  10. using namespace std;
  11.  
  12. int P_GiveWeapon ( int playerid, int gunid, int ammo );
  13.  
  14. cell AMX_NATIVE_CALL P_GiveWeapon(AMX* amx, cell* params)
  15. {
  16.     g_Invoke->callNative(&PAWN::GivePlayerWeapon, params[1], params[2], params[3]);
  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.     g_Invoke = new Invoke;
  28.    
  29.     pAMXFunctions = ppData[PLUGIN_DATA_AMX_EXPORTS];
  30.     logprintf = (logprintf_t) ppData[PLUGIN_DATA_LOGPRINTF];
  31.  
  32.     logprintf(" * Test plugin was loaded.");
  33.     return true;
  34. }
  35.  
  36. PLUGIN_EXPORT void PLUGIN_CALL Unload()
  37. {
  38.     logprintf(" * Test plugin was unloaded.");
  39. }
  40.  
  41. AMX_NATIVE_INFO PluginNatives[] =
  42. {
  43.     {"P_GiveWeapon", P_GiveWeapon},
  44.     {0, 0}
  45. };
  46.  
  47. PLUGIN_EXPORT int PLUGIN_CALL AmxLoad( AMX *amx )
  48. {
  49.     g_Invoke->amx_list.push_back(amx);
  50.     return amx_Register(amx, PluginNatives, -1);
  51. }
  52.  
  53. PLUGIN_EXPORT int PLUGIN_CALL AmxUnload( AMX *amx )
  54. {
  55.     for(list<AMX *>::iterator i = g_Invoke->amx_list.begin(); i != g_Invoke->amx_list.end(); ++i)
  56.     {
  57.         if(*i == amx)
  58.         {
  59.             g_Invoke->amx_list.erase(i);
  60.             break;
  61.         }
  62.     }
  63.     return AMX_ERR_NONE;
  64. }
Advertisement
Add Comment
Please, Sign In to add comment