Forum Jump :

Author Message


Posts: 14
Rank:


Level: Member

Country: es
Location:
Occupation:
Age:
In-game name:

 
#1 Posted at 2016-05-19 20:11        
     
Hello,

i wonder how this is made. Actually i making a mission in where you have to detect several objectives within an area with a UAV. Problem is i have not been able to do so.

The nearest solution i found was this one:

https://forums.bistudio.com/topic/147758-detection-script-help-detected-by-trigger-not-working/

->Posted in 2013:
playerdetected=false;{if ((_x knowsabout Player) > 1.49) then { playerdetected=true } } foreach (units group1); playerdetected

which does not seem to work. (I change Player with the unit variable name i want, and group1 with my group number, but nothing happens.)

Does someone know a way?

Thanks.


Author Message


Posts: 1589
Rank:


Level: Member

Country: pf
Location: Tahiti
Occupation: too many Arma
Age: 57
In-game name: Kobayashi Maru

 
#2 Posted at 2016-05-19 21:06        
     
what's your code? It's easier to help with a good wording and THE code.

PLEASE CONTACT ME ON BI FORUMS FOR ANY SCRIPT / MOD QUESTION. TKS

Advertisement


Author Message


Posts: 14
Rank:


Level: Member

Country: es
Location:
Occupation:
Age:
In-game name:

 
#3 Posted at 2016-05-19 21:51        
     
I have tried different codes.

For example (in object->init, variable name:
Unit name-> A
My team name-> t1
target unit name-> B


unitdetected=false;{if ((_x knowsabout B) > 1.49) then { unitdetected=true } } foreach (units t1); unitdetected

(This last, i just tried looking at arma 3 commands, but result is the same, trigger never activates.)




_know = (A targetKnowledge B) select 1;

I am totally knew at scripting with arma, so i do not know what am i doing wrong.

Edit:There is something really weird. I just tried this as "debugger":
posError = (A targetKnowledge B )select 1; if (posError) then {hint "Yes"} else {hint "No"};

And it works as intended (whenever i see enemy it starts telling me 'Yes', otherwhise 'No'.
When i place only 'true' in the trigger it always works (as it should be).

Problem is that when i only use that script without 'the hint' thing, it simply does not work (when it is returning true). How to solve that?

Oh my goodness.... i came up with the solution.
posError = (A targetKnowledge B )select 1 turns to
(A targetKnowledge B )select 1 and it is solved. It seems that an assignment simply makes the trigger not work.

This post was edited by Maiser (2016-05-19 23:16, 520 days ago)


Author Message


Posts: 1589
Rank:


Level: Member

Country: pf
Location: Tahiti
Occupation: too many Arma
Age: 57
In-game name: Kobayashi Maru

 
#4 Posted at 2016-05-20 00:10        
     
If you're speaking about trigger, the condition field must return a boolean "true" or "false". That means you can't code something returning a variable (not boolean) here.

In on act. field, you must return... nothing. That means you can write any function returning nothing. The most popular example is a script spawned like this:
0 = [] spawn {<some code here>}

What does that mean for your case:
In condition field, you can write something like:
(A targetKnowledge B) select 1 > 1.4
or even:
{_x knowsabout Player) > 1.49} count units group1 > 0
In both cases, it's a comparison between 2 figures (1st one a target knowledge, 2nd one a count for units knowing about B presence). Both returns true or false.

But you can also erase all in condition field in order to make an "unconditional" trigger (always activated) and throw you condition in the on act. field, in the spawned code, like this:
0 = [] spawn {
  waitUntil {  {_x knowsabout Player) > 1.49} count units group1 > 0 };
  < code what you want here, or execVM an sqf... >;
}
Never comment your code in a trigger (or console). It'll stop and return an error.

PLEASE CONTACT ME ON BI FORUMS FOR ANY SCRIPT / MOD QUESTION. TKS