export default function vehicleEntering(globalData: GlobalData) {
    mp.events.add('render', () => {
        const controls = mp.game.controls;
        if(globalData.InChat) return;

        controls.enableControlAction(0, 23, true);
        controls.disableControlAction(0, 58, true);

        if (controls.isDisabledControlJustPressed(0, 58)) {
            let position = mp.players.local.position;
            let vehHandle = mp.game.vehicle.getClosestVehicle(position.x, position.y, position.z, 5, 0, 70);

            let vehicle = mp.vehicles.atHandle(vehHandle);

            if (vehicle
                && vehicle.isAnySeatEmpty()
                && vehicle.getSpeed() < 5) {
                mp.players.local.taskEnterVehicle(vehicle.handle, 5000, 0, 2, 1, 0);
            }
        }
    });
}