Home   Help Search Login Register  

Author Topic: Hidden objective error...  (Read 1728 times)

0 Members and 1 Guest are viewing this topic.

Hidden objective error...
« 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.

Offline Pirin

  • Members
  • *
Re: Hidden objective error...
« Reply #1 on: 16 Aug 2011, 05:22:06 »
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 has many SQF tricks and tips and a link to a nice guide about the syntax of SQF in the top right corner.

Offline Wolfrug

  • Addons Depot
  • Former Staff
  • ****
  • Official OFPEC Old Timer
Re: Hidden objective error...
« Reply #2 on: 16 Aug 2011, 07:53:47 »
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:

Code: [Select]
//your task-making script:
Your_Task1 = player createSimpleTast ["Taskely-task"];

//your set-to-cancelled script:

Code: [Select]
if (isNil "Your_Task1") then {hint "No such task!"} else {Your_Task1 setaTaskState "Cancelled"};
 :good: Should work.

Wolfrug out.

"When 900 years YOU reach, look as good you will not!"

Re: Hidden objective error...
« Reply #3 on: 16 Aug 2011, 22:51:23 »
@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