Skip to content

Instantly share code, notes, and snippets.

@FDiskas
Last active October 28, 2024 13:26
Show Gist options
  • Save FDiskas/70966ef454c39f0fc51b5fa35e847595 to your computer and use it in GitHub Desktop.
Save FDiskas/70966ef454c39f0fc51b5fa35e847595 to your computer and use it in GitHub Desktop.

Take a bus from airport

The bus will spawn at second floor. The drunk driver should come from first floor. He will wait for you to enter the bus. Enter the bus as passenger and driver will take you to the station. Don't try to piss him off.

To enter as a passenger you can try this snippet

on('keyup', async (key) => {
    if (key == 'B'.charCodeAt(0)) {
        const closest = game.getClosestVehicle(Player.local.pos.x, Player.local.pos.y, Player.local.pos.z, 50, 0, 70);
        game.taskEnterVehicle(Player.local.scriptID, closest, 5000, 2, 1.0, 2, 0);
    }
});
import { Player, on, setTimeout, onServer, log, clearTimeout, emit, emitServer } from 'alt-client';
import game from 'natives';
onServer("Bus:From:Airport", async (vehicle) => {
const driverStart = {
x: -1016.289,
y: -2759.372,
z: 14.165,
model: 's_m_y_airworker',
heading: 45.0,
};
const driverDest = {
x: 456.035,
y: -644.921,
z: 28.359,
};
const garage = {
x: 441.69,
y: -585.894,
z: 28.5,
};
let pedDriver = null;
let timerToBusStation = null;
let timerToGarage = null;
loadModelAsync(driverStart.model).then(() => {
pedDriver = game.createPed(1, game.getHashKey(driverStart.model), driverStart.x, driverStart.y, driverStart.z, driverStart.heading, false, false);
on('resourceStop', () => {
game.deletePed(pedDriver);
});
game.giveWeaponToPed(pedDriver, 453432689, 100, false, true);
game.requestAnimSet('move_m@drunk@verydrunk');
if (game.hasAnimSetLoaded('move_m@drunk@verydrunk')) {
game.setPedMovementClipset(pedDriver, 'move_m@drunk@verydrunk', 0.0);
game.setPedConfigFlag(pedDriver, 100, true);
game.setPedIsDrunk(pedDriver, true);
}
game.taskWanderStandard(pedDriver, 10.0, 10);
game.taskEnterVehicle(pedDriver, vehicle.scriptID, 60000, -1, 1.0, 0, 0);
});
on('enteredVehicle', (vehicle, seat) => {
if (seat !== 1) {
if (timerToGarage) {
clearTimeout(timerToGarage);
}
game.taskVehicleDriveToCoordLongrange(pedDriver, vehicle.scriptID, driverDest.x, driverDest.y, driverDest.z, 220.0, 525247, 5.0);
}
});
on('leftVehicle', (vehicle, seat) => {
if (seat !== 1) {
emit("Bus:To:Garage", pedDriver, vehicle);
}
});
on("Bus:To:Garage", (driver, bus) => {
timerToGarage = setTimeout(() => {
log('Take Bus to garage');
game.taskVehicleDriveToCoordLongrange(driver, bus.scriptID, garage.x, garage.y, garage.z, 220.0, 525247, 5.0);
setTimeout(() => {
game.deletePed(pedDriver);
emitServer("Bus:To:Garage", bus);
}, 45000);
}, 15000);
});
});
import { on, Vehicle, emitClient, setTimeout, log, logError, onClient } from 'alt-server';
const spawn = {
x: -1045.25,
y: -2750.778,
z: 21.363,
};
const busPos = { x: -1033.796142578125, y: -2730.409423828125, z: 20.085569381713867 };
on('playerConnect', (player) => {
player.model = `mp_m_freemode_01`;
const vehicle = new Vehicle(3581397346, busPos.x, busPos.y, busPos.z, busPos.x, busPos.y, busPos.z);
vehicle.dirtLevel = 0;
vehicle.engineOn = false;
vehicle.numberPlateText = 'welcome';
vehicle.activeRadioStation = 0;
vehicle.primaryColor = 27;
player.spawn(spawn.x, spawn.y, spawn.z, 0);
setTimeout(() => {
emitClient(player, 'Bus:From:Airport', vehicle);
}, 5000);
on('resourceStop', () => {
try {
vehicle.destroy();
} catch (error) {
log('Cant destroy bus');
logError(error);
}
});
});
onClient('Bus:To:Garage', (player, bus) => {
bus.destroy();
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment