11/11/2021 18:46
Existe uma função AttachVehicleToVehicle que faz isso, porém nunca testei.
Código:
//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 );
}
![[Imagem: 347839be01e244708a7926a262255411.png]](http://s7.hostingkartinok.com/uploads/images/2015/01/347839be01e244708a7926a262255411.png)
Discente de Sistemas de Informação no Centro Federal de Ensino Tecnológico(CEFET/RJ)
Programador SA-MP desde 2012
Programador SA-MP desde 2012
Não envie dúvidas por inbox, crie um tópico. Sua dúvida pode ser a dúvida de outro alguém, e seu tópico ajudará outras pessoas no futuro.