altv-issues
altv-issues copied to clipboard
attachTo not always attaching vehicle to object
Description of the problem
attachTo not always attaching vehicle to object
how it attaches the first time:
how it attaches after the first time:
Reproduction steps
// edit: tried to add some settimeouts between object create / attachTo, the issue still persists.
import * as alt from 'alt-server';
alt.on('playerConnect', handlePlayerConnect);
function handlePlayerConnect(player: alt.Player) {
player.spawn(-19.8066, 25.1868, 72.7693);
player.rot = new alt.Vector3(0, 0, 1.1874);
player.model = 'mp_m_freemode_01';
setTimeout(async () => {
if (player.id != 1) return;
const vehicle = new alt.Vehicle('flatbed', player.pos, player.rot);
player.setIntoVehicle(vehicle, 1);
let sultan = new alt.Vehicle('sultan', new alt.Vector3(-7.2527, 19.5165, 70.6967), player.rot);
let vehicleRamp = new alt.Object('imp_prop_flatbed_ramp', vehicle.pos, vehicle.rot, 255);
vehicleRamp.attachTo(
vehicle,
39433,
0,
new alt.Vector3(0, -8.6, -1.24),
new alt.Vector3(0, 0, 180).toRadians(),
false,
false
);
await alt.Utils.waitFor(() => sultan.valid && vehicleRamp.valid);
setTimeout(async () => {
sultan.detach();
for (let i = 0; i < 10; i++) {
await alt.Utils.wait(1000)
alt.log(i);
sultan.detach();
vehicleRamp.detach();
vehicleRamp.destroy();
vehicleRamp = new alt.Object('imp_prop_flatbed_ramp', vehicle.pos, vehicle.rot, 255);
vehicleRamp.attachTo(
vehicle,
39433,
0,
new alt.Vector3(0, -8.6, -1.24),
new alt.Vector3(0, 0, 180).toRadians(),
false,
false
);
sultan.attachTo(vehicleRamp, 0, 0, new alt.Vector3(0, 0, 1.3), new alt.Vector3(-0.26, 0, 0), false, false);
}
}, 1500);
}, 1000);
}
Expected behaviour
should always be attached correctly, not only for the first time.
Additional context
No response
Operating system
Windows 11
Version
16.2.5-dev.1 (dev)
Crashdump ID
No response
Confirmation of issue's presence
- [X] By submitting this ticket, I affirm that I have verified the presence of this issue on the latest developer version available at the time of writing this ticket.