Trailer is not being attached. - 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: Trailer is not being attached. (
/showthread.php?tid=275090)
Trailer is not being attached. -
WooTFTW - 08.08.2011
The trailer is streamed, i wonder why this code doesn't work.
The trailer creating and attaching function.
pawn Code:
public OnPlayerEnterDynamicCP(playerid, checkpointid)
{
if(checkpointid == Trucker_CP_Id[playerid])
{
if(IsPlayerInAnyVehicle(playerid))
{
new vehicleid;
new createdvehicle;
vehicleid = GetPlayerVehicleID(playerid);
if(VehicleInfo[vehicleid][vjob] == JOB_TRUCKER)
{
createdvehicle = CreateTrailer(vehicleid, floatround(Truck_Pickups[Trucker_ID[playerid]][3]), Truck_Pickups[Trucker_ID[playerid]][0], Truck_Pickups[Trucker_ID[playerid]][1], Truck_Pickups[Trucker_ID[playerid]][2]);
printf("%i _ %i", vehicleid, floatround(Truck_Pickups[Trucker_ID[playerid]][3]));
SendClientMessage(playerid, COLOR_YELLOW, "((Tagad Jums ir jādodas piegādāt kravu.))");
AttachTrailerToVehicle(createdvehicle, vehicleid);
}
}
}
return true;
}
The trailer gets created, but its not getting attached..
Re: Trailer is not being attached. -
JaTochNietDan - 08.08.2011
Could you show us your CreateTrailer function please?
Re: Trailer is not being attached. -
AndreT - 08.08.2011
You cannot instantly attach the trailer. The trailer must first stream in for the player, then AttachTrailerToVehicle can be used.
Here's how I (and I assume, most people) bypass the issue:
pawn Code:
// Where you create it
SetTimerEx("attachTrailer", 1000, false, "ii", createdvehicle, vehicleid);
// The timer
forward attachTrailer(trailerid, vehicleid);
public attachTrailer(trailerid, vehicleid)
return AttachTrailerToVehicle(trailerid, vehicleid);
Re: Trailer is not being attached. -
WooTFTW - 08.08.2011
Quote:
Originally Posted by AndreT
You cannot instantly attach the trailer. The trailer must first stream in for the player, then AttachTrailerToVehicle can be used.
Here's how I (and I assume, most people) bypass the issue:
pawn Code:
// Where you create it SetTimerEx("attachTrailer", 1000, false, "ii", createdvehicle, vehicleid);
// The timer forward attachTrailer(trailerid, vehicleid); public attachTrailer(trailerid, vehicleid) return AttachTrailerToVehicle(trailerid, vehicleid);
|
Thanks for the answer.
I won't be using AttachTrailerToVehicle(), i found a workaround.