SA-MP Forums Archive
Attaching an object on train. - 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: Attaching an object on train. (/showthread.php?tid=591022)



Attaching an object on train. - GuitarMan - 06.10.2015

Hey.
I wanted to know is it possible to spawn an object on trains trailers.
My idea was to Get the vehicle ID, then get the trailer id and in the end attach the object to the trailer. But it does not seem to work.

Код:
CMD:SpawnContainers(playerid,params[])
{
    new vehicleid = GetPlayerVehicleID(playerid);
	new trailerid = GetVehicleTrailer(vehicleid);
	new objectid1 = CreateObject(3572, 0.00000, 4.40000, 0.30000,   0.00000, 0.00000, 90.00000);
	new objectid2 = CreateObject(3572, 0.00000, -4.00000, 0.30000,   0.00000, 0.00000, 90.00000);

	AttachObjectToVehicle(objectid1, trailerid, 0.00000, 4.40000, 0.30000,   0.00000, 0.00000, 90.00000);
	AttachObjectToVehicle(objectid2, trailerid, 0.00000, -4.00000, 0.30000,   0.00000, 0.00000, 90.00000);

}
Is it even possible?


Re: Attaching an object on train. - Dusan01 - 07.10.2015

hmm, train is just a vehicle, there is no trailers, so u should use code like this:

Код:
CMD:SpawnContainers(playerid,params[])
{
        new vehicleid = GetPlayerVehicleID(playerid);
	new objectid1 = CreateObject(3572, 0.00000, 4.40000, 0.30000,   0.00000, 0.00000, 90.00000);
	new objectid2 = CreateObject(3572, 0.00000, -4.00000, 0.30000,   0.00000, 0.00000, 90.00000);

	AttachObjectToVehicle(objectid1, vehicleid, 0.00000, 4.40000, 0.30000,   0.00000, 0.00000, 90.00000);
	AttachObjectToVehicle(objectid2, vehicleid, 0.00000, -4.00000, 0.30000,   0.00000, 0.00000, 90.00000);

}
and you will need to adjust cordinates for each trailer behind the train, cuz train is just a vehicle, dont have a trailers and with default cordinates that container should spawn at the middle of the train...