Author Topic: My scripting problems: 0  (Read 4269 times)

I am trying to make it when you say /count (mins here). The only way i can......AHA, I got it. Arguments:

function Count(%c, %mins)

That work?


Updated. Temporarily no problems.

The "toggletest" variable should be a global ($toggletest) not a local (%toggletest) otherwise it's reset to "" counted as 0 whenever the function is called and it'll always turn on, never off.
Oh right.
As it is something server wide, it should be, yes.

I see, yes it should.


3.Is there a problem with this script? :
Code: [Select]
//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);
}

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.

3.Is there a problem with this script? :
Code: [Select]
//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);
}



Thanks in advance to anybody who helps.
Yes, dividing has the adding sign.

I see. The thing that didn't work was when i typed anything: /add 1 2, /multiply 6 7. Any ideas?

I see. The thing that didn't work was when i typed anything: /add 1 2, /multiply 6 7. Any ideas?
The messageclient is wrong I think.

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: [Select]
==>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.
« Last Edit: June 06, 2010, 03:17:02 PM by Sammygood »


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

{
%aanswer = %a1 + %a2;
messageClient(%client, '', %a1 @ " add " @ %a2 @ " = " @ %aanswer);
}
@ signs between variable and the quotes. Do this for all of them.

@ signs between variable and the quotes. Do this for all of them.
aa i'm stupid

Also, i think you might need the %a1 and %a2 before the %client.. :s

aa i'm stupid

Also, i think you might need the %a1 and %a2 before the %client.. :s
In a servercmd, the first variable is always the client if I'm not to rusted up in the head.

In a servercmd, the first variable is always the client if I'm not to rusted up in the head.
alrighty. I'm not that experienced with scripting, so I just try to learn from others. Thanks for the clarification.