Advertisement
BigETI

Problem at invoking GetPlayerPos

Apr 10th, 2013
229
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.74 KB | None | 0 0
  1. // a struct, which is is being used for the variable b_stream
  2. struct B_STREAM
  3. {
  4.     AMX *amx_ptr;
  5.     // some stuff...
  6.     unsigned int hooked_natives;
  7.     // some stuff...
  8.     AMX_NATIVE
  9.         // some stuff...
  10.         GetPlayerPos
  11.         // some stuff...
  12.         ;
  13. };
  14.  
  15. // type definition
  16. typedef vector<B_STREAM> B_STREAM_VECTOR;
  17.  
  18. // variable
  19. B_STREAM_VECTOR b_stream;
  20.  
  21. // Test native to call it from a PAWN script
  22. cell AMX_NATIVE_CALL AMX_BStreamTest(AMX *amx, cell *params)
  23. {
  24.     vector_foreach(B_STREAM, b_stream, amx_it)
  25.     {
  26.         if(amx_it->amx_ptr != amx) continue;
  27.         float x, y, z;
  28.  
  29.         // Le native
  30.         GetPlayerPos(amx_it, params[1], x, y, z);
  31.  
  32.         // Will return NULL on x, y, and z :-(
  33.         logprintf("Pos: X = %.4f; Y = %.4f; Z = %.4f", x, y, z);
  34.  
  35.         // This part below works, so do not worry about it :-)
  36.         /*float x = -1974.7776f, y = 124.8516f, z = 26.1731f, r = 0.0f, sdistance = 200.0f;
  37.         logprintf("Connected: %d", IsPlayerConnected(amx_it, params[1]));
  38.         logprintf("Player ID %d: Object ID returns %d ", params[1], CreatePlayerObject(amx_it, params[1], 18876, amx_ftoc(x), amx_ftoc(y), amx_ftoc(z), amx_ftoc(r), amx_ftoc(r), amx_ftoc(r), amx_ftoc(sdistance)));*/
  39.         return 1;
  40.     }
  41.     return 0;
  42. }
  43.  
  44. // My invoke function...
  45. cell GetPlayerPos(B_STREAM_VECTOR::iterator amx_it, cell playerid, float &x, float &y, float &z)
  46. {
  47.     if((amx_it->hooked_natives&0x2) == 0) return 0;
  48.     cell params[5] = {4, playerid, NULL, NULL, NULL}, ret = amx_it->GetPlayerPos(amx_it->amx_ptr, params);
  49.  
  50.     // returns null...
  51.     x = amx_ctof(params[2]);
  52.  
  53.     // returns null...
  54.     y = amx_ctof(params[3]);
  55.  
  56.     // returns null...
  57.     z = amx_ctof(params[4]);
  58.  
  59.     // Testing its own return value, returns what it should...
  60.     //logprintf("Returns %d; %.4f; %.4f", ret, ret, amx_ctof(ret));
  61.     return ret;
  62. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement