Portal SAMP
[Ajuda] Colocar veículo em cima do DFT-30 - 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] Colocar veículo em cima do DFT-30 (/showthread.php?tid=1834)



Colocar veículo em cima do DFT-30 - DPB G4MERS - 11/11/2021

Queria saber se teria alguma função para fixar algum carro em cima do DTF-30? aquele caminhão que tem uma prancha igual de guincho.

É que estou fazendo um sistema de Detran e queria uma função que fizesse isso para encaminhar o veículo ao Detran.

Sei que possa ser improvável de existir uma função que fixe um veiculo em cima do outro, mas não custa nada perguntar.


RE: Colocar veículo em cima do DFT-30 - Miqueias Barros - 11/11/2021

Acredito que criando objetos. Agora fixar in-game, nunca ouvi falar não.


RE: Colocar veículo em cima do DFT-30 - xbruno1000x - 11/11/2021

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]


RE: Colocar veículo em cima do DFT-30 - DPB G4MERS - 11/11/2021

(11/11/2021 18:46)xbruno1000x Escreveu: 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]

eu vou tentar usar essa função parece que é oque procuro


RE: Colocar veículo em cima do DFT-30 - Jogador - 12/11/2021

[Imagem: 20211112-134426.png]main.pwn