AttachObjectToVehicle

From SA-MP Wiki

Jump to: navigation, search


Vehicle coordinate system
Enlarge
Vehicle coordinate system
AttachObjectToVehicle was added in SA-MP 0.3c This function was added in SA-MP 0.3c and will not work in earlier versions!


Description:

Attach an object to a vehicle.


Parameters:
(objectid, vehicleid, Float:OffsetX, Float:OffsetY, Float:OffsetZ, Float:RotX, Float:RotY, Float:RotZ)
objectidThe ID of the object to attach to the vehicle. Note that this is an object ID, not a model ID. The object must be CreateObject created first.
vehicleidThe ID of the vehicle to attach the object to.
Float:OffsetXThe X axis offset from the vehicle to attach the object to.
Float:OffsetYThe Y axis offset from the vehicle to attach the object to.
Float:OffsetZThe Z axis offset from the vehicle to attach the object to.
Float:RotXThe X rotation offset for the object.
Float:RotYThe Y rotation offset for the object.
Float:RotZThe Z rotation offset for the object.


Return Values:

This function does not return any specific values.


Image:32px-Ambox_warning_orange.png

Note

The object must be created first.


Image:32px-Circle-style-warning.png

Important
Note

When the vehicle is destroyed or respawned, the attached objects won't be destroyed with it; they will remain stationary at the position the vehicle disappeared and be reattached to the next vehicle to claim the vehicle ID that the objects were attached to.


Example Usage:

new objectid = CreateObject(...);
new vehicleid = GetPlayerVehicleID(playerid);
AttachObjectToVehicle(objectid, vehicleid, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0);

Related Functions

The following functions may be useful, as they are related to this function in one way or another.



Personal tools
In other languages