Author Topic: A few Node related things;  (Read 1529 times)

Is there a variable that stores a clients nodes for example:
%client.player.headnode = headcode
Is there a command to show nodes after hiding them (I've tried showNode, but I was mistaken)
And is there a command to a set a node to something.
Note: I want to set other peoples appearance in my server to certain things, not my own appearance.

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.

Code: [Select]
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.

Thanks much.

Edit: Would there be a %client.allcolor variable?
« Last Edit: October 12, 2008, 03:02:15 AM by Destiny/Zack0Wack0 »

I don't think so, but you can set all body parts a particular colour:

player.setTempColor("1 0 0 1",3000) - colours red for three seconds
player.setNodeColor("ALL","0 1 0 1") - colours all body green, permenantly

so after you go hidenode("ALL") i got that working, how can you bring back the nodes you already hade before you hide them, with the same colours?

You can use unHideNode("lshoe") etc. to unhide individual nodes, and they'll keep the same colours as before you hid them.

hmmmmm, that doesn't really work, doesn't reset your head, feet or waist

The head node is called "headskin"
The foot nodes are "lshoe", "rshoe", "lpeg" and "rpeg"
The waist is a little weird since the second choice (dress) needs special things for the trim part

its echoing that the string always evaluates to 0, in the positions of your switch strings ("Accent" etc), unless thats my code?


Code: [Select]
function AIPlayer::ApplyBotParts(%this, %client) {
hideAllNodes(%this);
if(%client.hat == 1 && %client.accent == 1)
%this.unhidenode($Accent[4]);
else if($Accent[%client.accent] !$= "none")
%this.unhidenode($Accent[%client.accent]);
%this.unhidenode($Chest[%client.chest]);
if($hat[%client.hat] !$= "none")
%this.unhidenode($hat[%client.hat]);
%this.unhidenode($hip[%client.hip]);
if(%client.hip == 0) {
%this.unhidenode($LLeg[%client.lleg]);
%this.unhidenode($RLeg[%client.rleg]);
}
else {
%this.unhidenode(skirtTrimLeft);
%this.unhidenode(skirtTrimRight);
}
%this.unhidenode($LArm[%client.larm]);
%this.unhidenode($LHand[%client.lhand]);
if($pack[%client.pack] !$= "none")
%this.unhidenode($pack[%client.pack]);
%this.unhidenode($RArm[%client.rarm]);
%this.unhidenode($RHand[%client.rhand]);
if($SecondPack[%client.secondpack] !$= "none")
%this.unhidenode($SecondPack[%client.secondpack]);
}

function AIPlayer::ApplyBotColors(%this, %client) {
if(%client.hat == 1 && %client.accent == 1)
%this.setnodecolor($Accent[4], %client.accentColor);
else if($Accent[%client.accent] !$= "none")
%this.setnodecolor($Accent[%client.accent], %client.accentColor);
%this.setnodecolor($Chest[%client.chest], %client.chestColor);
if($hat[%client.hat] !$= "none")
%this.setnodecolor($hat[%client.hat], %client.hatColor);
%this.setnodecolor(headskin, %client.headColor);
if($hip[%client.hip] !$= "none")
%this.setnodecolor($hip[%client.hip], %client.hipColor);
if(%client.hip == 0) {
%this.setnodecolor($LLeg[%client.lleg], %client.llegColor);
%this.setnodecolor($RLeg[%client.rleg], %client.rlegColor);
}
else {
%this.setnodecolor(skirtTrimLeft, %client.llegColor);
%this.setnodecolor(skirtTrimRight, %client.rlegColor);
}
%this.setnodecolor($LArm[%client.larm], %client.larmColor);
%this.setnodecolor($LHand[%client.lhand], %client.lhandColor);
if($pack[%client.pack] !$= "none")
%this.setnodecolor($pack[%client.pack], %client.packColor);
%this.setnodecolor($RArm[%client.rarm], %client.rarmColor);
%this.setnodecolor($RHand[%client.rhand], %client.rhandColor);
if($SecondPack[%client.secondpack] !$= "none")
%this.setnodecolor($SecondPack[%client.secondpack], %client.secondpackColor);
%this.setdecalname(%client.decalname);
%this.setfacename(%client.facename);
}
I use that to turn Horses into clonebots, if that helps :o