Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // a struct, which is is being used for the variable b_stream
- struct B_STREAM
- {
- AMX *amx_ptr;
- // some stuff...
- unsigned int hooked_natives;
- // some stuff...
- AMX_NATIVE
- // some stuff...
- GetPlayerPos
- // some stuff...
- ;
- };
- // type definition
- typedef vector<B_STREAM> B_STREAM_VECTOR;
- // variable
- B_STREAM_VECTOR b_stream;
- // Test native to call it from a PAWN script
- cell AMX_NATIVE_CALL AMX_BStreamTest(AMX *amx, cell *params)
- {
- vector_foreach(B_STREAM, b_stream, amx_it)
- {
- if(amx_it->amx_ptr != amx) continue;
- float x, y, z;
- // Le native
- GetPlayerPos(amx_it, params[1], x, y, z);
- // Will return NULL on x, y, and z :-(
- logprintf("Pos: X = %.4f; Y = %.4f; Z = %.4f", x, y, z);
- // This part below works, so do not worry about it :-)
- /*float x = -1974.7776f, y = 124.8516f, z = 26.1731f, r = 0.0f, sdistance = 200.0f;
- logprintf("Connected: %d", IsPlayerConnected(amx_it, params[1]));
- 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)));*/
- return 1;
- }
- return 0;
- }
- // My invoke function...
- cell GetPlayerPos(B_STREAM_VECTOR::iterator amx_it, cell playerid, float &x, float &y, float &z)
- {
- if((amx_it->hooked_natives&0x2) == 0) return 0;
- cell params[5] = {4, playerid, NULL, NULL, NULL}, ret = amx_it->GetPlayerPos(amx_it->amx_ptr, params);
- // returns null...
- x = amx_ctof(params[2]);
- // returns null...
- y = amx_ctof(params[3]);
- // returns null...
- z = amx_ctof(params[4]);
- // Testing its own return value, returns what it should...
- //logprintf("Returns %d; %.4f; %.4f", ret, ret, amx_ctof(ret));
- return ret;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement