Portal SAMP
[Ajuda] AttachVehicleToVehicle - Versão de Impressão

+- Portal SAMP (https://portalsamp.com)
+-- Fórum: SA-MP (https://portalsamp.com/forumdisplay.php?fid=5)
+--- Fórum: Área de suporte (https://portalsamp.com/forumdisplay.php?fid=6)
+--- Tópico: [Ajuda] AttachVehicleToVehicle (/showthread.php?tid=3284)



AttachVehicleToVehicle - pereira. - 04/02/2023

a onde eu posso acha biblioteca AttachVehicleToVehicle alguem saber pois eu não tenho


RE: AttachVehicleToVehicle - White_Blue - 04/02/2023

A função AttachVehicleToVehicle não existe. Existe a função AttachTrailerToVehicle, esta que é uma nativa.

https://www.open.mp/docs/scripting/functions/AttachTrailerToVehicle


RE: AttachVehicleToVehicle - pereira. - 04/02/2023

pois estou tentando colocar um tank em um vagão de um trem


RE: AttachVehicleToVehicle - xbruno1000x - 04/02/2023

Tá na mão:

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 );
}