Author Topic: Weird syntax error  (Read 415 times)

So I made a script, and tested it. I found that it had a syntax error. This is the error:

Code: [Select]
Loading Add-On: Server_SpaceRP_TradingSystem (CRC:693186939)
Add-Ons/Server_SpaceRP_TradingSystem/server.cs Line: 51 - Syntax error.
>>> Some error context, with ## on sides of error halt:
^^%client.chatMessage("Type /sellresources [resource] [amount] to sell your credits, ice crystals or gold.[resource] names: Credits, Ice, Gold Example: /sellresources Ice 10");
^}
^
^function serverCmdbuyresources(%client, %resname, %resamt)
^{
^^if(%resamt < 1)
^^^%client.chatMessage("You must buy at least 1 resource unit.");
^^^return 1;
^^//find buy price of client's order
^^if (%resname $== ##"##Credits")
^^{
^^^%orderprice = (100 * %resamt);^^
^^}
^^if (%resname $== "Ice")
^^{
^^^%orderprice = ($srp::icecrystalprice * %resamt);
^^}
^^if (%resname $== "Gold")
^^{
^^^%orderprice = ($srp::goldprice * %resamt);
^^}
^^
^^if(%resname $!= "Credits" || %resname $!= "Ice" || %resname $!= "Gold")
>>> Error report complete.
Correct me if I'm wrong, but I don't see how a quote mark can be a syntax error.
And there were 2 more "if" statements very similar to it right afterwards, and they didn't have syntax errors.

The ## tags are always misplaced, the error is actually where you used $== as an evaluator (use $=). As for the ones after it, they are wrong too. Torque stops immediately after it finds the first syntax error, so it didn't even bother to look after that first one. You have to change these to $= as well

Ok. I'll try that and see if it works.

I ran it one more time after that because I forgot to change just one of those "if" statements, but now the script is syntax-error free. So locking the topic...