The client's avatar choice is stored in the client.part and client.partcolor variables, as a number and a color ID e.g. rleg = "0" and rlegcolor = "1 0 0 1", so use the normal right leg (not peg) and colour it red. The head choice is not displayed, since there is only one kind of head, but headcolor exists. The names of each node are stored in arrays called $part - $rleg[0] = "rshoe" and $rleg[1] = "rpeg".
client.applyBodyParts() and client.applyBodyColors() can be used (in that order, usually) to apply a client's default appearance - changes to the appearance should be done in packages after that.
To hide nodes, use player.hideNode("part") and to show them use player.unHideNode("part"). A list of body nodes is available on the forum, if you search.
function Player::changeBodyPart(%player,%type,%partCode,%colorCode)
{
switch(%type)
{
case "accent":
for (%i = 0; $accent[%i] !$= ""; %i++) %player.hideNode($accent[%i]);
%player.unHideNode($accent[%partCode]);
%player.setNodeColor($accent[%partCode],%colorCode);
case "chest":
for (%i = 0; $chest[%i] !$= ""; %i++) %player.hideNode($chest[%i]);
%player.unHideNode($chest[%partCode]);
%player.setNodeColor($chest[%partCode],%colorCode);
case "hat":
for (%i = 0; $hat[%i] !$= ""; %i++) %player.hideNode($hat[%i]);
%player.unHideNode($hat[%partCode]);
%player.setNodeColor($hat[%partCode],%colorCode);
case "hip":
for (%i = 0; $hip[%i] !$= ""; %i++) %player.hideNode($hip[%i]);
%player.unHideNode($hip[%partCode]);
%player.setNodeColor($hip[%partCode],%colorCode);
case "larm":
for (%i = 0; $LArm[%i] !$= ""; %i++) %player.hideNode($LArm[%i]);
%player.unHideNode($larm[%partCode]);
%player.setNodeColor($larm[%partCode],%colorCode);
case "lhand":
for (%i = 0; $LHand[%i] !$= ""; %i++) %player.hideNode($LHand[%i]);
%player.unHideNode($lhand[%partCode]);
%player.setNodeColor($lhand[%partCode],%colorCode);
case "lleg":
for (%i = 0; $LLeg[%i] !$= ""; %i++) %player.hideNode($LLeg[%i]);
%player.unHideNode($lleg[%partCode]);
%player.setNodeColor($lleg[%partCode],%colorCode);
case "pack":
for (%i = 0; $pack[%i] !$= ""; %i++) %player.hideNode($pack[%i]);
%player.unHideNode($pack[%partCode]);
%player.setNodeColor($pack[%partCode],%colorCode);
case "rarm":
for (%i = 0; $RArm[%i] !$= ""; %i++) %player.hideNode($RArm[%i]);
%player.unHideNode($rarm[%partCode]);
%player.setNodeColor($rarm[%partCode],%colorCode);
case "rhand":
for (%i = 0; $RHand[%i] !$= ""; %i++) %player.hideNode($RHand[%i]);
%player.unHideNode($rhand[%partCode]);
%player.setNodeColor($rhand[%partCode],%colorCode);
case "rleg":
for (%i = 0; $RLeg[%i] !$= ""; %i++) %player.hideNode($RLeg[%i]);
%player.unHideNode($rleg[%partCode]);
%player.setNodeColor($rleg[%partCode],%colorCode);
case "secondPack":
for (%i = 0; $secondPack[%i] !$= ""; %i++) %player.hideNode($secondPack[%i]);
%player.unHideNode($secondPack[%partCode]);
%player.setNodeColor($secondPack[%partCode],%colorCode);
default:
error("Player::changeBodyPart: unknown part type " @ %partCode);
return;
}
}
Paste this function into your code, and use player.changeBodyPart("type","part code","colour code")
Accepted types are accent, chest, hat, hip, larm, lhand, lleg, pack, rarm, rhand, rleg and secondPack. Anything else will show an error.
The part code is approximately between one and four, echo $accent[number], $chest[number], $hat[number], etc. while hosting a server to find the exact body parts.
The colour code is a 4-digit code: "R G B A" with values between zero and one. (alpha, A, should almost always be one except for the Accent or special cases)
player.changeBodyPart("rarm",0,"1 0 0 1");
This will change player's right arm to the default one (not thin), coloured red. If they have the other type of arm currently on their avatar, it will be hidden and replaced.