OFPEC Forum
Editors Depot - Mission Editing and Scripting => Arma2 - Editing/Scripting General => Topic started by: aLlamaWithARifle on 16 Aug 2011, 01:13:28
-
I have a mission where I have an optional objective that may or may not appear depending on how the mission happens.
If the objective does get created but the player chooses not to do it then I set the task as Cancelled but if the objective does not get activated the objective still gets set as cancelled but I get an error since the objective is an undefined variable because I create the objective if it's needed.
How do I check if the optional objective has not been created and if so skip the line that changes it to cancelled... I'm not great with this whole .sqf editing method, would be easy in .sqs but I'm trying to get with the times and learn :D
Speaking of which is there a guide to .sqf editing anywhere?
Cheers.
-
There's no hidden objectives anymore, just objectives you haven't added yet. If you have something that's optional and you don't want appearing from the start, just check for whatever condition you want, then add it at that time and set it to succeeded.
My website (http://www.kylania.com/ex) has many SQF tricks and tips and a link to a nice guide about the syntax of SQF in the top right corner.
-
The easiest method is to make sure the objective is defined using a global variable, and then when you're doing the "set as cancelled" thing, simply check beforehand if the global variable has been defined or not, as so:
//your task-making script:
Your_Task1 = player createSimpleTast ["Taskely-task"];
//your set-to-cancelled script:
if (isNil "Your_Task1") then {hint "No such task!"} else {Your_Task1 setaTaskState "Cancelled"};
:good: Should work.
Wolfrug out.
-
@Pirin
Wasn't quite what I was asking but I will definitely take a look at your website :good:
@Wolfrug
Works perfectly, thanks a lot apart from your misspelling of setTaskState :D
Cheers, topic solved