Author Topic: ADD-ON script_moneymod contains syntax errors...?  (Read 590 times)

I get this error while trying to test my money mod (More of playing around with varibles, really...)
(Note, I did write package correctly, and I don't even know about servercmdmoneyadd...)
VVV-Error Report-VVV

Code: [Select]
Loading Add-On: script_moneymod (CRC:1537974462)
Add-Ons/script_moneymod/moneyscript.cs Line: 3 - Syntax error.
>>> Some error context, with ## on sides of error halt:
ackage MPcash



function ##S##erverCmdMoneyAdd()

{

%money += %5;



messageclient(%client, "", "You have been granted 5!");

messageclient(%client, 'bottomprint', %money, 10);

}

 

function ServerCmdMoneySubtract()

{

%money -= 5;



messageclient(%client "","You lost 5!");

messageclient(%client, 'bottomprint', %money, 10);
>>> Error report complete.

ADD-ON "script_moneymod" CONTAINS SYNTAX ERRORS

VVV-Actual Script-VVV

Code: [Select]
package MPcash

function ServerCmdMoneyAdd()
{
%money += %5;

messageclient(%client, "", "You have been granted 5!");
messageclient(%client, 'bottomprint', %money, 10);
}
 
function ServerCmdMoneySubtract()
{
%money -= 5;

messageclient(%client "","You lost 5!");
messageclient(%client, 'bottomprint', %money, 10);
}

function ServerCmdMoneySave()
{
export("$money*", "config/money.cs");

messageclient(%client "","Money saved!");
messageclient(%client, 'bottomprint', %money, 10);
}

function ServerCmdMoneyLoad()
{
exec("config/money.cs");
echo("Money.cs loaded!");

messageclient(%client "","Money loaded!");
messageclient(%client, 'bottomprint', %money, 10);
}

function ServerCmdMoneyHelp()
{
messageclient(%client "","Hello, welcome to moneymod. The commands for this mod are...");
messageclient(%client "","MoneySubtract - Subtracts 5 dollars from cash.");
messageclient(%client "","MoneySave - Saves money to a file.");
messageclient(%client "","MoneyLoad - Loads money from file.");
messageclient(%client "","MoneyHelp - Lists MoneyMod commands.");
}


};

Can someone help, or just fix the script completely? I have to go for the night, but just PM the script to me or post it in comments, either works.

Thanks :D

Forgot a bracket after package.

Forgot a bracket after package.

Ah, you see, even WITH the bracket, it has the error, I. Believe. I will try that tomorrow, posting from an android is hard. ,_.

I see multiple things wrong with this script.

I see multiple things wrong with this script.
Stating the errors would be more help.

I had a look at the script and fixed the syntax errors, and incorrect usage of messageclient, This should work however there may be a problem I overlooked.

Code: [Select]
package MPcash
{
   function ServerCmdMoneyAdd(%client)
   {
      $money += 5;

      messageclient(%client , '', "You have been granted 5!");
      messageclient(%client , 'bottomprint', %money, 10);
   }
   
   function ServerCmdMoneySubtract(%client)
   {
      $money -= 5;

      messageclient(%client , '', "You lost 5!");
      messageclient(%client , 'bottomprint', %money, 10);
   }

   function ServerCmdMoneySave(%client)
   {
      export("$money*", "config/money.cs");

      messageclient(%client , '', "Money saved!");
      messageclient(%client , 'bottomprint', %money, 10);
   }

   function ServerCmdMoneyLoad(%client)
   {
      exec("config/money.cs");
      echo("Money.cs loaded!");

      messageclient(%client , '', "Money loaded!");
      messageclient(%client , 'bottomprint', %money, 10);
   }

   function ServerCmdMoneyHelp(%client)
   {
      messageclient(%client , '', "Hello, welcome to moneymod. The commands for this mod are...");
      messageclient(%client , '', "MoneySubtract - Subtracts 5 dollars from cash.");
      messageclient(%client , '', "MoneySave - Saves money to a file.");
      messageclient(%client , '', "MoneyLoad - Loads money from file.");
      messageclient(%client , '', "MoneyHelp - Lists MoneyMod commands.");
   }
};
activatePackage(MPcash);

And you're packaging a bunch of servercmd's that haven't been defined before?
You can do it.
But I don't see why you would.

And you're packaging a bunch of servercmd's that haven't been defined before?
You can do it.
But I don't see why you would.

Probably to enable/disable everything.

Like I said, it's just a little variable test. All I wanted to do was make a simple script.