Jump to content
Sign in to follow this  
KC Grimes

Pop-Up Targets (Firing Range)

Recommended Posts

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.

Edited by F2k Sel

Share this post


Link to post
Share on other sites

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.

Edited by F2k Sel

Share this post


Link to post
Share on other sites

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.

Share this post


Link to post
Share on other sites

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

Share this post


Link to post
Share on other sites

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.

Share this post


Link to post
Share on other sites

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="

Share this post


Link to post
Share on other sites

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

@F2k Sel:

You can find the CSL_GetRandomInteger function in the mission download.

Edited by Soldat20

Share this post


Link to post
Share on other sites

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.

Share this post


Link to post
Share on other sites

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")

Share this post


Link to post
Share on other sites

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.

Share this post


Link to post
Share on other sites
;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.

Share this post


Link to post
Share on other sites

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'

Share this post


Link to post
Share on other sites
;1386187']I've got this qualification course and a firing range with the same type of targets. I figured it out though' date=' 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'[/quote']

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?

Edited by F2k Sel

Share this post


Link to post
Share on other sites

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.

Edited by Grimes [3rd ID]

Share this post


Link to post
Share on other sites

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.

Share this post


Link to post
Share on other sites

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.

Edited by F2k Sel

Share this post


Link to post
Share on other sites

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

Share this post


Link to post
Share on other sites

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

Share this post


Link to post
Share on other sites
;1386707']Alright' date=' 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[/quote']

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"

Share this post


Link to post
Share on other sites

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

Share this post


Link to post
Share on other sites

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.

Share this post


Link to post
Share on other sites

wow intresting thread good reading..have u got a finished version yet..maybe for release.....:yay::yay::yay::yay::yay:

Share this post


Link to post
Share on other sites

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?

Edited by d88gamble

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  

×