Author Topic: Error when using if-else  (Read 457 times)

Can somebody please fix this script's if function?
Code: [Select]
package CityRPG_Cash
{
// Section 1.1 : Drop Money
function gameConnection::onDeath(%client, %killerPlayer, %killer, %damageType, %unknownA)
{
if(!getWord(CityRPGData.getData(%client.bl_id).valueJailData, 1) && CityRPGData.getData(%client.bl_id).valueMoney && !%client.moneyOnSelf Delete)
{
%cash = new Item()
{
datablock = castuffem;
canPickup = false;
value = mFloor(CityRPGData.getData(%client.bl_id).valueMoney);
};

%cash.setTransform(setWord(%client.player.getTransform(), 2, getWord(%client.player.getTransform(), 2) + 2));
%cash.setVelocity(VectorScale(%client.player.getEyeVector(), 10));

MissionCleanup.add(%cash);
%cash.setShapeName("$" @ %cash.value);

CityRPGData.getData(%client.bl_id).valueMoney = 0;
%client.SetInfo();
}

parent::onDeath(%client, %killerPlayer, %killer, %damageType, %unknownA);
}

// Section 1.2 : Money and Gold Pickup
function Armor::onCollision(%this, %obj, %col, %thing, %other)
{
if(%col.getDatablock().getName() $= "Castuffem")
{
if(isObject(%obj.client))
{
if(isObject(%col))
{
if(%obj.client.minigame)
%col.minigame = %obj.client.minigame;

CityRPGData.getData(%obj.client.bl_id).valueMoney += %col.value;
messageClient(%obj.client, '', "\c6You have picked up \c3$" @ %col.value SPC "\c6off the ground.");

%obj.client.SetInfo();
%col.canPickup = false;
%col.delete();
}
else
{
%col.delete();
MissionCleanup.remove(%col);
}
}
}
else
{
if(%col.getDatablock().getName() $= "GoldItem)
{
if(isObject(%obj.client))
{
if(isObject(%col))
{
if(%obj.client.minigame)
%col.minigame = %obj.client.minigame;

CityRPGData.getData(%obj.client.bl_id).valueMoney += %col.value;
messageClient(%obj.client, '', "\c6You have picked up \c3a gold bar worth $" @ %col.value SPC "\c6off the ground.");

%obj.client.SetInfo();
%col.canPickup = false;
%col.delete();
}
else
{
%col.delete();
MissionCleanup.remove(%col);
}
}
}
}
if(isObject(%col))
parent::onCollision(%this, %obj, %col, %thing, %other);
}
}

function Castuffem::onAdd(%this, %item, %b, %c, %d, %e, %f, %g)
{
parent::onAdd(%this, %item, %b, %c, %d, %e, %f, %g);
schedule($CityRPG::pref::moneyDieTime, 0, "eval", "if(isObject(" @ %item.getID() @ ")) { " @ %item.getID() @ ".delete(); }");
}
};
activatePackage(CityRPG_Cash);
The syntax error itself:
Code: [Select]
Loading Add-On: Gamemode_CityRPG
Add-Ons/Gamemode_CityRPG/modules/cash.cs Line: 72 - Syntax error.
>>> Some error context, with ## on sides of error halt:
^^^^^messageClient(%obj.client, '', "\c6You have picked up \c3$" @ %col.value SPC "\c6off the ground.");

^^^^^

^^^^^%obj.client.SetInfo();

^^^^^%col.canPickup = false;

^^^^^%col.delete();

^^^^}

^^^^else

^^^^{

^^^^^%col.delete();

^^^^^MissionCleanup.remove(%col);

^^^^}

^^^}

^^}
^^else
^^{
^^^if(%col.getDatablock().getName() $= "GoldItem)
##^##^^{

^^^^if(isObject(%obj.client))

^^^^^{

^^^^^^if(isObject(%col))

^^^^^^{

^^^^^^^if(%obj.client.minigame)

^^^^^^^^%col.minigame = %obj.client.minigame;

^^^^^

^^^^^^^CityRPGData.getData(%obj.client.bl_id).valueMoney += %col.value;

^^^^^^^messageClient(%obj.client, '', "\c6You have picked up \c3a gold bar worth $" @ %col.value SPC "\c6off the ground.");
>>> Error report complete.

ADD-ON "Gamemode_CityRPG" CONTAINS SYNTAX ERRORS

Forgot " at end of $= "GoldItem

Forgot " at end of $= "GoldItem
lol.

will add that, thank you.

EDIT: OK new error:
Code: [Select]
Loading Add-On: Gamemode_CityRPG
Add-Ons/Gamemode_CityRPG/modules/cash.cs Line: 97 - Syntax error.
>>> Some error context, with ## on sides of error halt:
^^^^^^^messageClient(%obj.client, '', "\c6You have picked up \c3a gold bar worth $" @ %col.value SPC "\c6off the ground.");

^^^^^

^^^^^^^%obj.client.SetInfo();

^^^^^^^%col.canPickup = false;

^^^^^^^%col.delete();

^^^^^^}

^^^^^^else

^^^^^^{

^^^^^^^%col.delete();

^^^^^^^MissionCleanup.remove(%col);

^^^^^^}

^^^^^}
^^^^}
^^^}
^^}
^^if(##i##sObject(%col))

^^^^parent::onCollision(%this, %obj, %col, %thing, %other);

^}

^

^function castuffem::onAdd(%this, %item, %b, %c, %d, %e, %f, %g)

^{

^^parent::onAdd(%this, %item, %b, %c, %d, %e, %f, %g);

^^schedule($CityRPG::pref::moneyDieTime, 0, "eval", "if(isObject(" @ %item.getID() @ ")) { " @ %item.getID() @ ".delete(); }");
>>> Error report complete.

ADD-ON "Gamemode_CityRPG" CONTAINS SYNTAX ERRORS
« Last Edit: December 05, 2011, 04:00:32 PM by Axolotl »

You have an extra curly brace before isObject(%col), I believe.