Jump to content
Sign in to follow this  
usarmy19dsniper

Global Chat on local / ded server

Recommended Posts

I have this script ( not made by me, I take no credit )

//                 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 = [pt1,pt1_1, pt1_2, pt1_3, pt1_4, pt1_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		    
 rrlane1 globalchat format ["Rifle Lane 1, 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";

Now to narrow it down to this

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

I have this set up so that the score of the rifle range lane displays the score in global chat.

I have this set up as an AI soldier placed on the map name rrlane1, as well as many others for the different ranges I have set up.

On local, it will display the globalchat to me ( the host ) and nobody else, and on ded server, it doesn't display at all.

Would i use globalchat = true; publicvariable "show chat" somewhere?

Edited by usarmy19dsniper

Share this post


Link to post
Share on other sites

Well your main problem is that you have put:

if (!isServer) exitWith{};

at the start of the script so none of the clients actually do the globalChat command on their machine. Thats all I can see, although I wouldnt put that much trust in me since I have only recently started scripting.

Share this post


Link to post
Share on other sites

Well removing it would make the script run on all machines and I think that would be bad :) can try it though and putting it at the end is as good as removing it completely.

Share this post


Link to post
Share on other sites

now that i think of it, i did try it without that !isserver thing, and yeah, it was bad. Targets were popping up all over the place instead of what was suppose to happen, instead of 2 at a time for whatever the duration was. Right now with it in, people see the targets popping up fine in the right places, its just that the score isn't displayed to everybody.

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  

×