get the model ID of the trailer and create it at player's vehicle position, and attach it to his vehicle with AttachTrailerToVehicle, but it needs to be called with a timer because the trailer will be not streamed too fast by the player.
createPlayerTrailer(playerid, trailerid)
{
new const vehicleid = GetPlayerVehicleID(playerid);
if(!vehicleid)
return 0;
new Float:x, Float:y, Float:z;
GetVehiclePos(vehicleid, x, y, z);
SetTimerEx("attachVehicleTrailer", 700, false, "dd", vehicleid, CreateVehicle(trailerid, x, y, z, 0.0, -1, -1, -1));
return 1;
}
forward attachVehicleTrailer(vehicleid, trailerid);
public attachVehicleTrailer(vehicleid, trailerid)
{
return AttachTrailerToVehicle(vehicleid, trailerid);
}