Player::setClothes: Difference between revisions

From RAGE Multiplayer Wiki
No edit summary
m (Replaced HTML with template)
Line 8: Line 8:


== Syntax ==
== Syntax ==
<syntaxhighlight lang="javascript">
<pre>
player.setClothes(Number componentNumber, Number drawable, Number texture, Number palette)
player.setClothes(Number componentNumber, Number drawable, Number texture, Number palette)
</syntaxhighlight>
</pre>
 
List of components:
List of components:
* 0 - Head
* 0 - Head
Line 27: Line 28:
== Example ==
== Example ==
This example changes clothes.
This example changes clothes.
<syntaxhighlight lang="javascript">
{{ServersideCode|
<pre>
mp.events.add('playerCommand', (player, command) => {
mp.events.add('playerCommand', (player, command) => {
   let arr = command.split(' ');
   let arr = command.split(' ');
Line 38: Line 40:
   }
   }
});
});
</syntaxhighlight>
</pre>
}}


==See Also==
==See Also==

Revision as of 12:54, 26 October 2018

This function set clothing for player. Alternative of client-side function: Player::setComponentVariation

palette = 2

Known issues

  • This function can't handle drawable over 255. If you need, use player.data & entityDataChange + entityStreamIn events so you can set it client-side with setComponentVariation. Fixed in 0.4.

Syntax

player.setClothes(Number componentNumber, Number drawable, Number texture, Number palette)

List of components:

  • 0 - Head
  • 1 - Beard
  • 2 - Hair
  • 3 - Torso
  • 4 - Legs
  • 5 - Hands
  • 6 - Foot
  • 7 - Eyes
  • 8 - Accessories like parachute, scuba tank
  • 9 - Accessories like bags, mask, scuba mask
  • 10- Decals and mask
  • 11 - Auxiliary parts for torso

Example

This example changes clothes.

Server-Side
mp.events.add('playerCommand', (player, command) => {
  let arr = command.split(' ');
  if (arr[0] == 'setclothes') {
    if (arr.length < 5 || parseInt(arr[1]) === undefined || parseInt(arr[2]) === undefined || parseInt(arr[3]) === undefined || parseInt(arr[4]) === undefined) {
      return player.outputChatBox('Use syntax: /setclothes [component_id] [drawable_id] [texture_id] [palette_id]');
    } else {
      player.setClothes(parseInt(arr[1]), parseInt(arr[2]), parseInt(arr[3]), parseInt(arr[4]));
    }
  }
});

See Also