View Full Version : AttachObjectToVehicle

05/07/2017, 12:31 PM
So recently i attached some objects to my car using tstudio
Thinking That i could add them on my car

But the objects wont add
Here is the code.
new tmpobjid;

tmpobjid = CreateDynamicObject(19601,0.0,0.0,-1000.0,0.0,0.0,0.0,-1,-1,-1,300.0,300.0);
AttachDynamicObjectToVehicle(tmpobjid, 411,2047.132,1337.139,10.671,199.567,-1,-1,-1, 0.030, -2.640, -0.130, 0.000, 0.000, 0.000);
tmpobjid = CreateDynamicObject(19601,0.0,0.0,-1000.0,0.0,0.0,0.0,-1,-1,-1,300.0,300.0);
AttachDynamicObjectToVehicle(tmpobjid,411,2047.132 ,1337.139,10.671,199.567,-1,-1,-1, -0.006, 2.963, -0.400, 0.000, 0.000, 179.400);

05/07/2017, 11:23 PM
You are attaching it to Vehicle ID 411 (which is the model id for Infernus).

However that function needs a Vehicle ID to attach to (not the model id of that vehicle). So you must replace 411 with a variable holding the Vehicle ID of the Vehicle you previously created.

new tmpvehicleid = CreateVehicle(411, ...);

Furthermore the offsets you put look like coordinates, so even if they attach they will never be visible (they'd be several kilometers away from the vehicle - and are probably not even streamed in).