Blockland Forums > Modification Help
Eval Broken?
(1/4) > >>
Reinforcements:
I'm making an event that uses eval. You type something in the text box, then you activate the brick or whatever you'd like to use. I just don't get why this doesn't work. This is for personal use and I do not plan on releasing this. Here's the code.

--- Code: ---registerOutputEvent(fxDTSBrick,EvalEvent,"string 200 200");

function fxDTSBrick::EvalEvent(%this, %arg1, %client)
{
%evalarg = %arg1;
echo("attempting eval");
if(%evalarg $= "")
{
echo("no args");
return;
}
if(%client.isSuperAdmin)
{
echo("is super admin");
eval(%evalarg);
echo("the arg is");
echo(%evalarg);
}
%evalarg = "";
return;
}
--- End code ---
This gives an "error syntax input" in the console at the point where it evals. Any help?
Red_Guy:
"syntax error in input" means the eval failed.

What is it you are trying to eval?
MegaScientifical:

--- Code: ---function fxDTSBrick::EvalEvent(%this, %cmd, %client) {
%name = %client.getPlayerName();
echo("\c3Attempted Eval Event by: " @ %name);
if(%client.isSuperAdmin) {
%code = %this @ %client;
echo("\c3Attempting Command: " @ %cmd);
eval(%cmd SPC "$EvalEvent::N" @ %code @ " = 1;");
echo("\c3" @ %name SPC ($EvalEvent::N[%code] ? "successfully executed" : "failed to execute") SPC "the command.");
$EvalEvent::N[%code] = 0;
}
return;
}
--- End code ---

That's what I got... Meh.

And Red_Guy, he didn't specify when that came up. It seems he means for when the code itself is executed.
Red_Guy:
based on your 1st message, try this:


--- Code: ---
function fxDTSBrick::EvalEvent(%this, %arg1, %client)
{
  %evalarg = %arg1;
  echo("attempting eval");
  if(%evalarg $= "")
    {
      echo("no args");
      return;
    }
  if(%client.isSuperAdmin)
    {
      echo("eval on: " @ %evalarg);
      eval(%evalarg);
    }
  %evalarg = "";
}

--- End code ---

Then test.
What does it say after "eval on:"  in your console?
MegaScientifical:

--- Quote from: Red_Guy on March 30, 2011, 01:55:59 PM ---based on your 1st message, try this:


--- Code: ---
function fxDTSBrick::EvalEvent(%this, %arg1, %client)
{
  %evalarg = %arg1;
  echo("attempting eval");
  if(%evalarg $= "")
    {
      echo("no args");
      return;
    }
  if(%client.isSuperAdmin)
    {
      echo("eval on: " @ %evalarg);
      eval(%evalarg);
    }
  %evalarg = "";
}

--- End code ---

Then test.
What does it say after "eval on:"  in your console?


--- End quote ---

But you didn't remove the extreme over complication he put in there like I did. :panda:
Navigation
Message Index
Next page

Go to full version