I would greatly appreciate any help on this, I feel like I am so close yet so far.
I have a script that runs targets on a rifle range, there are about 12 of these ranges each with it's own .sqf.
here is one of them
// 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
if (!isServer) exitWith{};
_maxtarg = _this select 0;
_numtargs = _this select 1;
_skill = _this select 2;
_targets = [pt2,pt2_1, pt2_2, pt2_3, pt2_4, pt2_5];// 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
rrlane2 globalchat format ["Rifle Lane 2 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";
This is my main focus
// 5. Display Score
rrlane2 globalchat format ["Rifle Lane 2 Targets :%1 Hit :%2",_inc,_score];
// 5. END
rrlane2 is an AI player that is just there to create the chat
so my issue is that when this is ran on a ded server, nobody can see the chat of the resulting scores on the ranges. On local, it is only displayed to me because I am the host.
EDIT - Ok so I think i made some progress, I used the cba fucntion globalexecute, only thing is is that I am not getting the values returned, it just says "Any" instead of the numbers of the targets that have popped up and the number of targets hit.
This is what block 5 reads now
[-2, {rrlane1 globalChat format["Rifle Lane 1 Targets :%1 Hit :%2", _inc, _score]}, ""] call CBA_fnc_globalExecute;
Not sure what i need to change for those values to show up accurately. _inc is the number of targets that have popped up, _score is how many targets have been hit.
any ideas?