| Blockland Forums > Modification Help |
| Error when using if-else |
| (1/1) |
| Axolotl:
Can somebody please fix this script's if function? --- Code: ---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); --- End code --- The syntax error itself: --- Code: ---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 --- End code --- |
| Chrono:
Forgot " at end of $= "GoldItem |
| Axolotl:
--- Quote from: Chrono on December 05, 2011, 08:59:50 AM ---Forgot " at end of $= "GoldItem --- End quote --- lol. will add that, thank you. EDIT: OK new error: --- Code: ---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 --- End code --- |
| Destiny/Zack0Wack0:
You have an extra curly brace before isObject(%col), I believe. |
| Axolotl:
Thanks |
| Navigation |
| Message Index |