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

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Sign in to follow this  

  • Recently Browsing   0 members

    No registered users viewing this page.