Перейти к содержанию

Vehicle::getDisplayNameFromVehicleModel

Материал из RAGE MP Wiki Archive
Версия от 12:33, 5 сентября 2020; imported>SugarD-x (Removed dead links to Pastebin lists.)
(разн.) ← Предыдущая версия | Текущая версия (разн.) | Следующая версия → (разн.)

Returns model name of vehicle in all caps. Needs to be displayed through localizing text natives to get proper display name.
-----------------------------------------------------------------------------------------------------------------------------------------
While often the case, this does not simply return the model name of the vehicle (which could be hashed to return the model hash). Variations of the same vehicle may also use the same display name.
-----------------------------------------------------------------------------------------------------------------------------------------

Returns 'CARNOTFOUND' if the hash doesn't match a vehicle hash.

Using UI::_GET_LABEL_TEXT, you can get the localized name.

Syntax

<syntaxhighlight lang="javascript">mp.game.vehicle.getDisplayNameFromVehicleModel(modelHash);</syntaxhighlight>

Required Arguments

  • modelHash: Model hash or name

Return value

  • String

Example

<syntaxhighlight lang="javascript"> function playerEnterVehicleHandler(vehicle) {

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

}

mp.events.add("playerEnterVehicle", playerEnterVehicleHandler); </syntaxhighlight>

See also