PDA

View Full Version : Pop-Up Targets (Firing Range)



Grimes [3rd ID]
Jul 18 2009, 23:54
I do apologize for making yet another thread related to Pop Up targets, but I am yet to find what I am looking for.

I am working on a training camp for the realism unit that I am in. It includes multiple things, including a firing range. Right now the range is just a bunch of spread out targets from 50 to 700 meters out that fall when you hit them, then they come back up a couple seconds later. If anyone here has played the America's Army 3 Marksmanship Qualification course, that is what I am looking for. For those of you who haven't, I want to be able to make the red targets not only fall when hit, but also fall if it isn't hit within a certain amount of time, then pop back up after a certain amount of time, then continue the cycle endlessly. If anyone can help me, please reply in this thread or catch me on xfire: rrkiller789 . Thank you!

-SPC KC Grimes,
3/1-15/K/1/1/1

F2k Sel
Jul 19 2009, 20:21
There are several scripts around but this is one someone else started and I added some scoring which may not be 100% right.

I think it's popping up a target that doesn't exist, see if you can fix it.


//////////////////////////////////////////////////////////////////
// How to use.
// 1. Place a popup target and name it to pt1
// 2. copy it 8 times and it will auto name the targets
// 3. place this line in a trigger or init nul=[] execVM "popup.sqf"

_inc = 0;
_count = 0;
_targets = [pt1,pt1_1, pt1_2, pt1_3, pt1_4, pt1_5, pt1_6, pt1_7];
_many = count _targets;
nopop=true;
{_x animate["terc",1]} forEach _targets;

hint "Setting up the Range";
sleep 2;
hint "Ready";
sleep 2;


while {_inc<20} do
{
_rnumber = random _many-1;
_rtarget = _targets select _rnumber;
_rtarget animate["terc", 0];
sleep 3;
if (_rtarget animationPhase "terc" > 0.1) then
{
_count = _count+1;
};
hint format ["Targets :%1 Hit :%2",_inc+1,_count];
_rtarget animate["terc", 1];
_inc = _inc + 1;
};
sleep 8;
hint "Session Complete";

Grimes [3rd ID]
Jul 19 2009, 22:28
Thanks for the reply. I do not know much about triggers and modules yet (still working on that), so what is the trigger in that script? How do I start this?

F2k Sel
Jul 20 2009, 01:11
Past this in one of the popup targets
nul=[] execVM "popup.sqf" and name the targets
pt1,pt1_1, pt1_2, pt1_3, pt1_4, pt1_5, pt1_6, pt1_7 just like that.

Grimes [3rd ID]
Jul 20 2009, 04:45
It works perfectly. Thank you very much! I haven't experienced it popping up any non-existent target's though.

Schilly
Jul 20 2009, 13:53
This is the same script I am using (although I modified mine a bit) but it works well. Thanks mate!

Grimes [3rd ID]
Jul 21 2009, 18:31
So, this script is working great, I just had 4 questions :P

1. Is there a way to get the targets to start down instead of up at the start of the session? It's just kind of confusing when it says "Begin!" and then 3 targets pop up, but they don't count. So if they could fall down instead of pop up at the start, that would be awesome.

2. At each hint and each change of the set of targets there is a VERY loud bleeping/pinging sound. Any idea as to how to get rid of that or lower the volume?

3. When the targets sets are switching, all of the targets flip up and down rapidily a couple times, then are either up or down but still random. Any idea how to fix this? Or is it just lag?

4. This part is pretty much optional. The map I have is a full training camp with many things on it. Is there a way to set up a trigger that activates this qualification script below? It's fine how it is, but it is just really annoying to have to end the map, switch out the scripts, then start it again with everyone redownloading and reloading. In the Single Player shooting range in BCT it is started on a trigger it seems, or some script. Anyone have any idea as to how to do that?


Here's my popup.sqf script for Pistol Qualification:


_inc = 0;
_count = 0;
_targets = [pt5, pt5_1, pt5_2];
_many = count _targets;
nopop=true;
{_x animate["terc",1]} forEach _targets;

sleep 10;
hint "Please wait until everyone loads the map";
sleep 20;
hint "Welcome to Camp Marne's Live Fire Pistol Qualification Range";
sleep 5;
hint "Setting up the Range";
sleep 3;
hint "The Qualification Course will begin in 10 Seconds";
sleep 2;
hint "The Qualification Course will begin in 8 Seconds";
sleep 2;
hint "The Qualification Course will begin in 6 Seconds";
sleep 2;
hint "The Qualification Course will begin in 4 Seconds";
sleep 2;
hint "The Qualification Course will begin in 2 Seconds";
sleep 2;
hint "Begin!";

while {_inc<10} do
{
_rnumber = random _many-1;
_rtarget = _targets select _rnumber;
_rtarget animate["terc", 0];
sleep 5;
if (_rtarget animationPhase "terc" > 0.1) then
{
_count = _count+1;
};
hint format ["Targets :%1 Hit :%2",_inc+1,_count];
_rtarget animate["terc", 1];
_inc = _inc + 1;
};
sleep 5;
hint "Qualification complete! See your CO for score and debriefing.";

Thanks for putting up with me. :)

F2k Sel
Jul 21 2009, 19:01
1. All I can think of is putting this code in the Init Box of each target, then they'll go down as they're created .
this animate["terc",1]

2. You can make the Hint silent ie HintSilent and then the text or use Sidechat I think.

3. If your trying to use it for multi player then I believe you need to add a couple of lines of script, I haven't any experience yet so you'll have to search around for that.

4. If your currently calling the code from an Init Box then just copy that line to a trigger and place it in the on Act box and set the trigger up to anyone present.

Grimes [3rd ID]
Jul 21 2009, 19:30
Ah, now I see what you mean by it not counting properly. I want to have 5 targets for the pistol range. Is there a way I can choose how many targets pop up each set? And is there a way to have the counter count the number of targets hit/miss, not set?

F2k Sel
Jul 21 2009, 20:07
You could just copy and rename the script and change the target names but that would require two different ranges.

If you want to keep to one script you could lay down the max number of targets and then pass a variable to replace the
_many = count _targets; with the number of targets you want to popup.

If you had 8 max targets changing many to 3 would result in the first 3 targets working, if it was 5 then the first 5 would popup ect.


I haven't tested it so it may or may not work.

As for the last part of the question I don't really understand it.

Grimes [3rd ID]
Jul 21 2009, 21:21
if (_rtarget animationPhase "terc" > 0.1) then


This line is what starts the 'Count' part of the scoring. '_rtarget' is a random target. So if 3 targets popped up, only 1 of them would actually be scored if you hit it. You don't know which one because it is random. It's like a range with 3 targets but only 1 matters, so it only counts one for hits and misses. What I want to do is have a script that adds 3 to 'Count' if 3 targets pop up, not just 1. So the scoring system with your current script is only scoring one target, and I need it to score all of them, but on the same scoreboard.

F2k Sel
Jul 21 2009, 23:00
The only way I can think of would be to scrap the current scoring system and try eventhandlers they can detect a bullet hit.

I did get that far but I couldn't manage to get a result out of it.

I do think I found the bug in the current scoring system, I believe the numbers work better when converted to whole numbers.

You need to change some of the code.


_rnumber = random _many;
_int = _rnumber%1;
_rnumber = _rnumber-_int;
_rtarget = _targets select _rnumber;

Grimes [3rd ID]
Jul 21 2009, 23:30
Didn't work :( Not sure about eventhandlers. How far did you get? Guide me to where you are and then I'll mess with it.

F2k Sel
Jul 21 2009, 23:51
I'm still using the original code with the random number fix which hasn't messed up yet for me.

The eventhandler will post a hint telling you it was hit but I haven't found a way if scoring it.

I did try
_rtarget addEventHandler ["hit", {hint "Hit Target";_count=_count+1;}];

It doesn't through an error but won't return the count.



//////////////////////////////////////////////////////////////////
// Function file for Armed Assault
// Created by: TODO: Author Name
//////////////////////////////////////////////////////////////////
// How to use.
// 1. Place a popup target and name it to pt1
// 2. copy it 8 times and it will auto name the targets
// 3. place this line in a trigger or init nul=[] execVM "popup.sqf"

_inc = 0;
_count = 0;
_targets = [pt1,pt1_1, pt1_2, pt1_3, pt1_4, pt1_5, pt1_6, pt1_7];
_many = count _targets;
nopop=true;
{_x animate["terc",1]} forEach _targets;

hint "Setting up the Range";
sleep 2;
hint "Ready";
sleep 2;


while {_inc<20} do
{
_rnumber = random _many;
_int = _rnumber%1;
_rnumber = _rnumber-_int;
_rtarget = _targets select _rnumber;
_rtarget animate["terc", 0];


_rtarget addEventHandler ["hit", {hint "Hit Target";}];
sleep 3;
//if (_rtarget animationPhase "terc" > 0.1) then
//{
//_count = _count+1;
//};
hint format ["Targets :%1 Hit :%2",_inc+1,_count];
_rtarget removeEventHandler ["hit", 0];
_rtarget animate["terc", 1];
_inc = _inc + 1;
};
sleep 8;
hint "Session Complete";

Grimes [3rd ID]
Jul 22 2009, 00:17
Alright, thanks. For now I just removed the hint format part that displays the scoreboard. I'll just get the people to count hits and misses, no big deal. I'll still mess around with this though, if you'll continue to help as well. Anyone else is welcome to chip in ;)

OConnell [3rd ID]
Jul 22 2009, 01:24
I'm a java programmer and know little about the syntax in this language but I will offer my help. I am not too sure how your event handler works and all but if it can tell if the target is hit, it should have some sort of return value attached to it so you can tell that it did indeed get hit with in your code.

If the event handler can tell you if it was hit, then can't you increment a number every time it says hit?

pseudo code: (riding on the fact that there is a return value for the event handler)

_numHits = 0;
_numMissed = 0;

_isHit = _rtarget removeEventHandler ["hit", 0];

if(_isHit == 1)
_numHits++;
else
_numMissed++;

F2k Sel
Jul 22 2009, 01:56
Cheers.

I tried something close to that and have just tried what you suggest but without any luck the return value seems isn't working. It may be a dimension although when I try and access it I get errors.

Schilly
Jul 22 2009, 03:14
//////////////////////////////////////////////////////////////////
// How to use.
// 1. Place a popup target and name it to pt1
// 2. copy it 8 times and it will auto name the targets
// 3. place this line in a trigger or init nul=[] execVM "popup.sqf"

_inc = 0;
_count = 0;
_targets = [pt1,pt1_1, pt1_2, pt1_3, pt1_4, pt1_5, pt1_6, pt1_7];
_many = count _targets;
nopop=true;
{_x animate["terc",1]} forEach _targets;

hint "Setting up the Range";
sleep 2;
hint "Ready";
sleep 2;


while {_inc<20} do
{
_rnumber = random _many-1;
_rtarget = _targets select _rnumber;
_rtarget animate["terc", 0];
sleep 3;
if (_rtarget animationPhase "terc" > 0.1) then
{
_count = _count+1;
};
hint format ["Targets :%1 Hit :%2",_inc+1,_count];
_rtarget animate["terc", 1];
_inc = _inc + 1;
};
sleep 8;
hint "Session Complete";


That is the original script... And it is working for me perfectly... I don't know what the problem is with your as to why it's not counting. Perhaps you changed a variable or have a variable set as something else, elsewhere.... That would botch it pretty fast.

Grimes [3rd ID]
Jul 22 2009, 03:21
It's not like it doesn't work, it works fine. Just not the way I want it to :P

Schilly
Jul 22 2009, 12:19
Ic ic... How does it differ from what your trying to do exactly?

Grimes [3rd ID]
Jul 22 2009, 16:11
What I want is a qualification range with 5 targets. I want 1-3 random targets popping up at a time until 25 targets have been popped up. We nearly have this. Currently instead of just 25 targets popping up, it is actually 25 groups (1-3 per) of targets popping up, which obviously throws everything off.

Now, if this can not be achieved, just 1 target at a time is perfectly fine with me, I just need to change some sleep times.

Schilly
Jul 22 2009, 16:59
Yea I have not yet got that far with mine... I currently have 2 operational firing ranges... Of which either can be set for a random 20 targets or a random 10 targets (for rifles and pistols) i am going to be working on a machine gun range which will popup a group of targets at a time...

When I get that far I'll let you know... Lot's of demands on me right now to get this mission done for the unit heh.

F2k Sel
Jul 22 2009, 17:01
This is about it for me, 3 targets per set = 24 total targets with scoring.







//////////////////////////////////////////////////////////////////
// Function file for Armed Assault
// Created by: TODO: Author Name
//////////////////////////////////////////////////////////////////
// How to use.
// 1. Place a popup target and name it to pt1
// 2. copy it 8 times and it will auto name the targets
// 3. place this line in a trigger or init nul=[] execVM "popup.sqf"

_inc = 0;
_count = 0;
_targets = [pt1,pt1_1, pt1_2, pt1_3, pt1_4, pt1_5, pt1_6, pt1_7];
_many = count _targets;
nopop=true;
{_x animate["terc",1]} forEach _targets;
_rnumber1=0;
_rnumber2=0;
_rnumber3=0;

hint "Setting up the Range";
sleep 2;
hint "Ready";
sleep 2;


while {_inc<8} do
{
_rnumber1 = random _many;
_int = _rnumber1%1;
_rnumber1 = _rnumber1-_int;

while {(_rnumber1 == _rnumber2) or (_rnumber1 == _rnumber3) or (_rnumber2 == _rnumber3)} do
{
_rnumber2 = random _many;
_int = _rnumber2%1;
_rnumber2 = _rnumber2-_int;

_rnumber3 = random _many;
_int = _rnumber3%1;
_rnumber3 = _rnumber3-_int;
};

_rtarget1 = _targets select _rnumber1;
_rtarget2 = _targets select _rnumber2;
_rtarget3 = _targets select _rnumber3;

_rtarget1 animate["terc", 0];
_rtarget2 animate["terc", 0];
_rtarget3 animate["terc", 0];

sleep 3;

if (_rtarget1 animationPhase "terc" > 0.1) then
{
_count = _count+1;
};
if (_rtarget2 animationPhase "terc" > 0.1) then

{
_count = _count+1;
};
if (_rtarget3 animationPhase "terc" > 0.1) then
{
_count = _count+1;
};

hint format ["Targets :%1 Hit :%2",(_inc+1)*3,_count];
_rtarget1 animate["terc", 1];
_rtarget2 animate["terc", 1];
_rtarget3 animate["terc", 1];
sleep 2;
_inc = _inc + 1;
};
sleep 8;
hint "Session Complete";

Grimes [3rd ID]
Jul 22 2009, 18:36
Nice. So, I tried that script, and found 2 problems. But the good thing is we are almost finished :P

1. Too many targets were up at certain times, should only be 1-3. Again, if this can not be achieved, just 1 at a time is fine.

2. It scored the hits exactly how I wanted it (1 target hit = +1 to hit counter), but it still counted every group of targets as 1 target. Half way there! :D

And I had a question... is there anything you can put into the script so it does not activate at the beginning of the map, and only by trigger? I've got the trigger set up and it works fine, but I don't want the script to always activate at the beginning of the map.

OConnell [3rd ID]
Jul 22 2009, 18:56
while {(_rnumber1 == _rnumber2) or (_rnumber1 == _rnumber3) or (_rnumber2 == _rnumber3)} do
{
_rnumber2 = random _many;
_int = _rnumber2%1;
_rnumber2 = _rnumber2-_int;

_rnumber3 = random _many;
_int = _rnumber3%1;
_rnumber3 = _rnumber3-_int;
};


I think I understand what this loop is doing but not the condition.

Instead of doing this in sets like _inc<8 could we not start it off like this instead?


_totalTargets = 25;
_numTargets = 0;


while {_numTargets < _totalTargets} do
{

have a random number [1-3] say _popNum

inside a loop that loops around _popNum times and checks (_numTargets < _totalTargets), have it pick a random target and pop it up. and at every instance of that loop increment _numTargets.

}

I am still learning the syntax for this language but I am sure that code will work if implemented.

F2k Sel
Jul 22 2009, 23:13
It's just a matter of keeping track of all the loops, it would be quite easy to randomise the set of three.

You would just need to randomize these two lines


_rtarget2 animate["terc", 0];
_rtarget3 animate["terc", 0];



Something like
If (random+2 >1 ) do {
_rtarget2 animate["terc", 0];

};
if (random+3 >1 ) do {
_rtarget3 animate["terc", 0];
};

You would only need two as one at least would always be true or there may be no popop that set.

I haven't tested any of this so it may be buggy.

OConnell [3rd ID] way would could also help but it does get hard to keep the syntax correct and nested whiles and IF's.

It is also getting difficult to keep the count of the targets with everything being random.


As for what the CONDITION does, it simply compares the random numbers and if they are duplicated it forces it to pick again until it has three unique numbers.
It's also the reason I needed to make the random numbers whole number as it's much easier to work with.


I haven't tested any of this so it may be buggy.




Thinking a bit more if you removed the WHILE with the CONDITION check and fixed the syntax you would get a varying number of popups if the numbers did duplicated.
Then you would just have to count the ones that popup until they reach the total you require.

F2k Sel
Jul 23 2009, 23:35
I've had one last go and I think it's ok now.

You can select the total number of targets, number that will popup randomly per set 1-3 and the time allowed for hitting the target.


// How to use.
// 1. Place a popup target and name it to pt1
// 2. copy it 8 times and it will auto name the targets
// 3. place this line in a trigger or init nul=[max,set,time] execVM "popup.sqf"
// max is the total number of targets that will popup
// set is the max number of targets that can popup per set upto a max of 3
// time is the amount of time to hit the targets before they go down


_maxtarg = _this select 0;
_numtargs = _this select 1;
_skill = _this select 2;

_targets = [pt1,pt1_1, pt1_2, pt1_3, pt1_4, pt1_5, pt1_6, pt1_7];// target names
_many = count _targets; // count the number of possible targets

_inc = 0;// keeps track of the number of popup targets triggered
_score = 0;// keep count of the targets hit


{_x animate["terc",1]} forEach _targets;//puts the targets down before the start

_rnumber1=0;
_rnumber2=0;
_rnumber3=0;

_flag1=0;
_flag2=0;

nopop=true; // sets them to stay down until triggered to popup

hint "Setting up the Range";
sleep 2;
hint "Ready";
sleep 2;


while {_inc<_maxtarg} do
{
_rnumber1 = random _many;
_int = _rnumber1%1;
_rnumber1 = _rnumber1-_int;


// 1. Check for duplicate targets
while {(_rnumber1 == _rnumber2) or (_rnumber1 == _rnumber3) or (_rnumber2 == _rnumber3)} do
{
_rnumber2 = random _many;
_int = _rnumber2%1;
_rnumber2 = _rnumber2-_int;

_rnumber3 = random _many;
_int = _rnumber3%1;
_rnumber3 = _rnumber3-_int;
};
// 1. END

// 2. Set the targets that will popup
_rtarget1 = _targets select _rnumber1;
_rtarget2 = _targets select _rnumber2;
_rtarget3 = _targets select _rnumber3;
// 2. END

// 3. Popup target one always active
_rtarget1 animate["terc", 0];
_inc=_inc+1;
// 3. END

// 3a. Check to see if more than one target is required and opopup at random
// 3b. second target
If (_numtargs > 1 ) then
{
if ((random 2 > 1) and (_inc < _maxtarg)) then
{
_rtarget2 animate["terc", 0];
_inc=_inc+1;
_flag1=1;
};
};
//3b. END

//3c. Third target
If (_numtargs > 2 ) then
{
if ((random 2 < 1) and (_inc < _maxtarg)) then
{
_rtarget3 animate["terc", 0];
_inc=_inc+1;
_flag2=1;
};
};
// 3c. END
// 3a. END

// 4. Time allowed for shooting.
sleep _skill;
// 4. END

// 5. Check to see if targets have been hit and count the score
if (_rtarget1 animationPhase "terc" > 0.1) then
{
_score = _score+1;
};
if ((_rtarget2 animationPhase "terc" > 0.1) and (_flag1 == 1)) then

{
_score = _score+1;
};
if ((_rtarget3 animationPhase "terc" > 0.1) and (_flag2 == 1)) then
{
_score = _score+1;
};
// 4. END

// 5. Display Score
hint format ["Targets :%1 Hit :%2",_inc,_score];
// 5. END

// 6. Reset targets down and restet flags
_rtarget1 animate["terc", 1];
_rtarget2 animate["terc", 1];
_rtarget3 animate["terc", 1];
_flag1=0;
_flag2=0;
// 6. END

sleep 2;
};
sleep 8;
hint "Session Complete";

I haven't done any fancy intro or exiting script it's just a basic hit and score routine.

Grimes [3rd ID]
Jul 24 2009, 01:03
No problem, all I need is a basic hit and score routine. I can add the rest myself. I am away from my gaming computer for the weekend, but I will try this out on Sunday and get back to you. Thanks very much.

Soldat20
Jul 24 2009, 04:03
Like I posted in Schilly's this is the code I use and you should Download the Mission for the whole scripts that run together to make it work but the only problem is it don't keep score it did in ArmA1 so it must be a simple fix.


_targetTime = _this select 0;

if (not RangeRunning) then
{
rangeRunning = true;

playSound "voice1";

Hits_Lane1 = 0;
Hits_Lane2 = 0;
Hits_Lane3 = 0;
Hits_Lane4 = 0;
Hits_Lane5 = 0;
Hits_Lane6 = 0;

if (isServer) then
{
sleep 5.5;

_i = 0;
while {_i < 10} do
{
_target = [1, 6] call CSL_GetRandomInteger;

switch (_target) do
{
case 1:
{
_eh = t50_1 addeventhandler ["hit", {Hits_Lane1 = Hits_Lane1 + 1; _this select 0 setDamage 0;}];
_eh = t50_2 addeventhandler ["hit", {Hits_Lane2 = Hits_Lane2 + 1; _this select 0 setDamage 0;}];
_eh = t50_3 addeventhandler ["hit", {Hits_Lane3 = Hits_Lane3 + 1; _this select 0 setDamage 0;}];
_eh = t50_4 addeventhandler ["hit", {Hits_Lane4 = Hits_Lane4 + 1; _this select 0 setDamage 0;}];
_eh = t50_5 addeventhandler ["hit", {Hits_Lane5 = Hits_Lane5 + 1; _this select 0 setDamage 0;}];
_eh = t50_6 addeventhandler ["hit", {Hits_Lane6 = Hits_Lane6 + 1; _this select 0 setDamage 0;}];

t50_1 animate["terc",0];
t50_2 animate["terc",0];
t50_3 animate["terc",0];
t50_4 animate["terc",0];
t50_5 animate["terc",0];
t50_6 animate["terc",0];
};
case 2:
{
_eh = t75_1 addeventhandler ["hit", {Hits_Lane1 = Hits_Lane1 + 1; _this select 0 setDamage 0;}];
_eh = t75_2 addeventhandler ["hit", {Hits_Lane2 = Hits_Lane2 + 1; _this select 0 setDamage 0;}];
_eh = t75_3 addeventhandler ["hit", {Hits_Lane3 = Hits_Lane3 + 1; _this select 0 setDamage 0;}];
_eh = t75_4 addeventhandler ["hit", {Hits_Lane4 = Hits_Lane4 + 1; _this select 0 setDamage 0;}];
_eh = t75_5 addeventhandler ["hit", {Hits_Lane5 = Hits_Lane5 + 1; _this select 0 setDamage 0;}];
_eh = t75_6 addeventhandler ["hit", {Hits_Lane6 = Hits_Lane6 + 1; _this select 0 setDamage 0;}];

t75_1 animate["terc",0];
t75_2 animate["terc",0];
t75_3 animate["terc",0];
t75_4 animate["terc",0];
t75_5 animate["terc",0];
t75_6 animate["terc",0];
};
case 3:
{
_eh = t100_1 addeventhandler ["hit", {Hits_Lane1 = Hits_Lane1 + 1; _this select 0 setDamage 0;}];
_eh = t100_2 addeventhandler ["hit", {Hits_Lane2 = Hits_Lane2 + 1; _this select 0 setDamage 0;}];
_eh = t100_3 addeventhandler ["hit", {Hits_Lane3 = Hits_Lane3 + 1; _this select 0 setDamage 0;}];
_eh = t100_4 addeventhandler ["hit", {Hits_Lane4 = Hits_Lane4 + 1; _this select 0 setDamage 0;}];
_eh = t100_5 addeventhandler ["hit", {Hits_Lane5 = Hits_Lane5 + 1; _this select 0 setDamage 0;}];
_eh = t100_6 addeventhandler ["hit", {Hits_Lane6 = Hits_Lane6 + 1; _this select 0 setDamage 0;}];

t100_1 animate["terc",0];
t100_2 animate["terc",0];
t100_3 animate["terc",0];
t100_4 animate["terc",0];
t100_5 animate["terc",0];
t100_6 animate["terc",0];
};
case 4:
{
_eh = t125_1 addeventhandler ["hit", {Hits_Lane1 = Hits_Lane1 + 1; _this select 0 setDamage 0;}];
_eh = t125_2 addeventhandler ["hit", {Hits_Lane2 = Hits_Lane2 + 1; _this select 0 setDamage 0;}];
_eh = t125_3 addeventhandler ["hit", {Hits_Lane3 = Hits_Lane3 + 1; _this select 0 setDamage 0;}];
_eh = t125_4 addeventhandler ["hit", {Hits_Lane4 = Hits_Lane4 + 1; _this select 0 setDamage 0;}];
_eh = t125_5 addeventhandler ["hit", {Hits_Lane5 = Hits_Lane5 + 1; _this select 0 setDamage 0;}];
_eh = t125_6 addeventhandler ["hit", {Hits_Lane6 = Hits_Lane6 + 1; _this select 0 setDamage 0;}];

t125_1 animate["terc",0];
t125_2 animate["terc",0];
t125_3 animate["terc",0];
t125_4 animate["terc",0];
t125_5 animate["terc",0];
t125_6 animate["terc",0];
};
case 5:
{
_eh = t150_1 addeventhandler ["hit", {Hits_Lane1 = Hits_Lane1 + 1; _this select 0 setDamage 0;}];
_eh = t150_2 addeventhandler ["hit", {Hits_Lane2 = Hits_Lane2 + 1; _this select 0 setDamage 0;}];
_eh = t150_3 addeventhandler ["hit", {Hits_Lane3 = Hits_Lane3 + 1; _this select 0 setDamage 0;}];
_eh = t150_4 addeventhandler ["hit", {Hits_Lane4 = Hits_Lane4 + 1; _this select 0 setDamage 0;}];
_eh = t150_5 addeventhandler ["hit", {Hits_Lane5 = Hits_Lane5 + 1; _this select 0 setDamage 0;}];
_eh = t150_6 addeventhandler ["hit", {Hits_Lane6 = Hits_Lane6 + 1; _this select 0 setDamage 0;}];

t150_1 animate["terc",0];
t150_2 animate["terc",0];
t150_3 animate["terc",0];
t150_4 animate["terc",0];
t150_5 animate["terc",0];
t150_6 animate["terc",0];
};
case 6:
{
_eh = t200_1 addeventhandler ["hit", {Hits_Lane1 = Hits_Lane1 + 1; _this select 0 setDamage 0;}];
_eh = t200_2 addeventhandler ["hit", {Hits_Lane2 = Hits_Lane2 + 1; _this select 0 setDamage 0;}];
_eh = t200_3 addeventhandler ["hit", {Hits_Lane3 = Hits_Lane3 + 1; _this select 0 setDamage 0;}];
_eh = t200_4 addeventhandler ["hit", {Hits_Lane4 = Hits_Lane4 + 1; _this select 0 setDamage 0;}];
_eh = t200_5 addeventhandler ["hit", {Hits_Lane5 = Hits_Lane5 + 1; _this select 0 setDamage 0;}];
_eh = t200_6 addeventhandler ["hit", {Hits_Lane6 = Hits_Lane6 + 1; _this select 0 setDamage 0;}];

t200_1 animate["terc",0];
t200_2 animate["terc",0];
t200_3 animate["terc",0];
t200_4 animate["terc",0];
t200_5 animate["terc",0];
t200_6 animate["terc",0];
};
};//switch (_target) do

sleep _targetTime;

switch (_target) do
{
case 1:
{
t50_1 animate["terc",1];
t50_2 animate["terc",1];
t50_3 animate["terc",1];
t50_4 animate["terc",1];
t50_5 animate["terc",1];
t50_6 animate["terc",1];
};
case 2:
{
t75_1 animate["terc",1];
t75_2 animate["terc",1];
t75_3 animate["terc",1];
t75_4 animate["terc",1];
t75_5 animate["terc",1];
t75_6 animate["terc",1];
};
case 3:
{
t100_1 animate["terc",1];
t100_2 animate["terc",1];
t100_3 animate["terc",1];
t100_4 animate["terc",1];
t100_5 animate["terc",1];
t100_6 animate["terc",1];
};
case 4:
{
t125_1 animate["terc",1];
t125_2 animate["terc",1];
t125_3 animate["terc",1];
t125_4 animate["terc",1];
t125_5 animate["terc",1];
t125_6 animate["terc",1];
};
case 5:
{
t150_1 animate["terc",1];
t150_2 animate["terc",1];
t150_3 animate["terc",1];
t150_4 animate["terc",1];
t150_5 animate["terc",1];
t150_6 animate["terc",1];
};
case 6:
{
t200_1 animate["terc",1];
t200_2 animate["terc",1];
t200_3 animate["terc",1];
t200_4 animate["terc",1];
t200_5 animate["terc",1];
t200_6 animate["terc",1];
};
};//switch (_target) do

sleep 1;

t50_1 removeAllEventHandlers "hit";
t50_2 removeAllEventHandlers "hit";
t50_3 removeAllEventHandlers "hit";
t50_4 removeAllEventHandlers "hit";
t50_5 removeAllEventHandlers "hit";
t50_6 removeAllEventHandlers "hit";
t75_1 removeAllEventHandlers "hit";
t75_2 removeAllEventHandlers "hit";
t75_3 removeAllEventHandlers "hit";
t75_4 removeAllEventHandlers "hit";
t75_5 removeAllEventHandlers "hit";
t75_6 removeAllEventHandlers "hit";
t100_1 removeAllEventHandlers "hit";
t100_2 removeAllEventHandlers "hit";
t100_3 removeAllEventHandlers "hit";
t100_4 removeAllEventHandlers "hit";
t100_5 removeAllEventHandlers "hit";
t100_6 removeAllEventHandlers "hit";
t125_1 removeAllEventHandlers "hit";
t125_2 removeAllEventHandlers "hit";
t125_3 removeAllEventHandlers "hit";
t125_4 removeAllEventHandlers "hit";
t125_5 removeAllEventHandlers "hit";
t125_6 removeAllEventHandlers "hit";
t150_1 removeAllEventHandlers "hit";
t150_2 removeAllEventHandlers "hit";
t150_3 removeAllEventHandlers "hit";
t150_4 removeAllEventHandlers "hit";
t150_5 removeAllEventHandlers "hit";
t150_6 removeAllEventHandlers "hit";
t200_1 removeAllEventHandlers "hit";
t200_2 removeAllEventHandlers "hit";
t200_3 removeAllEventHandlers "hit";
t200_4 removeAllEventHandlers "hit";
t200_5 removeAllEventHandlers "hit";
t200_6 removeAllEventHandlers "hit";

_i = _i + 1;

}; //while {_i < 10} do

t50_1 animate["terc",1];
t50_2 animate["terc",1];
t50_3 animate["terc",1];
t50_4 animate["terc",1];
t50_5 animate["terc",1];
t50_6 animate["terc",1];
t75_1 animate["terc",1];
t75_2 animate["terc",1];
t75_3 animate["terc",1];
t75_4 animate["terc",1];
t75_5 animate["terc",1];
t75_6 animate["terc",1];
t100_1 animate["terc",1];
t100_2 animate["terc",1];
t100_3 animate["terc",1];
t100_4 animate["terc",1];
t100_5 animate["terc",1];
t100_6 animate["terc",1];
t125_1 animate["terc",1];
t125_2 animate["terc",1];
t125_3 animate["terc",1];
t125_4 animate["terc",1];
t125_5 animate["terc",1];
t125_6 animate["terc",1];
t150_1 animate["terc",1];
t150_2 animate["terc",1];
t150_3 animate["terc",1];
t150_4 animate["terc",1];
t150_5 animate["terc",1];
t150_6 animate["terc",1];
t200_1 animate["terc",1];
t200_2 animate["terc",1];
t200_3 animate["terc",1];
t200_4 animate["terc",1];
t200_5 animate["terc",1];
t200_6 animate["terc",1];


_scores = "player sideChat '";

if ((count list Lane1ShootingArea) > 0) then {_scores = format["%1Lane 1 %2 hits. ", _scores, Hits_Lane1];};
if ((count list Lane2ShootingArea) > 0) then {_scores = format["%1Lane 2 %2 hits. ", _scores, Hits_Lane2];};
if ((count list Lane3ShootingArea) > 0) then {_scores = format["%1Lane 3 %2 hits. ", _scores, Hits_Lane3];};
if ((count list Lane4ShootingArea) > 0) then {_scores = format["%1Lane 4 %2 hits. ", _scores, Hits_Lane4];};
if ((count list Lane5ShootingArea) > 0) then {_scores = format["%1Lane 5 %2 hits. ", _scores, Hits_Lane5];};
if ((count list Lane6ShootingArea) > 0) then {_scores = format["%1Lane 6 %2 hits. ", _scores, Hits_Lane6];};

_scores = format["%1';", _scores];

//player sideChat _scores;

//Display chat in each group once
ChatLogic = "Logic" createVehicle [random 100, random 100];
ChatLogic setVehicleInit _scores;

processInitCommands;

rangeRunning = false;
publicVariable "rangeRunning";

};//if (isServer) then


};//if (not rangeRunning) then


sleep 30;

deleteVehicle ChatLogic;

Mission: http://arma2.7thcavalry.us/BootCamp.utes.pbo

Grimes [3rd ID]
Jul 24 2009, 05:52
How does it work compared to the script we have been messing with in this thread? Looks a bit too in depth and complicated compared to what we are trying to accomplish.

F2k Sel
Jul 24 2009, 09:48
There does seem to be some useful stuff in there worth looking at.


call CSL_GetRandomInteger;

is a big help getting integer numbers if I can get it to work.

And I really need to look at the use of the case statement as that was very useful when I used to code in BBC basic.

Still a puzzle to me is the eventhandler.


_eh = t50_1 addeventhandler ["hit", {Hits_Lane1 = Hits_Lane1 + 1; _this select 0 setDamage 0;}];


To use it to keep score you have to use a global variable no underscore "Hits_lane1" not "_Hits_lane1" that stumped me when I tried to use it.

But the bit at the beginning is still a mystery "_eh="

Soldat20
Jul 27 2009, 23:49
I'm sure some of you might know him but Colonel Sanders Lite wrote this for the clan we had back in the ArmA1 days it worked perfectly fine, it would add up all the scores at the end of the cycles and then it would tell you each lanes scores. It calls on to a script he wrote for the random integers its in the mission file i posted. I could probably get him to look at this thread he don't play much anymore but I'll see what I can do.

Well He said this since he hasn't migrated over to these new forums like I said he hasn't had much to do with ArmA2 stuff but heres what he told me Colonel Sanders Lite:

"First, keep in mind that code was written for arma 1.
_eh is just a variable that holds an event handler.
In this case, I don't really care about referencing the eventhandler as I use a variable to keep score, so I believe I just overwrote _eh repeatedly. It's possible that the event handler needs to be stored globally now, and soldat mentions that the score keeper is broken in arma 2.

I don't have arma 2, so I'm incapable of fixing it at the moment. Feel free to take a crack at it though.

When asked what the advantage of my method is. That code was written to make a multiplayer friendly multi lane firing range, which was synchronised on all machines. Just try the mission soldat posted above to see what I mean." Link:Bootcamp (http://arma2.7thcavalry.us/BootCamp.utes.pbo)

@<hidden> Sel:
You can find the CSL_GetRandomInteger function in the mission download.

F2k Sel
Jul 28 2009, 10:07
Yes I did find it, it was a bit more complex than what I was using so I haven't bothered to change my original script.

The advantage of the CSL version is you can specify a min and max number quite easily, If I do need such a function it may be the way to go.

I was only writing this script for something to do so I'm not really looking for anything else or really fussed about fixing it that's for others who want a good script.
I did take a look but I'm not up to that standard of scripting so I couldn't locate the error.

Grimes [3rd ID]
Jul 30 2009, 04:24
So I've got 2 questions.

1: How do I get the script to not execute at the beginning of the map?

2: How do I get it so that the 'nopop' command only effects the specific targets?
Meaning:



nopop=true (some way to say "only for targets pt5, pt5_1, pt5_2, pt5_3, and pt5_4")

Soldat20
Jul 30 2009, 10:29
I'm not sure if you can just specify which targets it effects, as far as I know the nopop=ture effects them all know matter what.

F2k Sel
Jul 30 2009, 11:26
;1385589']So I've got 2 questions.

1: How do I get the script to not execute at the beginning of the map?

2: How do I get it so that the 'nopop' command only effects the specific targets?
Meaning:



nopop=true (some way to say "only for targets pt5, pt5_1, pt5_2, pt5_3, and pt5_4")



Just put the script in a trigger and call it when you need it.

Why would you want to turn off nopop, all it does is stop a target from popping back up automatically without the use of a command and would then be outside the scope of the program.

Grimes [3rd ID]
Jul 30 2009, 15:02
I've got this qualification course and a firing range with the same type of targets. I figured it out though, you just can't use them at the same time. I did this in the trigger and removed 'nopop=true' from the script.



On Activation:
nopop=true; nul=[] execVM "popup.sqf"

On Deactivation:
nopop=false


So now I still have 2 problems.

1. Even in a trigger like that the script still executes at the beginning of the map
2. 'Hit' scoring works fine, but only 1 target is popping up at a time, and this one target counts as 3 on 'Count'

F2k Sel
Jul 30 2009, 15:17
;1386187']I've got this qualification course and a firing range with the same type of targets. I figured it out though, you just can't use them at the same time. I did this in the trigger and removed 'nopop=true' from the script.



On Activation:
nopop=true; nul=[] execVM "popup.sqf"

On Deactivation:
nopop=false


So now I still have 2 problems.

1. Even in a trigger like that the script still executes at the beginning of the map
2. 'Hit' scoring works fine, but only 1 target is popping up at a time, and this one target counts as 3 on 'Count'


If you put it in a trigger don't forget to remove it from the Init box.

I had that problem at first but I just downloaded the last script I posted and tested it and it was fine.


nul=[] execVM "popup.sqf" not sure why you are calling it with empty brackets?

Grimes [3rd ID]
Jul 30 2009, 18:03
What would I put in the empty brackets? The script already selects the targets. Also, which last script? Most of 'em say that you haven't tested them lol

If its working, see if you can setup a mission with a range with a couple targets and the script included. Then I'll compare it to mine and see what I am doing wrong I suppose. So confused.

Schilly
Jul 30 2009, 18:31
You can run 2 lanes at the same time, with seperate scoring... Only issue that arises is the fact that you have to have multiple script files... One for each course, otherwise you would end up with variable mismatches and get invalid numbers being returned.

F2k Sel
Jul 30 2009, 20:13
Post 27 was my last version and I have checked it. The info for calling it is contained in the script.

but
nul=[25,3,4] execVM "popup.sqf" will work. That's 25 targets in random sets of three with 4 sec delay.


Schilly is correct about needing two scripts for multiple lanes however it could be made to use one.
Not being able to test MP I haven't done anything about it.

You could need pass the targets in a variable instead of defining them in the script. The only problem I can think of is that you would get two lots of scoring appearing at the same time. That must be fixable, maybe using sidechat.

Grimes [3rd ID]
Jul 30 2009, 23:01
Alright, got it to work, and got the trigger to work so it doesn't start at the beginning of the round. Thank you so very much for your help, and I apologize for me being a burden. :p

Schilly
Jul 30 2009, 23:33
Yea F2k,

I was not able to pass the variables to the script and get it to work properly... So I used multiple files... Works just as well, jsut a bit redundant thats all. Also, the scoring, I switched from using Hints to using sideChat, as well hints are great and all but it gets pretty messy when running multiple lanes.

For the unit training map I have, I can run two seperate lanes for rifle or pistol quals, each recording their own score... Working quite well at the moment... unless something explodes on Sunday when it gets a real exercise lol

F2k Sel
Jul 30 2009, 23:49
;1386707']Alright, got it to work, and got the trigger to work so it doesn't start at the beginning of the round. Thank you so very much for your help, and I apologize for me being a burden. :p

No problem I was glad of the exercise I needed something to do.;)

---------- Post added at 12:49 AM ---------- Previous post was at 12:45 AM ----------


Yea F2k,

I was not able to pass the variables to the script and get it to work properly... So I used multiple files... Works just as well, jsut a bit redundant thats all. Also, the scoring, I switched from using Hints to using sideChat, as well hints are great and all but it gets pretty messy when running multiple lanes.

For the unit training map I have, I can run two seperate lanes for rifle or pistol quals, each recording their own score... Working quite well at the moment... unless something explodes on Sunday when it gets a real exercise lol

If you do want to tidy it up to one script all you need is to add this to the script


_targets = _this select 3; and delete or // this line
_targets = [pt1,pt1_1, pt1_2, pt1_3, pt1_4, pt1_5, pt1_6, pt1_7];// target names

the execute line would be something like this :-


nul=[25,3,4,[pt1,pt1_1, pt1_2, pt1_3, pt1_4, pt1_5, pt1_6, pt1_7]] execVM "popup.sqf"

Schilly
Jul 31 2009, 17:47
Yea I know, but seeing how it's only 1 kb per file, im not too worried... And it's only for a unit training map... If this was something I was going to make for hte public, i would clean it up lol

Kremator
Jul 31 2009, 23:20
Looking good.

Schilly
Aug 1 2009, 15:23
has any testing been done on a dedicated server? As the script I have, (very similar to this one, wihtout the extra variables) does not function on a dedicated server for some reason... Works perfectly locally hosted though.

22Jacket
Aug 12 2009, 15:52
wow intresting thread good reading..have u got a finished version yet..maybe for release.....:yay::yay::yay::yay::yay:

d88gamble
Aug 29 2009, 14:24
I've a little problem with this one.

I used the script from post 27 and used a trigger to start the fire range.


// How to use.
// 1. Place a popup target and name it to pt1
// 2. copy it 8 times and it will auto name the targets
// 3. place this line in a trigger or init nul=[max,set,time] execVM "popup.sqf"
// max is the total number of targets that will popup
// set is the max number of targets that can popup per set upto a max of 3
// time is the amount of time to hit the targets before they go down


_maxtarg = _this select 0;
_numtargs = _this select 1;
_skill = _this select 2;

_targets = [pt1,pt1_1, pt1_2];// target names
_many = count _targets; // count the number of possible targets

_inc = 0;// keeps track of the number of popup targets triggered
_score = 0;// keep count of the targets hit


{_x animate["terc",1]} forEach _targets;//puts the targets down before the start

_rnumber1=0;
_rnumber2=0;
_rnumber3=0;

_flag1=0;
_flag2=0;

nopop=true; // sets them to stay down until triggered to popup

hint "Setting up the Range";
sleep 2;
hint "Ready";
sleep 2;


while {_inc<_maxtarg} do
{
_rnumber1 = random _many;
_int = _rnumber1%1;
_rnumber1 = _rnumber1-_int;


// 1. Check for duplicate targets
while {(_rnumber1 == _rnumber2) or (_rnumber1 == _rnumber3) or (_rnumber2 == _rnumber3)} do
{
_rnumber2 = random _many;
_int = _rnumber2%1;
_rnumber2 = _rnumber2-_int;

_rnumber3 = random _many;
_int = _rnumber3%1;
_rnumber3 = _rnumber3-_int;
};
// 1. END

// 2. Set the targets that will popup
_rtarget1 = _targets select _rnumber1;
_rtarget2 = _targets select _rnumber2;
_rtarget3 = _targets select _rnumber3;
// 2. END

// 3. Popup target one always active
_rtarget1 animate["terc", 0];
_inc=_inc+1;
// 3. END

// 3a. Check to see if more than one target is required and opopup at random
// 3b. second target
If (_numtargs > 1 ) then
{
if ((random 2 > 1) and (_inc < _maxtarg)) then
{
_rtarget2 animate["terc", 0];
_inc=_inc+1;
_flag1=1;
};
};
//3b. END

//3c. Third target
If (_numtargs > 2 ) then
{
if ((random 2 < 1) and (_inc < _maxtarg)) then
{
_rtarget3 animate["terc", 0];
_inc=_inc+1;
_flag2=1;
};
};
// 3c. END
// 3a. END

// 4. Time allowed for shooting.
sleep _skill;
// 4. END

// 5. Check to see if targets have been hit and count the score
if (_rtarget1 animationPhase "terc" > 0.1) then
{
_score = _score+1;
};
if ((_rtarget2 animationPhase "terc" > 0.1) and (_flag1 == 1)) then

{
_score = _score+1;
};
if ((_rtarget3 animationPhase "terc" > 0.1) and (_flag2 == 1)) then
{
_score = _score+1;
};
// 4. END

// 5. Display Score
hint format ["Targets :%1 Hit :%2",_inc,_score];
// 5. END

// 6. Reset targets down and restet flags
_rtarget1 animate["terc", 1];
_rtarget2 animate["terc", 1];
_rtarget3 animate["terc", 1];
_flag1=0;
_flag2=0;
// 6. END

sleep 2;
};
sleep 2;
hint "Session Complete";

At the start of the mission allt the targets are up (like i want it).

When i walk into the trigger (at the range) the targets drop down and it start the count down.

Now when i complete the fire range all the targets are down and it shows me the score and they say Session Complete.

The range wont reset by it self.

My questions:

1. How can i make the range reset with a option in the action menu when im still in the trigger?

2. How can i make the range reset if i move outside the trigger?

d88gamble
Sep 23 2009, 09:21
::bump::

Alderman
Feb 10 2010, 06:12
I hate to revive old threads but due to the limitations of ArmA2 the 3rd Marine Division cannot follow the USMC standard for rifle qualifications. After discussion on the issue we have decided that following the common Army BRM qualification standard would be most appropriate. What I need is a script kinda like the ones in this thread but that meets these requirements. The 3rd Marine Division will provide a financial (money) contribution a individual who can do this.

Currently we have the range setup with 7 pop-up targets, 2 at 50m (one left and one right), and then 1 target at each 50 meter interval that are mostly centered and staggered. I need a script that can be activated by a instructor at a location, maybe by having a object with a init line that says (Start Lane 1, Start Lane 2). Maybe having a copy of the script for the second lane but a object that can have a variable that allows a scroll wheel option to start each as stated above.

I then need the sequence of targets to follow a set order, and since it would make it easier, here is the sequence I need to have followed. At a later time we might like to have another option to start a random sequences for the purpose of training, and not qualification though. You will notice that several rounds are together which means that two targets, one at each of the indicated distances will pop-up at and for the same amount of time.

http://3rdmd.net/images/alderman/BRM.jpg

Also each table listed is for various shooting positions, and thanks to ACE we can do the prone supported, prone unsupported, and then kneeling. The script would need to allow for a significant pause between tables of about 45 seconds, but the preferred option would be to allow the instructor/controller to have a way to enable the qualification to continue to the next table. The other thing would be to have a pause after each round (aka set of targets as see in the above image). If possible it would nice to have it be about 4 seconds from when the last target went down (if shot), or regardless of it or not, 4 seconds from when the target automatically goes down by itself if it does not get hit. We also need to have a system that would record the entire thing and at the end give out a result showing XX/40 (40 being the maximum).

Anyone how might have the ability to create something like or exactly as I mentioned above is asked to contact me. As noted earlier we will compensate someone for their time as this is a vital asset that we need.

AkeR
Jan 22 2011, 19:42
shooting_range.utes.zip (http://sender.hu/downloads/shooting_range.utes.zip)
Hey! I've a problem with my script, couple of (frequently -2 or -3) targets are usually does not appear, just the target counter counts. Any Ideas? Thank You!

F2k Sel
Jan 22 2011, 23:02
You may want to change the following line

Old

_rnumber = random _many-1;

New

_rnumber = floor random _many;

I don't know if it will fix the problem but it's better to use whole numbers for this.

AkeR
Jan 23 2011, 13:19
_rnumber = floor random _many;

Tested and worked perfectly! Many Thanks!

eLectryx
Mar 29 2011, 08:36
Hey there:

I finally got around to working on a range and used the script F2k Sel worked up. Works great except at least twice in 20 targets I get repeats where the last target stays up for another round. Any way anyone can see to fix that?

Thanks,

-e

Alderman
Apr 27 2011, 18:48
In response to my previous post on what my unit is looking for. If someone can create the system we talk about above, our organization will make a financial contribution to the individual, group of people, or an organization/business that can create it. Please contact me directly for details.

rhaggan
Apr 28 2011, 01:33
Cant get the pop up to work targets are being missed out ie no target poping up and being counted as misses. Also one question would this work with the nato targets from arma as i have them set up and the targets appear but i cant get it to register hits.

michelstreet
Nov 28 2011, 00:18
heey guys

i have make my own training map, is there a way to get a message in the screen if i pass a training or not. my idea is to have 20 targets pop up. and you need to hit 18 targets for completing. if you hit <17 you get a message fail and if you hit 18> you got training exam passed.


//////////////////////////////////////////////////////////////////
// How to use.
// 1. Place a popup target and name it to pt1
// 2. copy it 8 times and it will auto name the targets
// 3. place this line in a trigger or init nul=[] execVM "popup.sqf"

_inc = 0;
_count = 0;
_targets = [pt1,pt1_1, pt1_2, pt1_3, pt1_4, pt1_5, pt1_6, pt1_7];
_many = count _targets;
nopop=true;
{_x animate["terc",1]} forEach _targets;

hint "Setting up the Range";
sleep 2;
hint "Load magazine of 30 rounds";
sleep 4;
hint "Ready";
sleep 4;


while {_inc<20} do
{
_rnumber = random _many-1;
_rtarget = _targets select _rnumber;
_rtarget animate["terc", 0];
sleep 7;
if (_rtarget animationPhase "terc" > 0.1) then
{
_count = _count+1;
};
hint format ["Targets :%1 Hit :%2",_inc+1,_count];
_rtarget animate["terc", 1];
_inc = _inc + 1;
};
sleep 8;
hint "Session Complete";
sleep 2;
hint "Wait for results";
sleep 4;

njmatrix
Dec 19 2011, 00:01
Anyway to transpose the scores into the debriefing? I love it but would like the final score posted.

brightness
Jun 14 2012, 14:13
Instead of making a new thread I find it reasonable to post it here even thought its in wrong section but its regarding the script by F2k.
I decided to make a firing range but as I am lazy and found out that F2K had released a good firing range script with targets & count system I decided to use it(It works perfect yes!) until I put it on a dedicated server where the popup targets screws up, basically - The target pops up I hit it but it re pops up + a new target pops up and when I shoot the other target the old target pops up and the new target pops up and another new one pop ups which is kinda messy so I decided to re-script the animation way(Still does this but it doesn't pop up fully) and now I really need help - How to fix this so the targets stop popping up after being hit..


Script:

_inc = 0;
_count = 0;
_targets = [p1_1,p2_1,p3_1,p4_1,p5_1];
_many = count _targets;
nopop=true;
{_x animate["terc",1]} forEach _targets;

hint "Setting up the Range";
sleep 2;
hint "Ready";
sleep 2;


while {_inc<15} do
{
_rtarget animate["terc", 1];
_rnumber = floor random _many;
_rtarget = _targets select random ((count _targets) - 1);
{_x animate["terc",1]} forEach _targets;
_rtarget animate["terc", 1];
_rtarget animate["terc", 0];
sleep 5;
if (_rtarget animationPhase "terc" > 0.1) then
{
_count = _count+1;
_rtarget animate["terc", 1];
};
hintSilent format ["Targets :%1 Hit :%2",_inc+1,_count];
_rtarget animate["terc", 1];
_inc = _inc + 1;
sleep 2;
};
{_x animate["terc",0]} forEach _targets;
sleep 3;
hint "Session Complete";



I added eventHandler it neither fixed the issue and just caused more problem so I removed it..

Any issues you guys can see except I am repeating shitout of animation?

F2k Sel
Jun 14 2012, 22:53
Hi, I never did make a full working version for several reasons the main being I really don't like pop ups and also I don't know how to get the score to display on one PC.
I haven't tried MP scripting either but have you tried just running it on the server alone.

place at the begining of the script.

if(!isServer)exitWith{};

brightness
Jun 14 2012, 23:06
Its not about scores, popup targets bugging out

F2k Sel
Jun 14 2012, 23:13
I would think it's because it's running on the server and all other clients. Try the above code to shut down the client scripts.

brightness
Jun 15 2012, 00:36
Will do :)
Thanks

gutiarhero814
Aug 14 2012, 03:20
i am tryin to use this, but not as a trigger but as a addAction in a init file any idea what i would need to change

drivetheory
Oct 30 2012, 05:24
if you run the script via addAction only the person who performs the addAction sees the hints/score and everyone sees the targets.

when i tried
if(!isServer)exitWith{};
nobody sees the hints/scores but they do get the popups

if you run it via server side trigger everyone sees the hints but the popups go haywire because everyone is triggering the popups...

i'm trying to make the script only popup server side but hint/score on all clients

hey F2k Sel, any ideas? I'll post my work in progress modification if it'd help.

EDIT: currently messing with some ideas, will post back later

kylania
Oct 30 2012, 06:14
For a firing range I did once we reset the range via a local trigger on the instructor which set a variable that reset the range via on-map trigger, so everyone reset it at the same time.

instructor's player_init:


if (_unit == user1) then {
trgSST = createTrigger ["EmptyDetector",[1,0,0]];
trgSST setTriggerActivation ["ALPHA", "", true];
trgSST setTriggerType "NONE";
trgSST setTriggerStatements
["this",
"SST_resetpop = true; publicVariable ""SST_resetpop"";",
""];
trgSST setTriggerText "Reset Iron Sights Ranges";
};


And the trigger on the map had:

Condition of:
SST_resetpop
onAct of:
{_x setDamage 0; _x animate["terc", 0]} forEach laneTargets; SST_resetpop = false; publicVariable "SST_resetpop";

laneTargets is a game logic on the map with this as it's init:

laneTargets = nearestObjects [this, ["TargetBase"], 130];

We didn't try to keep score though, since it was obvious to the instructor how many they'd hit. :)

drivetheory
Oct 30 2012, 09:14
got the popup target range script working in an MP environment, will post back later with complete details

GiJoe775
Mar 1 2013, 02:00
Hello devetheory, Did you ever get around to posting how you got MP Firing range to work. I would love to see it if you care to share it with me.