Jump to content
Nope.X

There'S a weird error in my script it says: Error Missing ;

Recommended Posts

Hello there,

as the title already states my script is missing a semicolon but my 2 friends couldn't figure out where it was missing and neither could I.
The following is the code:

run = true;

task_1 = player createSimpleTask ["Kill Bob"];
	task_1 setSimpleTaskDescription ["Kill Bob that stupid prick","Kill Bob"];
	task_1 setSimpleTaskDestination (getPos bob);
	task_1 setSimpleTaskType "attack";
	player setCurrentTask task_1;


while (run){
	if (alive bob) then{
		hint "Bob is dead";
		task_1 setTaskState "Succeeded";
		run = false;
	};
};

The error says it missing in the same line in which I start my while loop.
Quick sidenote this script is just something I created to learn to script for missions.

 

I also have another question because I want to be able to execute this script from my main script how do I do that because I couldn't get execVM to work and how can I check within the main script wether task_1 is finished and then start task_2?

Thanks for your help

 

Cheers,
Nope.X

Share this post


Link to post
Share on other sites

As you already noticed, the error is in the line where the while loop starts.

While loop condition requires curly brackets instead of round ones.

That's the error.

 

Also I'd add a sleep inside the while loop, alternatively you can completely replace the while loop with a killed eventhandler.

 

Cheers

  • Like 1

Share this post


Link to post
Share on other sites

@Grumpy Old Man
How do I use the killed event handler? Is it in the list of all the commands?

 

Would the following be correct?
 

while (run) do{
	if (!alive bob) then{
		hint "Bob is dead";
		task_1 setTaskState "Succeeded";
		run = false;
	};
};

Or do I also need to change the brackets around the "run" for curly brackets?

 

Cheers

Share this post


Link to post
Share on other sites
8 hours ago, Nope.X said:

@Grumpy Old Man
How do I use the killed event handler? Is it in the list of all the commands?

 

Could be as simple as:

bob addEventHandler ["Killed",{
	hint "Bob is dead";
	task_1 setTaskState "Succeeded";
}];

 

8 hours ago, Nope.X said:

Would the following be correct?
 


while (run) do{
	if (!alive bob) then{
		hint "Bob is dead";
		task_1 setTaskState "Succeeded";
		run = false;
	};
};

Or do I also need to change the brackets around the "run" for curly brackets?

As stated above, the condition needs to be inside curly brackets.

Just take a quick look at the wiki which was also linked by @sarogahtyp,

provides proper syntax and alternate syntax for various commands.

 

Those error messages can be confusing at first until you learn how to interpret them,

simply check the line the error occurs in, go through all commands from that line, check for proper syntax and proper parameters, most of the time you'll find the error, heh.

 

I also recommend some dedicated program to write .sqf script in, notepad++ with .sqf syntax is frequently used.

Personally I'm using poseidon which is made and maintained by a BI dev and a real swiss army knife for .sqf.

 

To learn scripting you can go through Mr. Murrays guide, which was made for A2 but still holds true in A3.

 

Cheers

  • Like 2
  • Thanks 1

Share this post


Link to post
Share on other sites

@Grumpy Old Man

Sorry for not reading everything that you've sent.

Thanks for the answers and the links to guides.

I just have one last question:
Is it possible to have the main script check in my task_1 script whether the task is finished or not, or do I just need to recreate the loop in the task_1 script?

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

×