PDA

View Full Version : Is possible get attached dynamic object position?


3417512908
23/08/2018, 01:42 AM
Is possible it?For vehicle object.
Anybody have some way to do that?

Sew_Sumi
23/08/2018, 03:18 AM
How do you mean?

If you're wanting to do lights/things added to them, spawn a car in Jernejls map editor (http://forum.sa-mp.com/showthread.php?t=282801), place it at 0,0,0 with 0,0,0 rotation, then any object you place on that vehicle, in that position/rotation is where it attaches to the car.


Because the car is 0,0,0, with 0,0,0, any objects coords/rotations are what is to be attached to the car.



Players/skins are a whole other ball game as they have bones to be attached to.



The other way to really do it, is by using the callback OnPlayerEditDynamicObject (if using streamer) or OnPlayerEditObject (If using natives), but again, that has a lot to it.

NaS
23/08/2018, 11:51 AM
If you want to get an attached object's position/offset, the offset and rotation is stored by the streamer and you can access it by Streamer_GetFloatData:

Streamer_GetFloatData(STREAMER_TYPE_OBJECT, objectid, E_STREAMER_ATTACH_OFFSET_X, x);
Streamer_GetFloatData(STREAMER_TYPE_OBJECT, objectid, E_STREAMER_ATTACH_OFFSET_Y, y);
Streamer_GetFloatData(STREAMER_TYPE_OBJECT, objectid, E_STREAMER_ATTACH_OFFSET_Z, z);

Streamer_GetFloatData(STREAMER_TYPE_OBJECT, objectid, E_STREAMER_ATTACH_RX, rx);
Streamer_GetFloatData(STREAMER_TYPE_OBJECT, objectid, E_STREAMER_ATTACH_RY, ry);
Streamer_GetFloatData(STREAMER_TYPE_OBJECT, objectid, E_STREAMER_ATTACH_RZ, rz);


If you use it frequently I'd suggest to write a function for it instead of pasting these 6 lines everywhere.