Sign in to follow this  
Karmakun

Displaying Vehicle Hash as String

Recommended Posts

Hello Friendly Coders,

I'm currently going crazy, i'm trying to output the vehicle name in chat.
Once i enter a car, it should say "You're in an Vehicle. Hash: ${vehicle.model}, Seat: ${seat} , Name: ${vehicleName}".

My Code:
 

function playerEnterVehicleHandler(vehicle, seat) {
var vehHash = vehicle.model;
var vehName = vehHash.toString();

    mp.gui.chat.push(`You're in an Vehicle. Hash: ${vehicle.model}, Seat: ${seat} , Name: ${vehicleName}.`);
}

Anything but the actual name works.
I also tried:
 

var vehicleHash = vehicle.model;
var vehicleName = vehicleHash.toString();

I could work that out with an Array, but it would consider a lot of work...
Any good tipps or work arounds?

Best regards Karmakun, thanks for anyhelp!

Share this post


Link to post
Share on other sites
function playerEnterVehicleHandler(vehicle, seat) {
  var vehicleName = mp.game.ui.getLabelText(mp.game.vehicle.getDisplayNameFromVehicleModel(vehicle.model));
    mp.gui.chat.push(`You're in an Vehicle. Hash: ${vehicle.model}, Seat: ${seat} , Name: ${vehicleName}.`);
  });
}

Edit:
mp.game.vehicle.getDisplayNameFromVehicleModel whas my answer...
That whas a pain my nervs...

With all respects, it couldn't got be done a little simplified? 

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.