Trailer is not being attached.
#1

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..
Reply
#2

Could you show us your CreateTrailer function please?
Reply
#3

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);
Reply
#4

Quote:
Originally Posted by AndreT
View Post
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.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)