Vehicle::getDisplayNameFromVehicleModel: Difference between revisions

From RAGE Multiplayer Wiki
(yay)
(Removed dead links to Pastebin lists.)
 
(3 intermediate revisions by 2 users not shown)
Line 1: Line 1:
Returns model name of vehicle in all caps. Needs to be displayed through localizing text natives to get proper display name.<br>-----------------------------------------------------------------------------------------------------------------------------------------<br>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.<br>-----------------------------------------------------------------------------------------------------------------------------------------<br><br>Returns 'CARNOTFOUND' if the hash doesn't match a vehicle hash.<br><br>Using UI::_GET_LABEL_TEXT, you can get the localized name.<br><br>For a full list, see here: pastebin.com/wvpyS4kS (pastebin.com/dA3TbkZw)<br><br>
Returns model name of vehicle in all caps. Needs to be displayed through localizing text natives to get proper display name.<br>-----------------------------------------------------------------------------------------------------------------------------------------<br>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.<br>-----------------------------------------------------------------------------------------------------------------------------------------<br><br>Returns 'CARNOTFOUND' if the hash doesn't match a vehicle hash.<br><br>Using UI::_GET_LABEL_TEXT, you can get the localized name.<br><br>
==Syntax==
==Syntax==
<syntaxhighlight lang="javascript">mp.game.vehicle.getDisplayNameFromVehicleModel(modelHash);</syntaxhighlight>
<syntaxhighlight lang="javascript">mp.game.vehicle.getDisplayNameFromVehicleModel(modelHash);</syntaxhighlight>
Line 8: Line 8:
==Example==
==Example==
<syntaxhighlight lang="javascript">
<syntaxhighlight lang="javascript">
// todo
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>
</syntaxhighlight>
==See also==
==See also==
{{Vehicle_s_function_c}}
{{Vehicle_s_function_c}}
[[Category:Clientside API]]
[[Category:Clientside API]]
[[Category:TODO: Example]]

Latest revision as of 12:33, 5 September 2020

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

mp.game.vehicle.getDisplayNameFromVehicleModel(modelHash);

Required Arguments

  • modelHash: Model hash or name

Return value

  • String

Example

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);

See also