Author Topic: Script crashing blockland  (Read 3790 times)

because I'd you export and then exec it work a space
Could you maybe rephrase this a bit...

Could you maybe rephrase this a bit...
OH GOD whoops
Blame my phone
Or me I guess for not reading before posting

Could you maybe rephrase this a bit...
segoe ui is a nice font but why use it everywhere

segoe ui is a nice font but why use it everywhere

He made a pledge.

Blockland is still crashing
This is the whole function

function ServerCMDCyes(%client)
{   
   if(!%client.inCropSale)
   {
      messageClient(%client,'',"\c6Your not in a crop sale!");
      return;
   }
   if(!isObject(%client.Croptarget))
   {
      messageClient(%client,'',"\c6Your trade partner has left!");
      ServerCMDCclear(%client);
      return;
   }
   %target = %client.croptarget;
   if(cityRPGData.getData(%client.getBlid()).valueMoney < %client.cropCharge)
   {
      messageClient(%client,'',"\c6You dont have \c3" @ %client.cropCharge);
      serverCMDCclear(%client);
      serverCMDCclear(%target);
      return;
   }
   cityRPGData.getData(%client.getBLID()).valueMoney -= %client.cropCharge;
   cityRPGData.getData(%target.getBLID()).valueMoney += %client.cropCharge;
   %eval = "cityRPGData.getData(" @ %client.getBlid() @ ").value" @ %client.CropSell @ " += " @ %client.CropSellAmnt @ ";";
   echo(%eval);
   eval(%eval);
   %eval = "";
   echo("Did we reach here? Or did it crash?");
   cityRPGData.getData(%target.getBlid()).value[%client.CropSell] -= %client.CropSellAmnt;
   messageClient(%client,'',"\c6You purcased \c3" @ %client.CropSellAmnt @ " \c6units of \c3" @ %client.CropSell @ "\c6 for \c3$" @ %client.CropCharge);
   messageClient(%target,'',"\c6You sold \c3" @ %client.CropSellAmnt @ " \c6units of \c3" @ %client.CropSell @ "\c6 for \c3$" @ %client.CropCharge);
   ServerCMDCclear(%client);
   ServerCMDCclear(%target);
   %client.setinfo();
   %target.setinfo();
}

Why are you still using eval

You're still using eval for no reason

cityRPGData.getData(%client.getBlid()).value[%client.CropSell] += %client.CropSellAmnt;

Just a note that I feel like saying because it seems to be a common misunderstanding:

eval() has the same scope as the parent function. The below is a perfectly valid statement:

Code: [Select]
%number = 1;
eval("%number++;");

%number will equal two.

So, there's no reason to do things like %eval = "cityRPGData.getData(" @ %client.getBlid() @ ");"; you can simply do %eval = "cityRPGData.getData(%client.getBlid());";

Which leads directly to the conclusion, you can just do cityRPGData.getData(%client.getBlid()); and be done with eval all together.


      messageClient(%client,'',"\c6Your not in a crop sale!");

You're*

Not code related, but fix that plz

the code shouldn't crash blockland though, what's going on there?

You're*

Not code related, but fix that plz

Just a note, when using apostrophes inside strings always prefix them with the backslash character ( \ ). Same thing with double quotes.

"\c6You\'re not in a crop sale!"

Just a note, when using apostrophies inside strings always prefix them with the forward slash character ( \ ).

"\c6You\'re not in a crop sale!"

It's inside a " string ". Why would it matter?

It's inside a " string ". Why would it matter?

I guess Torque has weird support for ' inside " as a result of ' not actually being used to identify strings, but tagged strings.

In other languages ' needs to be escaped inside a string. I thought Torque was the same way.

I guess Torque has weird support for ' inside " as a result of ' not actually being used to identify strings, but tagged strings.

In other languages ' needs to be escaped inside a string. I thought Torque was the same way.

It doesn't in PHP.

Whether it needs to or not, it's probably good practice.


Anyways OP. fix the eval issue, put more echos in, turn trace on, run the script until it crashes, then post console
« Last Edit: July 13, 2014, 06:23:38 PM by Headcrab Zombie »