fatty86 10 Posted July 22, 2009 (edited) 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 July 22, 2009 by fatty86 Share this post Link to post Share on other sites
rocket 9 Posted July 22, 2009 Have you ensured there is a ";" at the end of the if statement? Share this post Link to post Share on other sites
fatty86 10 Posted July 22, 2009 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
rocket 9 Posted July 22, 2009 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
fatty86 10 Posted July 22, 2009 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
Big Dawg KS 6 Posted July 22, 2009 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
Taurus 20 Posted July 22, 2009 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
Big Dawg KS 6 Posted July 22, 2009 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
Taurus 20 Posted July 22, 2009 (edited) 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] 700:th post! I'm such a spammer 0.25 posts per day. Edited July 22, 2009 by Taurus 700:th post anniversary Share this post Link to post Share on other sites
Big Dawg KS 6 Posted July 22, 2009 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