Jump to content
Sign in to follow this  
Helanger

Variables and IF statements

Recommended Posts

Hello everyone.

I'm starting to slowly get into Arma 3's editor and making missions, I used to do a few missions back in Arma 2OA but then I stopped playing the game for a good 2 years, I have unfortunately forgotten a lot.

I'm curious as to what I seem to be doing wrong with this script.

 

At the moment I'm working on a mission (this is just a part of it)

3 soldiers visit this area, you kill them and then you have to search their bodies. I want to make it so only after all 3 bodies are searched, the task updates.

 

I made it possible for this to work using the addaction feature and then linked it with a script I made on the missions directory, but now I'm in a bit of a situation.


This is the code I have right now
 

_per = _this select 0;  // Person who had the addAction
_ldr = _this select 1;  // Person who used the addAction
 
_ldr SwitchMove "AmovPercMstpSrasWrflDnon_AinvPercMstpSrasWrflDnon_Putdown";
Sleep 0.5;
removeAllActions _per; 
 
SearchCount +1;
 
if (SearchCount = 3) then [hint "IT WORKED!"];

Everything works perfect up to RemoveAllActions
But the count doesn't seem to go up and I keep getting the following error message displayed to me.
 
if (searchCount |#|= 3) then [hint "IT WORKED!"];
Error Missing )
 
what am I doing wrong here? I was trying to figured this out for ours and tried many different codes, but still getting issues. I cant seem to figure out what to do.
 

SearchCount +1;

Share this post


Link to post
Share on other sites

Hello everyone.

I'm starting to slowly get into Arma 3's editor and making missions, I used to do a few missions back in Arma 2OA but then I stopped playing the game for a good 2 years, I have unfortunately forgotten a lot.

I'm curious as to what I seem to be doing wrong with this script.

 

At the moment I'm working on a mission (this is just a part of it)

3 soldiers visit this area, you kill them and then you have to search their bodies. I want to make it so only after all 3 bodies are searched, the task updates.

 

I made it possible for this to work using the addaction feature and then linked it with a script I made on the missions directory, but now I'm in a bit of a situation.

This is the code I have right now

 

_per = _this select 0;  // Person who had the addAction
_ldr = _this select 1;  // Person who used the addAction
 
_ldr SwitchMove "AmovPercMstpSrasWrflDnon_AinvPercMstpSrasWrflDnon_Putdown";
Sleep 0.5;
removeAllActions _per; 
 
SearchCount +1;
 
if (SearchCount = 3) then [hint "IT WORKED!"];

Everything works perfect up to RemoveAllActions

But the count doesn't seem to go up and I keep getting the following error message displayed to me.
 
if (searchCount |#|= 3) then [hint "IT WORKED!"];
Error Missing )
 
what am I doing wrong here? I was trying to figured this out for ours and tried many different codes, but still getting issues. I cant seem to figure out what to do.
 

SearchCount +1;

 

try

 

 if (searchCount == 3) then [hint "IT WORKED!"];

  • Like 1

Share this post


Link to post
Share on other sites

searchcount + 1 is basically nothing else than a number, you don't add 1 to searchcount permanently:

searchcount = 0;
searchcount + 1;
systemchat str searchcount; //0
systemchat str (searchcount + 1); //1
searchcount + 1;
systemchat str searchcount; //0

Proper syntax would be:

searchcount = searchcount + 1;

Cheers

  • Like 1

Share this post


Link to post
Share on other sites

As previous posters have said, be careful about the following:

 

"=" is an assignment operator.  It does not compare anything, it assigns data to a variable.  "==" compares two variables to see if they are equal.  You would use "==" in something like an "if" statement or some other conditional statement, wheras "=" is pretty much only used to assign data to a variable.  

 

Unlike some other languages, in ArmA you need to put "_variable = _variable + 1;" if you want to increment a variable.  "_variable + 1;" returns the value of _variable + 1, but if you do not assign it to anything with the "=" operator then that bit of code ("_variable + 1;") essentially does nothing besides calculate the value and then discard it,

  • Like 1

Share this post


Link to post
Share on other sites

Also be careful with removeAllActions as that can also affect actions added by other scripts, mods or similar.

Its better to save the IDs for the actions you create and delete them directly.

  • Like 2

Share this post


Link to post
Share on other sites

Guys I got it to work, finally, thank you so much for all the help :)

Share this post


Link to post
Share on other sites

One more question, I want to make it so after the 3 bodies are searched, an objective completes.

Is there any way I can activate a trigger VIA the SQF or make the objective complete itself through it?

 

EDIT: Never mind, I figured it out. I added the Variable SearchCount==3 to the condition in a trigger ingame and it worked :D

Share this post


Link to post
Share on other sites

As a suggestion perhaps change your thread title so it means more, as if another user has you issue they maybe to use your fix if the title was more appropriate. ;) 

  • Like 2

Share this post


Link to post
Share on other sites

Seeing I cant create my own post for some reason I will ask it here, hope thats alright:

 

I have a trigger, set to WHOLE GROUP, trigger owned to the group leader. When I launch the scenario from the editor in SP, the trigger waits with firing untill the whole group is inside.

 

But when I export the mission to SP, and launch it from there, the trigger fires when the group leader gets inside and does not react to the rest of the group... Am I doing something wrong? I am using the 3den enhanced, could that have anything to do with it?

 

Greets,

Tikas

  • Like 1

Share this post


Link to post
Share on other sites

Seeing I cant create my own post for some reason I will ask it here, hope thats alright:

 

I have a trigger, set to WHOLE GROUP, trigger owned to the group leader. When I launch the scenario from the editor in SP, the trigger waits with firing untill the whole group is inside.

 

But when I export the mission to SP, and launch it from there, the trigger fires when the group leader gets inside and does not react to the rest of the group... Am I doing something wrong? I am using the 3den enhanced, could that have anything to do with it?

 

Greets,

Tikas

Hello Tikas, I'm a newbie at the site too, in order for you to create your own post you have to reply to other people's posts first, It was only until recently that I was able to set up this post.

As to your question I too am unsure as to what is happening, so the trigger works perfect in the Editor but when Exported it acts differently. I am not so certain about what may be causing that, I am but a Newbie myself :P

But I don't think 3den Enhanced has anything to do with it, I use it myself and I haven't come across any issues.

  • Like 1

Share this post


Link to post
Share on other sites

As a suggestion perhaps change your thread title so it means more, as if another user has you issue they maybe to use your fix if the title was more appropriate. ;)

I'll do that, thanks for the advice R0adki11 :)

I gotta figure out how to do it first :P I'm such a noob when it comes to forums I'm sorry XD

 

I found it lol.

Share this post


Link to post
Share on other sites

Hello Tikas, I'm a newbie at the site too, in order for you to create your own post you have to reply to other people's posts first, It was only until recently that I was able to set up this post.

As to your question I too am unsure as to what is happening, so the trigger works perfect in the Editor but when Exported it acts differently. I am not so certain about what may be causing that, I am but a Newbie myself :P

But I don't think 3den Enhanced has anything to do with it, I use it myself and I haven't come across any issues.

Exactly this. It reacts the way it should if I launch from the editor, it does not once I export, either SP or MP...

 

And thanks for the info, shouldve read the Rules first ofcourse ;-)

 

Does anyone have the same problem as I do? This is really weird...

 

------------------------------ Edit ----------------------------------

 

Is it mayby because I did not make the other group members trigger owners, but just the group leader? (not sure if there can be more then 1 trigger owner? Never needed it before)

Share this post


Link to post
Share on other sites

Exactly this. It reacts the way it should if I launch from the editor, it does not once I export, either SP or MP...

 

And thanks for the info, shouldve read the Rules first ofcourse ;-)

 

Does anyone have the same problem as I do? This is really weird...

 

------------------------------ Edit ----------------------------------

 

Is it mayby because I did not make the other group members trigger owners, but just the group leader? (not sure if there can be more then 1 trigger owner? Never needed it before)

From experience, I think you can only set one unit as a Trigger Owner but you can modify the trigger so that It's affected by other members of the Group you're in.

Maybe this is where your problem may be coming from?

Share this post


Link to post
Share on other sites

From experience, I think you can only set one unit as a Trigger Owner but you can modify the trigger so that It's affected by other members of the Group you're in.

Maybe this is where your problem may be coming from?

Ah, no, then I have done it how its supposed too be, group leader is trigger owner, set it to WHOLE GROUP. It reacts perfectly when launched from the editor, but once exported, it only fires when the group leader enters the trigger... Im perplexed, this has never happened before

 

---------- edit ---------

 

The only other thing I can think of is that for each member in the group, I use this in their init:

 

Inis = group this;

 

Not sure if this messes with the group structure or w/e, and now looking at that code I suspect I only have to use it in the group leaders unit, because group this will add the whole group as an array to the variable Inis?

Share this post


Link to post
Share on other sites

Apologies for tagging this question on to this thread, but like others above I'm new and can't create a separate topic yet. I'm an absolute beginner at the Eden editor and scripting, so I'll apologise in advance if I've made any really obvious errors  :)

 

OK, so what I want to achieve is to activate a task when the player picks up an item of intel. I have the following script set as the "init" for the intel item:
 
this setVariable ["RscAttributeDiaryRecord_texture","a3\structures_f_epc\Items\Documents\Data\document_secret_01_co.paa", true]; [this,"RscAttributeDiaryRecord",["Top Secret Docs","<br />These are the documents we've been looking for!.<execute expression=""player setVariable ['found_evidence' = true]; openMap false""><br />Review Documents<br /></execute>",""]] call bis_fnc_setServerVariable
 
If I'm reading this correctly when the player picks up the item the variable "found_evidence" should be set to true?
 
What I then want to do is to have a flag synced with the relevant "set task state - succeeded" using that same variable. At the moment I have a trigger synced to the "set task state - successful" and the trigger condition as "player getVariable["found_evidence", true]"
 
For some reason this isn't working and as soon as the mission begins the task is set as succeeded. What am I doing wrong???  :huh:

Share this post


Link to post
Share on other sites

I wanted to ask a question about the original question the search count +1 I am not seeing where the +1 has to equal three before the task updates or says it worked Yes I see the hint but I am not seeing in the code where search count has to equal 3??

Share this post


Link to post
Share on other sites

I wanted to ask a question about the original question the search count +1 I am not seeing where the +1 has to equal three before the task updates or says it worked Yes I see the hint but I am not seeing in the code where search count has to equal 3??

if (SearchCount == 3) then {hint "IT WORKED!";};

this line throws the hint if searchcount is equal to 3

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  

×