SetPlayerSkin

From GT-MP
Jump to: navigation, search
SetPlayerSkin
Shared Function
Utilities-terminal.png Server-Side System-users.png Client-Side
Csharp.png C# Javascript.png JavaScript

Set a skin to a defined player.


Syntax

API.setPlayerSkin(Client player, PedHash modelHash);

Required Arguments

  • player: parameter input should be in Client type.
  • modelHash: parameter input should be in PedHash type.
Icon-info.png
Attention: Changing the Skin of a Player will result in the loss of all his weapons!


Usage example(s)

In C#
Server-Side Function

[Command("skin")]
public void ChangeSkinCommand(Client sender, PedHash model)
{
    API.setPlayerSkin(sender, model);     
}

In Javascript
Client-Side Function

API.setPlayerSkin(1885233650) //Default GTAO Male Skin

Bugfix for reset Weapons

In C#
Server-Side Function

[Command("skin")]
public void ChangeSkinCommand(Client sender, PedHash model)
{
    WeaponHash[] wHashes = API.getPlayerWeapons(sender);
	int[] ammo = new int[wHashes.Length];

	for(int i=0; i < wHashes.Length; i++)
	{
		ammo[i] = API.getPlayerWeaponAmmo(sender, wHashes[i]);
	}

	API.setPlayerSkin(sender, model);

	for (int i = 0; i < wHashes.Length; i++)
	{
		API.givePlayerWeapon(sender, wHashes[i], ammo[i], true, true);
	}    
}


References