SA-MP Forums Archive
AttachObjectToVehicle - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: AttachObjectToVehicle (/showthread.php?tid=636891)



AttachObjectToVehicle - TeKno - 05.07.2017

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);



Re: AttachObjectToVehicle - NaS - 05.07.2017

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).