Blockland Forums > Modification Help

Syntax error: Projectile Changing function

Pages: (1/2) > >>

takato14:

You may be able to tell, but this function is supposed to change the projectile of a weapon when the player's health is full. Ran into a syntax error I couldnt make sense of. Help?


--- Code: ---function MasterImage::OnFire(%client, %obj,%slot) //%otherargs means the other client sided arguements needed for this specific edit.
{
%health = mFloor($MaxHealth - %client.player.getDamageLevel() + 0.5) //This gets the clients Nice little Health!
if(!%health = 100) //If the Persons health is at max
{
%p = new (MasterProjectile)()
{
dataBlock = MasterProjectile;
initialVelocity = %velocity;
initialPosition = %obj.getMuzzlePoint(%slot);
sourceObject = %obj;
sourceSlot = %slot;
client = %obj.client;
};
MissionCleanup.add(%p);
}

else
{
%p = new (MasterProjectileFull)()
{
dataBlock = MasterProjectileFull;
initialVelocity = %velocity;
initialPosition = %obj.getMuzzlePoint(%slot);
sourceObject = %obj;
sourceSlot = %slot;
client = %obj.client;
};
MissionCleanup.add(%p);
}
}

--- End code ---
I get a syntax error for some reason:

--- Quote from: Code ---Loading Add-On: Weapon_TSP
Add-Ons/Weapon_TSP/Master Sword [TP]/server.cs Line: 215 - Syntax error.
>>> Some error context, with ## on sides of error halt:
function MasterImage::OnFire(%client, %obj,%slot) //%otherargs means the other client sided arguements needed for this specific edit.

{

^%health = mFloor($MaxHealth - %client.player.getDamageLevel() + 0.5) //This gets the clients Nice little Health!

^if(##%##health = 100) //If the Persons health is at max

^{

^^%p = new (MasterProjectile)()

^^{

^^^dataBlock = MasterProjectile;

^^^initialVelocity = %velocity;

^^^initialPosition = %obj.getMuzzlePoint(%slot);

^^^sourceObject = %obj;

^^^sourceSlot = %slot;
>>> Error report complete.

ADD-ON "Weapon_TSP" CONTAINS SYNTAX ERRORS

--- End quote ---
D:?



phflack:

instead of
%health = mFloor($MaxHealth - %client.player.getDamageLevel() + 0.5) //This gets the clients Nice little Health!
use
%health = mFloor($MaxHealth - %client.player.getDamageLevel() + 0.5); //This gets the clients Nice little Health!

you were missing a ;

takato14:

Thank you. I checked for semicolons but I guess I missed one. xP

takato14:

Thats no longer an error, but now its doing this:

x_x

Chrono:

Why did you add an extra } there after the Mission cleanup?

Also change
if(!%health = 100)
to
if(%health != 100)

and even if you were not using a !, it would be ==, not =.

Pages: (1/2) > >>

Go to full version