Author Topic: I need some help with *script merging  (Read 2525 times)

Anyways, new problem

I need it to be so when you say /wearPiehat and you already have the pie on, it takes it off.
But if you don't have it on, then it puts it on.

I have 2 peices of code but I dont know how to merge them to have the functionality that I want
Code: [Select]
package PieHat
{
function serverCmdwearPieHat(%client)
{
        if(%client.piesEaten >= 100||%client.isAdmin||%client.isSuperAdmin)
        {
%client.player.unmountImage(2);
%client.player.mountImage(PiehatImage,2);
messageClient(%client,'',"<color:FFFF00>You put on the PIE HAT.");

for(%i = 0;$hat[%i] !$= "";%i++)
{
%client.player.hideNode($hat[%i]);
%client.player.hideNode($accent[%i]);
}
        }
        else
        {
                messageClient(%client,'',"<color:FFFF00>You do not have enough pies.");
        }
}
};
ActivatePackage(PieHat);

Code: [Select]
{
if(%player.getMountedImage(2) $= nametoID(PiehatImageImage))
{
%player.unmountImage(2);
%client.applyBodyParts();
%client.applyBodyColors();
}
else
{
%player.unmountImage(2);
%player.mountImage(PiehatImageImage,2);

for(%i = 0;$hat[%i] !$= "";%i++)
{
%player.hideNode($hat[%i]);
%player.hideNode($accent[%i]);
}
}
}

Any help?
« Last Edit: August 20, 2013, 11:01:07 PM by Darksaber2213 »

And Number 2:
Can I have multiple if statements inside a function?
My code is this:
Code: [Select]
package EatPie
{
function ServerCmdEatPie(%client)
{
if(%client.pieEnabled == 2)
{
%client.piesEaten += 1;
messageClient(%client,'',"<color:FFFF00>You ate a pie. You have eaten" SPC %client.piesEaten SPC "pies.");
}
else
{
messageClient(%client,'',"<color:FFFF00>You are not allowed to eat pie.");
}
}
};
ActivatePackage(EatPie);

I want to give the client a message when he reaches 100 pies.
Could I do this inside this function here or would I have to do something else?
Yes, just do something like this:
Code: [Select]
package EatPie
{
function ServerCmdEatPie(%client)
{
if(%client.pieEnabled == 2)
{
%client.piesEaten += 1;
messageClient(%client,'',"<color:FFFF00>You ate a pie. You have eaten" SPC %client.piesEaten SPC "pies.");
}
else
{
messageClient(%client,'',"<color:FFFF00>You are not allowed to eat pie.");
}

if(%client.piesEaten >= 100 && %client.pieEnabled)
{
messageClient(%client,'',"<color:FFFF00>Dude. You just ate 100 pies.");
}
}
};
ActivatePackage(EatPie);

Code: [Select]
if((%col.GrappleRopeTarget || $Pref::Server::GrappleRopeAnywhere || %col.getClassName() $= "fxDTSBrick") && %col.getname() $= "_grapple")
note the added parenthesies

Changes the logic around a tad, might work.

-SNIP-


Now with this code,
Code: [Select]
package PieHat
{
function serverCmdwearPieHat(%client)
{
        if(%client.piesEaten >= 100||%client.isAdmin||%client.isSuperAdmin)
        {
%client.player.unmountImage(2);
%client.player.mountImage(PiehatImage,2);
messageClient(%client,'',"<color:FFFF00>You put on the PIE HAT.");

for(%i = 0;$hat[%i] !$= "";%i++)
{
%client.player.hideNode($hat[%i]);
%client.player.hideNode($accent[%i]);
}
        }
        else
        {
                messageClient(%client,'',"<color:FFFF00>You do not have enough pies.");
        }
}
};
ActivatePackage(PieHat);
would it be able to implement something like this?
Code: [Select]
{
if(%player.getMountedImage(2) $= nametoID(PiehatImageImage))
{
%player.unmountImage(2);
%client.applyBodyParts();
%client.applyBodyColors();
}
else
{
%player.unmountImage(2);
%player.mountImage(PiehatImageImage,2);

for(%i = 0;$hat[%i] !$= "";%i++)
{
%player.hideNode($hat[%i]);
%player.hideNode($accent[%i]);
}
}
}

The brackets confuse me D:

Also, uhh
Code: [Select]
Add-Ons/Tool_GrappleRope/Tool_GrappleRope.cs Line: 23 - Syntax error.
>>> Some error context, with ## on sides of error halt:
// Changes by Demian (10334)

//

// - Removed GrappleRopeExplosionParticle, GrappleRopeExplosionEmitter and Air Control Playertype.

// - New rope particle and color.

// - Fixed console errors.

// - Enhanced script overall appearance.

//----------------

datablock ##P##articleData(ChainTrailParticle)

{

^dragCoefficient = 3.0;

^windCoefficient = 0.0;

^gravityCoefficient = 0.0;

^inheritedVelFactor = 0.0;

^constantAcceleration = 0.0;

^lifetimeMS = 50;

^lifetimeVarianceMS = 0;

^spinSpeed = 10.0;

^spinRandomMin = -50.0;
>>> Error report complete.
« Last Edit: August 18, 2013, 09:46:30 PM by Darksaber2213 »


Now with this code,
Code: [Select]
package PieHat
{
function serverCmdwearPieHat(%client)
{
        if(%client.piesEaten >= 100||%client.isAdmin||%client.isSuperAdmin)
        {
%client.player.unmountImage(2);
%client.player.mountImage(PiehatImage,2);
messageClient(%client,'',"<color:FFFF00>You put on the PIE HAT.");

for(%i = 0;$hat[%i] !$= "";%i++)
{
%client.player.hideNode($hat[%i]);
%client.player.hideNode($accent[%i]);
}
        }
        else
        {
                messageClient(%client,'',"<color:FFFF00>You do not have enough pies.");
        }
}
};
ActivatePackage(PieHat);
would it be able to implement something like this?
Code: [Select]
{
if(%player.getMountedImage(2) $= nametoID(PiehatImageImage))
{
%player.unmountImage(2);
%client.applyBodyParts();
%client.applyBodyColors();
}
else
{
%player.unmountImage(2);
%player.mountImage(PiehatImageImage,2);

for(%i = 0;$hat[%i] !$= "";%i++)
{
%player.hideNode($hat[%i]);
%player.hideNode($accent[%i]);
}
}
}

The brackets confuse me D:
What do you mean? Where?

You need better formatting.

What do you mean? Where?

You need better formatting.
I need it to be so when you say /wearPiehat
and you already have the pie on
it takes it off.
But if you don't have it on, then it puts it on.

Do not post ambiguous topics. It appears you've already been helped.

« Last Edit: August 19, 2013, 04:11:25 AM by Scriode »

NEW QUESTION
Code: [Select]
Add-Ons/Tool_GrappleRope/Tool_GrappleRope.cs Line: 23 - Syntax error.
>>> Some error context, with ## on sides of error halt:
// Changes by Demian (10334)

//

// - Removed GrappleRopeExplosionParticle, GrappleRopeExplosionEmitter and Air Control Playertype.

// - New rope particle and color.

// - Fixed console errors.

// - Enhanced script overall appearance.

//----------------

datablock ##P##articleData(ChainTrailParticle)

{

^dragCoefficient = 3.0;

^windCoefficient = 0.0;

^gravityCoefficient = 0.0;

^inheritedVelFactor = 0.0;

^constantAcceleration = 0.0;

^lifetimeMS = 50;

^lifetimeVarianceMS = 0;

^spinSpeed = 10.0;

^spinRandomMin = -50.0;
>>> Error report complete.

WHAT IS THIS

Literally nothing above this
datablock ##P##articleData(ChainTrailParticle)

Case sensitive if I remember correctly.

Not when defining a datablock

When you post an error report you should post the original script along with it.
Maybe it's just me, but the way the error reports double spaces everything (and I think it does a few other things too) makes it harder to read.
As far as the error report, you really only need to paste the line with the ####, and a few lines above/below it to show context/where it is. Anything more just takes up space in the post and makes people look more for the error location

Aha

How did that even get there.

Anyways, new problem

I need it to be so when you say /wearPiehat and you already have the pie on, it takes it off.
But if you don't have it on, then it puts it on.

I have 2 peices of code but I dont know how to merge them to have the functionality that I want
Code: [Select]
package PieHat
{
function serverCmdwearPieHat(%client)
{
        if(%client.piesEaten >= 100||%client.isAdmin||%client.isSuperAdmin)
        {
%client.player.unmountImage(2);
%client.player.mountImage(PiehatImage,2);
messageClient(%client,'',"<color:FFFF00>You put on the PIE HAT.");

for(%i = 0;$hat[%i] !$= "";%i++)
{
%client.player.hideNode($hat[%i]);
%client.player.hideNode($accent[%i]);
}
        }
        else
        {
                messageClient(%client,'',"<color:FFFF00>You do not have enough pies.");
        }
}
};
ActivatePackage(PieHat);

Code: [Select]
{
if(%player.getMountedImage(2) $= nametoID(PiehatImageImage))
{
%player.unmountImage(2);
%client.applyBodyParts();
%client.applyBodyColors();
}
else
{
%player.unmountImage(2);
%player.mountImage(PiehatImageImage,2);

for(%i = 0;$hat[%i] !$= "";%i++)
{
%player.hideNode($hat[%i]);
%player.hideNode($accent[%i]);
}
}
}

Any help?

for
Code: [Select]
if(%player.getMountedImage(2) $= nametoID(PiehatImageImage))it should probably be
Code: [Select]
if(%player.getMountedImage(2) == PiehatImageImage.getid())
Not really sure if nameToID actually exists.

Also, does %player even exist?
« Last Edit: August 20, 2013, 11:10:16 PM by Advanced Bot »