Вот функция аттача ТС к ТС.
//by Seregamil
native IsValidVehicle(vehicleid);
new vehicleAttached[ MAX_VEHICLES ] = { INVALID_VEHICLE_ID, ... };
new vehicleTimer[ MAX_VEHICLES ] ;
stock AttachVehicleToVehicle( vehicleid, to_vehicleid, Float: offsetX, Float: offsetY, Float: offsetZ, Float: offsetA, time = 100 ) {
if( !IsValidVehicle( vehicleid ) || !IsValidVehicle( to_vehicleid ) )
return INVALID_VEHICLE_ID ;
if( vehicleAttached[ vehicleid ] != INVALID_VEHICLE_ID )
return INVALID_VEHICLE_ID ;
vehicleAttached[ vehicleid ] = to_vehicleid ;
vehicleTimer[ vehicleid ] = SetTimerEx( "updateVehiclesWithAttach", time, false, "iiffffi", vehicleid, to_vehicleid, offsetX, offsetY, offsetZ, offsetA, time );
return vehicleid ;
}
stock DeAttachVehicle( vehicleid ) {
vehicleAttached[ vehicleid ] = INVALID_VEHICLE_ID ;
KillTimer( vehicleTimer[ vehicleid ] );
}
forward updateVehiclesWithAttach( vehicleid, to_vehicleid, Float: offsetX, Float: offsetY, Float: offsetZ, Float: offsetA, time ) ;
public updateVehiclesWithAttach( vehicleid, to_vehicleid, Float: offsetX, Float: offsetY, Float: offsetZ, Float: offsetA, time ) {
if( !IsValidVehicle( vehicleid ) || !IsValidVehicle( to_vehicleid ) )
return ;
new Float: x, Float: y, Float: z, Float: a ;
GetVehiclePos( to_vehicleid, x, y, z );
GetVehicleZAngle( to_vehicleid, a );
SetVehiclePos( vehicleid, x + offsetX, y + offsetY, z + offsetZ );
SetVehicleZAngle( vehicleid, a );
vehicleTimer[ vehicleid ] = SetTimerEx( "updateVehiclesWithAttach", time, false, "iifffi", vehicleid, to_vehicleid, offsetX, offsetY, offsetZ, offsetA, time );
}
Функции:
AttachVehicleToVehicle( vehicleid, to_vehicleid, Float: offsetX, Float: offsetY, Float: offsetZ, Float: offsetA, time = 100 )
DeAttachVehicle( vehicleid )
Аргумент time отвечает за время, через которое машины снова совокупятся, если машина скоростная, то можно выставить ~15-20ms, если же медленная, то можно и так оставить.