Sign in to follow this  
Mentanding

(JavaScript) Client-side events: playerStartEnterVehicle + playerEnterVehicle = same

Recommended Posts

When I get into a car, both functions are called.

Code:

function playerStartEnterVehicleHandler(player, vehicle, seat) {
    const playerName = player.name;
    const vehicleID = vehicle.id;
 
    mp.gui.chat.push(`${playerName} started to get into the car ID: ${vehicleID}. Seat: ${seat}`);
}
 
mp.events.add("playerStartEnterVehicle", playerStartEnterVehicleHandler);

function playerEnterVehicleHandler(vehicle) {
    var vehicleModel = mp.game.vehicle.getDisplayNameFromVehicleModel(vehicle.model);
    mp.gui.chat.push(`Vehicle-Model: ${vehicleModel}`);

    var vehicleName = mp.game.ui.getLabelText(mp.game.vehicle.getDisplayNameFromVehicleModel(vehicle.model));
    mp.gui.chat.push(`Vehicle-Name ${vehicleName}`);

    mp.gui.chat.push(`Vehicle-ID: ${vehicle.id}`);
}
mp.events.add("playerEnterVehicle", playerEnterVehicleHandler);

InGame:
8yAyn3ntSoG7ez_YTv-J0Q.png

I know that the text of playerStartEnterVehicleHandler can only be seen after the other function in the screenshot, but try it yourself, both functions are called directly if you want to get started.

- google translator greetz 🤙

btw, https://bt.rage.mp/mp/issues says me Error: 522, cant load this page

Edited by Mentanding

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

  • Recently Browsing   0 members

    No registered users viewing this page.