Blockland Forums > Modification Help
My scripting problems: 0
<< < (8/14) > >>
Placid:

--- Quote from: Sammygood on June 01, 2010, 12:19:50 PM ---3.Is there a problem with this script? :

--- Code: ---//Adding

function ServerCmdAdd(%client, %a1, %a2)
{
    %aanswer = %a1 + %a2;
    messageClient(%client, '', %a1" add "%a2 "=" %aanswer);
}

//Subtracting

function ServerCmdSubtract(%client, %b1, %b2)
{
    %Banswer = %b1 - %b2;
    messageClient(%client, '', %b1" subtract "%b2 "=" %banswer);
}

//Dividing

function ServerCmdDivide(%client, %c1, %c2)
{
    %canswer = %c1 + %c2;
    messageClient(%client, '', %c1" add "%c2 "=" %canswer);
}

//Multiplying

function ServerCmdMultiply(%client, %d1, %d2)
{
    %danswer = %d1 * %d2;
    messageClient(%client, '', %d1" times "%d2 "=" %dAnswer);
}

--- End code ---

--- End quote ---

Should work.

Also, there's no need to define each variable as %a1 or %b1 or %aanswer and %banswer. Those variables end after the function, and therefore you could have them all like, %a1 %a2 %answer.
heedicalking:

--- Quote from: Sammygood on June 01, 2010, 12:19:50 PM ---3.Is there a problem with this script? :

--- Code: ---//Adding

function ServerCmdAdd(%client, %a1, %a2)

{
%aanswer = %a1 + %a2;
messageClient(%client, '', %a1" add "%a2 "=" %aanswer);
}

//Subtracting

function ServerCmdSubtract(%client, %b1, %b2)

{
%Banswer = %b1 - %b2;
messageClient(%client, '', %b1" subtract "%b2 "=" %banswer);
}

//Dividing

function ServerCmdDivide(%client, %c1, %c2)

{
%canswer = %c1 + %c2;
messageClient(%client, '', %c1" add "%c2 "=" %canswer);
}

//Multiplying

function ServerCmdMultiply(%client, %d1, %d2)

{
%danswer = %d1 * %d2;
messageClient(%client, '', %d1" times "%d2 "=" %dAnswer);
}


--- End code ---


Thanks in advance to anybody who helps.

--- End quote ---
Yes, dividing has the adding sign.
Sammygood:
I see. The thing that didn't work was when i typed anything: /add 1 2, /multiply 6 7. Any ideas?
heedicalking:

--- Quote from: Sammygood on June 06, 2010, 02:50:01 PM ---I see. The thing that didn't work was when i typed anything: /add 1 2, /multiply 6 7. Any ideas?

--- End quote ---
The messageclient is wrong I think.
Sammygood:
How so?

Edit: I think you are right, because the console at that time showed errors in the messageClient line. Here's the console:


--- Code: ---==>exec("config/Test.cs");
config/Test.cs Line: 9 - Syntax error.
>>> Some error context, with ## on sides of error halt:
/exec("config/Test.cs");



//Adding



function ServerCmdAdd(%client, %a1, %a2)



{

%aanswer = %a1 + %a2;

messageClient(%client, '', %a1" add "## ##%a2 "=" %aanswer);

}



//Subtracting



function ServerCmdSubtract(%client, %b1, %b2)



{

%Banswer = %b1 - %b2;

messageClient(%client, '', %b1" subtract "%b2 "=" %banswer);

}



//Dividing



function ServerCmdDivide(%client, %c1, %c2)



{

%canswer = %c1 / %c2;
>>> Error report complete.

Executing config/Test.cs.
config/Test.cs Line: 9 - Syntax error.
>>> Some error context, with ## on sides of error halt:
/exec("config/Test.cs");



//Adding



function ServerCmdAdd(%client, %a1, %a2)



{

%aanswer = %a1 + %a2;

messageClient(%client, '', %a1" add "## ##%a2 "=" %aanswer);

}



//Subtracting



function ServerCmdSubtract(%client, %b1, %b2)



{

%Banswer = %b1 - %b2;

messageClient(%client, '', %b1" subtract "%b2 "=" %banswer);

}



//Dividing



function ServerCmdDivide(%client, %c1, %c2)



{

%canswer = %c1 / %c2;
>>> Error report complete.
--- End code ---
Navigation
Message Index
Next page
Previous page

Go to full version