Author Topic: Can a Playertype Force a Specific Appearance on to the Player?  (Read 2792 times)

I apologize if this is a stupid question, but my knowledge of torquescript is no further than understanding what global and local variables are, how to modify them, and copying and pasting code together (after all, that's as far as most tutorials go). I'm currently working on a RPG-themed deathmatch server in which players must select a class before spawning. I want each class to have a distinct costume, yet I can't use the editAppearance from the old bot events for obvious reasons. If there is an editAppearance for new bots anyway, it won't work because whenever someone sprints with the sprinting playertype (code from it is used in my playertypes), their datablock would change, which I believe overwrites any modifications made to the player's avatar.

How can I implement this sort of feature that forces specific nodes onto a player using a certain playertype? Thank you for your time.

Avatar appearance isn't affected by datablocks. (unless that datablock makes use of a different model, but it still doesn't "change" your avatar preferences, it just utilizes them differently)

If editAppearance doesn't work, I believe that player objects have member fields for each node, decal, and color. Do findClientByName("<your username>").player.dump(); in console and scroll up to the member fields, and play around a bit.

Code: [Select]
datablock PlayerData(PlayerRPGBarbarian : PlayerStandardArmor)
{
rechargeRate = 0.65;

runForce = 4325;
runEnergyDrain = 0.25;
maxForwardSpeed = "5";
maxBackwardSpeed = "6";
maxSideSpeed = "6";

maxForwardCrouchSpeed = "3";
maxBackwardCrouchSpeed = "2";
maxSideCrouchSpeed = "2";
maxDamage = 225;

airControl = 0.1;
jumpForce = 950;

canJet = 0;

uiName = "RPG Barbarian";

canRide = 1;
showEnergyBar = 1;

maxTools = 2;
maxWeapons = 2;

player.hideNode('LShoe') = 1;
};
datablock PlayerData(PlayerRPGBarbarianActive : PlayerRPGBarbarian)
{
runEnergyDrain = 1.75;
minRunEnergy = 1;
maxForwardSpeed = "16";
maxBackwardSpeed = "0";
maxSideSpeed = "0";

maxForwardCrouchSpeed = "3";
maxBackwardCrouchSpeed = "2";
maxSideCrouchSpeed = "2";

airControl = 0;

uiName = "";

canRide = 0;
};

package RPGBarbarianPlayer
{
function Armor::onTrigger(%data,%player,%slot,%io)
{
if(%slot == 4)
{
if(%io && %data.getName() $= "PlayerRPGBarbarian")
{
%player.changeDatablock(PlayerRPGBarbarianActive);
%tool = %player.currTool;
servercmdunusetool(%player.client);
%player.currTool = %tool;
} else if(!%io && %data.getName() $= "PlayerRPGBarbarianActive")
{
%player.changeDatablock(PlayerRPGBarbarian);
servercmduseTool(%player.client,%player.currTool);
}
}
Parent::onTrigger(%data,%player,%slot,%io);
}
function Player::mountImage(%player,%image,%slot)
{
if(%player.getDatablock().getName() $= "PlayerRPGBarbarianActive" && %slot == 0)
{
return;
}
Parent::mountImage(%player,%image,%slot);
}
function ServerCmdUseTool(%client,%slot)
{
if(isObject(%player = %client.player))
{
if(%player.getDatablock().getName() $= "PlayerRPGBarbarianActive")
{
%player.currTool = %slot;
return;
}
}
Parent::serverCmdUseTool(%client,%slot);
}
};
activatePackage(RPGBarbarianPlayer);

what am i doing and why is it wrong

I did the player.dump(); thing but I have no idea how to use the actual thing

I never did anything like this before so

Also, the last package makes the player hide their weapons, right? If I remove it, will it mess up everything? Sorry I'm so stupid. Mind you, this is not the final script. I couldn't find "unhideNode" but I'm testing to see A: If this is a working solution, and B: How I'm supposed to do this.
« Last Edit: March 20, 2014, 10:37:05 PM by childofdarkness016 »


datablock PlayerData(PlayerRPGBarbarian : PlayerStandardArmor)
{
   rechargeRate = 0.65;

   runForce = 4325;
   runEnergyDrain = 0.25;
   maxForwardSpeed = "5";
   maxBackwardSpeed = "6";
   maxSideSpeed = "6";

   maxForwardCrouchSpeed = "3";
   maxBackwardCrouchSpeed = "2";
   maxSideCrouchSpeed = "2";
   maxDamage = 225;

   airControl = 0.1;
   jumpForce = 950;

   canJet = 0;

   uiName = "RPG Barbarian";

   canRide = 1;
   showEnergyBar = 1;
   
   maxTools = 2;
   maxWeapons = 2;
   
   player.hideNode('LShoe') = 1;
};

You can't put something like that in a datablock/object..

Use
function YourDatablock::onNewDatablock(%this,%obj)
{
   Parent::OnNewDatablock(%this,%obj);
   %obj.hideNode("LShoe"); //example
   //Stuff here
}

So everytime when the object is this datablock for the first time (No repeating), it should call this function. It doesn't need to be in a package, unless the class is Armor.
« Last Edit: March 20, 2014, 11:45:29 PM by Advanced Bot »


Double posting for obvious reasons.

Code: [Select]
datablock PlayerData(PlayerRPGBarbarian : PlayerStandardArmor)
{
        rechargeRate = 0.65;
 
        runForce = 4325;
        runEnergyDrain = 0.25;
        maxForwardSpeed = "5";
        maxBackwardSpeed = "6";
        maxSideSpeed = "6";
 
        maxForwardCrouchSpeed = "3";
        maxBackwardCrouchSpeed = "2";
        maxSideCrouchSpeed = "2";
        maxDamage = 225;
 
        airControl = 0.1;
        jumpForce = 950;
 
        canJet = 0;
 
        uiName = "RPG Barbarian";
 
        canRide = 1;
        showEnergyBar = 1;
       
        maxTools = 2;
        maxWeapons = 2;
};
datablock PlayerData(PlayerRPGBarbarianActive : PlayerRPGBarbarian)
{
        runEnergyDrain = 1.75;
        minRunEnergy = 1;
        maxForwardSpeed = "16";
        maxBackwardSpeed = "0";
        maxSideSpeed = "0";
 
        maxForwardCrouchSpeed = "3";
        maxBackwardCrouchSpeed = "2";
        maxSideCrouchSpeed = "2";
 
        airControl = 0;
 
        uiName = "";
 
        canRide = 0;
};
 
package RPGBarbarianPlayer
{
        function Armor::onTrigger(%data,%player,%slot,%io)
        {
                if(%slot == 4)
                {
                        if(%io && %data.getName() $= "PlayerRPGBarbarian")
                        {
%player.hideNode("ALL",0);
                                %player.setNodeColor("LShoe",60);
                                %player.setNodeColor("RShoe",60);
                                %player.setNodeColor("LArm",60);
                                %player.setNodeColor("RArm",60);
                                %player.setNodeColor("LHand",60);
                                %player.setNodeColor("RHand",60);
                                %player.setNodeColor("Chest",4);
                                %player.setNodeColor("Pants",4);
                                %player.setNodeColor("Headskin",60);
                                %player.changeDatablock(PlayerRPGBarbarianActive);
                                %tool = %player.currTool;
                                servercmdunusetool(%player.client);
                                %player.currTool = %tool;
                        } else if(!%io && %data.getName() $= "PlayerRPGBarbarianActive")
                        {
                                %player.changeDatablock(PlayerRPGBarbarian);
                                servercmduseTool(%player.client,%player.currTool);
                        }
                }
                Parent::onTrigger(%data,%player,%slot,%io);
        }
        function Player::mountImage(%player,%image,%slot)
        {
                if(%player.getDatablock().getName() $= "PlayerRPGBarbarianActive" && %slot == 0)
                {
%player.hideNode("ALL",0);
                        %player.setNodeColor("LShoe",60);
                        %player.setNodeColor("RShoe",60);
                        %player.setNodeColor("LArm",60);
                        %player.setNodeColor("RArm",60);
                        %player.setNodeColor("LHand",60);
                        %player.setNodeColor("RHand",60);
                        %player.setNodeColor("Chest",4);
                        %player.setNodeColor("Pants",4);
                        %player.setNodeColor("Headskin",60);
                        return;
                }
                Parent::mountImage(%player,%image,%slot);
        }
        function ServerCmdUseTool(%client,%slot)
        {
                if(isObject(%player = %client.player))
                {
                        if(%player.getDatablock().getName() $= "PlayerRPGBarbarianActive")
                        {
                                %player.currTool = %slot;
%player.hideNode("ALL",0);
                                %player.setNodeColor("LShoe",60);
                                %player.setNodeColor("RShoe",60);
                                %player.setNodeColor("LArm",60);
                                %player.setNodeColor("RArm",60);
                                %player.setNodeColor("LHand",60);
                                %player.setNodeColor("RHand",60);
                                %player.setNodeColor("Chest",4);
                                %player.setNodeColor("Pants",4);
                                %player.setNodeColor("Headskin",60);
                                return;
                        }
                }
                Parent::serverCmdUseTool(%client,%slot);
        }
};

so purplemetro tried to help me and gave me code i stupidly didn't test and fixed it to suit the playertype

this code does nothing. What am I supposed to do?

I asked him how nodes work, and he said that you're supposed to put the node's string and the numerical color from the colorset when you use setNodeColor (which also shows the node). Yet, this has done nothing.

Also, this is supposed to happen whenever a player first selects the playertype, and whenever they run or whatever

Testing it further, sprinting doesn't even work any more.
« Last Edit: March 22, 2014, 05:10:32 PM by childofdarkness016 »

-snip-
You forgot to activate the package.
I asked him how nodes work, and he said that you're supposed to put the node's string and the numerical color from the colorset when you use setNodeColor (which also shows the node). Yet, this has done nothing.
He was wrong. It's player.setNodeColor("NODE_NAME", "R G B A");
The RGBA colors should be 0-1.

You forgot to activate the package.He was wrong. It's player.setNodeColor("NODE_NAME", "R G B A");
The RGBA colors should be 0-1.

Thank you! I didn't read the code, which was dumb of me. Anyway, I guess I will revise that.

Will double post if another issue arises.

Code: [Select]
%player.hideNode("ALL","0 0 0 0");
I revised the line as jes00 suggested I did, and it worked. The only issue, however, is that some of my unwanted nodes (hats, shoulder parts, etc.) still showed. How is this one line supposed to be correctly done? Thanks.

%player.hideNode("ALL");

%player.hideNode("ALL");

that should have been obvious

thanks

EDIT: No more double posting. How do I unhide a node? After I tested the new version, my whole avatar disappeared! According to PurpleMetro, who I should no longer trust, setNodeColor automatically unhides nodes, but that, clearly, is a lie.
« Last Edit: March 22, 2014, 06:13:00 PM by childofdarkness016 »

that should have been obvious

thanks

EDIT: No more double posting. How do I unhide a node? After I tested the new version, my whole avatar disappeared! According to PurpleMetro, who I should no longer trust, setNodeColor automatically unhides nodes, but that, clearly, is a lie.
%player.unHideNode("NODE_NAME");
Don't just use ALL because it will look very messed up.

If you want to just unhide all the nodes that they would regularly have then you can just use %client.applyBodyParts();
« Last Edit: March 22, 2014, 06:17:13 PM by jes00 »

%player.unHideNode("NODE_NAME");
Don't just use ALL because it will look very messed up.

If you want to just unhide all the nodes that they would regularly have then you can just use %client.applyBodyParts();

no no no that's what i meant

why would i unhide all of them

And, again, I didn't try that because PurpleMetro told me it didn't exist. I'm so done. Anyway, I feel really stupid after this help post, so could anyone link me to a more advanced tutorial that explains something other than variables? Thanks.

OK, it's been a while and I'm still having trouble.

Code: [Select]
datablock PlayerData(PlayerRPGBarbarian : PlayerStandardArmor)
{
        rechargeRate = 0.65;
 
        runForce = 4325;
        runEnergyDrain = 0.25;
        maxForwardSpeed = "5";
        maxBackwardSpeed = "6";
        maxSideSpeed = "6";
 
        maxForwardCrouchSpeed = "3";
        maxBackwardCrouchSpeed = "2";
        maxSideCrouchSpeed = "2";
        maxDamage = 225;
 
        airControl = 0.1;
        jumpForce = 950;
 
        canJet = 0;
 
        uiName = "RPG Barbarian";
 
        canRide = 1;
        showEnergyBar = 1;
       
        maxTools = 2;
        maxWeapons = 2;
};
datablock PlayerData(PlayerRPGBarbarianActive : PlayerRPGBarbarian)
{
        runEnergyDrain = 1.75;
        minRunEnergy = 1;
        maxForwardSpeed = "16";
        maxBackwardSpeed = "0";
        maxSideSpeed = "0";
 
        maxForwardCrouchSpeed = "3";
        maxBackwardCrouchSpeed = "2";
        maxSideCrouchSpeed = "2";
 
        airControl = 0;
 
        uiName = "";
 
        canRide = 0;
};
 
package RPGBarbarianPlayer
{
        function Armor::onTrigger(%data,%player,%slot,%io)
        {
                if(%slot == 4)
                {
                        if(%io && %data.getName() $= "PlayerRPGBarbarian")
                        {
%player.changeDatablock(PlayerRPGKnightActive);
%tool = %player.currTool;
servercmdunusetool(%player.client);
%player.currTool = %tool;
%player.hideNode("ALL");
                                %player.unHideNode("LShoe");
%player.setNodeColor("LShoe", "1 .926 .694 1");
                                %player.unHideNode("RShoe");
%player.setNodeColor("RShoe", "1 .926 .694 1");
                                %player.unHideNode("LArm");
%player.setNodeColor("LArm", "1 .926 .694 1");
                                %player.unHideNode("RArm");
%player.setNodeColor("RArm", "1 .926 .694 1");
                                %player.unHideNode("LHand");
%player.setNodeColorNode("LHand", "1 .926 .694 1");
%player.unHideNode("RHand");
%player.setNodeColorNode("RHand", "1 .926 .694 1");
                                %player.unHideNode("Chest");
%player.setNodeColor("Chest",".471 .235 .169 1");
                                %player.unHideNode("Pants");
%player.setNodeColor("Pants",".471 .235 .169 1");
                                %player.unHideNode("Headskin");
%player.setNodeColor("Headskin","1 .926 .694 1");
%player.setDecalName("Medieval-Tunic");
                        } else if(!%io && %data.getName() $= "PlayerRPGBarbarianActive")
                        {
                                %player.changeDatablock(PlayerRPGBarbarian);
                                servercmduseTool(%player.client,%player.currTool);
%player.hideNode("ALL");
                                %player.unHideNode("LShoe");
%player.setNodeColor("LShoe", "1 .926 .694 1");
                                %player.unHideNode("RShoe");
%player.setNodeColor("RShoe", "1 .926 .694 1");
                                %player.unHideNode("LArm");
%player.setNodeColor("LArm", "1 .926 .694 1");
                                %player.unHideNode("RArm");
%player.setNodeColor("RArm", "1 .926 .694 1");
                                %player.unHideNode("LHand");
%player.setNodeColorNode("LHand", "1 .926 .694 1");
%player.unHideNode("RHand");
%player.setNodeColorNode("RHand", "1 .926 .694 1");
                                %player.unHideNode("Chest");
%player.setNodeColor("Chest",".471 .235 .169 1");
                                %player.unHideNode("Pants");
%player.setNodeColor("Pants",".471 .235 .169 1");
                                %player.unHideNode("Headskin");
%player.setNodeColor("Headskin","1 .926 .694 1");
%player.setDecalName("Medieval-Tunic");
                        }
                }
                Parent::onTrigger(%data,%player,%slot,%io);
        }
        function Player::mountImage(%player,%image,%slot)
        {
                if(%player.getDatablock().getName() $= "PlayerRPGBarbarianActive" && %slot == 0)
                {
%player.currTool = %slot;
%player.hideNode("ALL");
                                %player.unHideNode("LShoe");
%player.setNodeColor("LShoe", "1 .926 .694 1");
                                %player.unHideNode("RShoe");
%player.setNodeColor("RShoe", "1 .926 .694 1");
                                %player.unHideNode("LArm");
%player.setNodeColor("LArm", "1 .926 .694 1");
                                %player.unHideNode("RArm");
%player.setNodeColor("RArm", "1 .926 .694 1");
                                %player.unHideNode("LHand");
%player.setNodeColorNode("LHand", "1 .926 .694 1");
%player.unHideNode("RHand");
%player.setNodeColorNode("RHand", "1 .926 .694 1");
                                %player.unHideNode("Chest");
%player.setNodeColor("Chest",".471 .235 .169 1");
                                %player.unHideNode("Pants");
%player.setNodeColor("Pants",".471 .235 .169 1");
                                %player.unHideNode("Headskin");
%player.setNodeColor("Headskin","1 .926 .694 1");
%player.setDecalName("Medieval-Tunic");
                        return;
                }
                Parent::mountImage(%player,%image,%slot);
        }
        function ServerCmdUseTool(%client,%slot)
        {
                if(isObject(%player = %client.player))
                {
                        if(%player.getDatablock().getName() $= "PlayerRPGBarbarianActive")
                        {
                                %player.currTool = %slot;
%player.hideNode("ALL");
                                %player.unHideNode("LShoe");
%player.setNodeColor("LShoe", "1 .926 .694 1");
                                %player.unHideNode("RShoe");
%player.setNodeColor("RShoe", "1 .926 .694 1");
                                %player.unHideNode("LArm");
%player.setNodeColor("LArm", "1 .926 .694 1");
                                %player.unHideNode("RArm");
%player.setNodeColor("RArm", "1 .926 .694 1");
                                %player.unHideNode("LHand");
%player.setNodeColorNode("LHand", "1 .926 .694 1");
%player.unHideNode("RHand");
%player.setNodeColorNode("RHand", "1 .926 .694 1");
                                %player.unHideNode("Chest");
%player.setNodeColor("Chest",".471 .235 .169 1");
                                %player.unHideNode("Pants");
%player.setNodeColor("Pants",".471 .235 .169 1");
                                %player.unHideNode("Headskin");
%player.setNodeColor("Headskin","1 .926 .694 1");
%player.setDecalName("Medieval-Tunic");
                                return;
                        }
                }
                Parent::serverCmdUseTool(%client,%slot);
        }
};
activatePackage(RPGBarbarianPlayer);

This changes the player successfully, but only when they sprint for the first time. Can someone explain why and how I can fix it (if applicable)?
« Last Edit: March 22, 2014, 07:04:02 PM by childofdarkness016 »

serverCmdUseTool

Clients send slot numbers, like, 0-5 (Or more than 5)