Jump to content
Sign in to follow this  
fatty86

Broken isServer check?

Recommended Posts

Guys, I have a script to simulate a very basic cruise missile attack on a gamelogic named bombdest. I have a check "isServer" to make sure that multiple missiles are not spawned on a dedicated server. Here is the script:

if (isServer) then {

HQ=[West,"HQ"];

HQ SideChat "First squad, CROSSROAD. Understand you have good fix on insurgent depot, nice work.";

sleep 5;

HQ SideChat "Missile is on the way. Pull back to a safe location. CROSSROAD out.";

sleep 5;

missile = "CruiseMissile2" createVehicle getPos bombdest;

missile setpos [getPos bombdest select 0, getPos bombdest select 1, (getPos bombdest select 2) +1000];

missile setvelocity (0,0,-400);

}

This fails to work in the editor or on dedicated testing. If I change the (isServer) to !(isServer) it also fails.

If I comment out the isServer check, it works great.

If I put commands before the isServer check they are executed properly in my tests.

So what is going on?

Edited by fatty86

Share this post


Link to post
Share on other sites

Have you ensured there is a ";" at the end of the if statement?

Share this post


Link to post
Share on other sites
Have you ensured there is a ";" at the end of the if statement?

No; I thought that was unnecessary for an open bracket. So should it be something like:

if (isServer) then {;

Thanks for your help :)

Share this post


Link to post
Share on other sites

Make sure its:

if (isServer) then {

HQ=[West,"HQ"];

HQ SideChat "First squad, CROSSROAD. Understand you have good fix on insurgent depot, nice work.";

sleep 5;

HQ SideChat "Missile is on the way. Pull back to a safe location. CROSSROAD out.";

sleep 5;

missile = "CruiseMissile2" createVehicle getPos bombdest;

missile setpos [getPos bombdest select 0, getPos bombdest select 1, (getPos bombdest select 2) +1000];

missile setvelocity (0,0,-400);

};

And see if that works :)

One thing I have noticed, is that ArmA2 seems to just carry on after code errors, so sometimes I haven't noticed small code formatting issues. ArmA was very obvious if you had screwed up some code formatting.

---------- Post added at 02:33 PM ---------- Previous post was at 02:31 PM ----------

Also, setVelocity should be in square brackets ie:

missile setvelocity [0,0,-400];

Share this post


Link to post
Share on other sites

Oh yeah, I had the semicolon on the close bracket, just lost it in the copy and paste.

But bingo on the square brackets. Changing them seemed to fix it. Thanks a mil.

Share this post


Link to post
Share on other sites
One thing I have noticed, is that ArmA2 seems to just carry on after code errors

I also noticed that when it encounters errors inside an if block for example, it tends to skip that whole block (which might explain this behaviour).

Share this post


Link to post
Share on other sites
I also noticed that when it encounters errors inside an if block for example, it tends to skip that whole block (which might explain this behaviour).

Not related to missing ; but to errors.

Where did the in-game pop-up UI from ArmA go when you had errors in your scripts?

Only way now to find out that something went wrong is the obvious "nothing happened" and look in the RPT log.

Share this post


Link to post
Share on other sites
Where did the in-game pop-up UI from ArmA go when you had errors in your scripts?

Yes, I am sad to see this go. I know some people prefer to not have all the errors "thrown in their face" (to quote one of them), but it saves a lot of time and effort IMO. Perhaps BIS should (in a patch) allow us to reenable it via a startup parameter?

Share this post


Link to post
Share on other sites

Thrown in their faces?

Allow me to LOL.

fatty86 here would have known directly what his problem was if BIS did not remove that nice debugging feature.

all scripts which were compiled with either preprocessFile or preprocessFileLineNumbers would state where in your code the error was, and the latter would even tell the line number...

Talking about throwing:

http://community.bistudio.com/wiki/Exception_handling

To bad that try-catch blocks as they do in other scripting languages.

And as far as my experience go you should try to avoid your code to throw any errors.

The example stated in that wiki document makes no sense to me.

NVM.

the .exe flag:

-dev

?

derailing topic now, sorry.

[edit]

:yay:

700:th post!

I'm such a spammer 0.25 posts per day.

Edited by Taurus
700:th post anniversary

Share this post


Link to post
Share on other sites

Yea, I don't think exception handling really applies much to the nature of scripting in ArmA. Perhaps somone will find good use for it though.

the .exe flag:

-dev

?

Should PM Suma, or open a feature request on dev-heaven.

Share this post


Link to post
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
Sign in to follow this  

×