SA-MP Forums Archive
Attaching a trailer on CreateVehicle - 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)
+---- Forum: Help Archive (https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: Attaching a trailer on CreateVehicle (/showthread.php?tid=274648)



Attaching a trailer on CreateVehicle - MP2 - 06.08.2011

I have a /vsave and /vload function, and it saves the position and angle of the vehicle you're in, and the model of your trailer (if any).

On /vload CreateVehicle is used to create the vehicle, and this is the code, including the trailer attaching:

pawn Код:
sscanf(templine, "iffffI(0)", model, x, y, z, angle, trailer);
new vid = CreateVehicle(model, x, y, z, angle, -1, -1, 60);
SetVehicleVirtualWorld(vid, GetPlayerVirtualWorld(playerid));
LinkVehicleToInterior(vid, GetPlayerInterior(playerid));
if(trailer > 399)
{
    new trailerid = CreateVehicle(trailer, x, y, z, angle, -1, -1, -1);
    LinkVehicleToInterior(trailerid, GetPlayerInterior(playerid));
    SetVehicleVirtualWorld(trailerid, GetPlayerVirtualWorld(playerid));
    AttachTrailerToVehicle(trailerid, vid);
}
But there's a delay with the vehicles spawning, and the trailer doesn't get attached -_- what can I do apart from use a timer? Perhaps OnVehicleStreamIn?

P.S For now I'm using a 1.5 second timer, but it looks stupid when you load the vehicle :/

EDIT: I've sort of made a work-around using OnVehicleStream in, but it required a 2000 cell array and has bugs. This BUG needs to be fixed. If I attach a trailer to a vehicle, I expect it to be attached.