Player::setModel: Difference between revisions

From RAGE Multiplayer Wiki
(yay)
 
No edit summary
 
Line 1: Line 1:
{{ClientsideJsFunction}}
{{JSContainer|
===Required Params===
*'''modelName:''' {{RageType|string}} — The name of the model to be set for the player.
===Return value===
*'''void''' — This function does not return a value.


==Syntax==
==Syntax==
<syntaxhighlight lang="javascript">player.setModel(model);</syntaxhighlight>
=== Required Arguments ===
*'''model:''' Model hash or name
===Return value===
*'''Undefined'''
==Example==
<syntaxhighlight lang="javascript">
<syntaxhighlight lang="javascript">
// todo
// Function to change the player's model
function changePlayerModel(modelName) {
    let player = mp.players.local; // Reference to the local player
    let modelHash = mp.game.joaat(modelName); // Get the model hash from the model name
 
    // Set the player's model
    player.model = modelHash; // Change the player's model
 
    // Notify the player
    mp.gui.chat.push("Your model has been changed to " + modelName + ".");
}
 
// Bind the function to a key (for example, the "E" key)
mp.keys.bind(69, false, function() { // 69 is the key code for "E"
    changePlayerModel('a_m_m_acult_01'); // Call the function to change the model
});
</syntaxhighlight>
</syntaxhighlight>
}}
==Available Models==
See the list of available models:  [https://wiki.rage.mp/index.php?title=Peds Peds]
==See also==
==See also==
{{Player_function_c}}
{{Ped_functions_c}}
[[Category:Clientside API]]
[[Category:Clientside API]]
[[Category:TODO: Example]]
[[Category:TODO: Example]]

Latest revision as of 22:04, 6 October 2024

Client-Side
Function

 JavaScript



JavaScript Syntax


Required Params

  • modelName: string — The name of the model to be set for the player.

Return value

  • void — This function does not return a value.

Syntax

// Function to change the player's model
function changePlayerModel(modelName) {
    let player = mp.players.local; // Reference to the local player
    let modelHash = mp.game.joaat(modelName); // Get the model hash from the model name

    // Set the player's model
    player.model = modelHash; // Change the player's model

    // Notify the player
    mp.gui.chat.push("Your model has been changed to " + modelName + ".");
}

// Bind the function to a key (for example, the "E" key)
mp.keys.bind(69, false, function() { // 69 is the key code for "E"
    changePlayerModel('a_m_m_acult_01'); // Call the function to change the model
});


Available Models

See the list of available models: Peds


See also