Jump to content
Sign in to follow this  
alexboy

Help (c-ram scripting).... need to check if unit is firing

Recommended Posts

Hey guys... If you dont know already.... im working on alot of addons / scripts....

I am working on my C-ram right now... and in my script I am trying to check if my unit is firing (actually firing bullets... not checking if its aiming at a target....)

I get this

_defender addEventHandler ["fired", {_this call IGN_fnc_shotcounter}];

but.... how can i make this into a true / false or 0/1 value that is given

ex:

if unit is firing return value 1

if unit is not firing return value 0

i need this to make sure the unit is firing to be able to aim its "target" to destroy it

if you can make it into a simple cut / paste code itll be highly appreciative really stuck on this...

when i put this into my script it lags it terribly



//creating a little function to count fired shots from primary weapon

alex_fnc_shotcounter = {
	private ["_defender", "_weapon"];
	_defender = _this select 0;
	_weapon = _weaponClass; //_this select 1;

		//_defender setVariable ["ShotsTaken", (_defender getVariable "ShotsTaken") + 1];
		if ((_defender getVariable "ShotsTaken")) then {
			//hintsilent format ["Shots fired: %1", _defender getVariable "ShotsTaken"];
			hint "firing";
			_fired = 1;
			_firinggun = 1;
		} else {
			_fired = 0;
			//hintsilent format ["Limit of %1 shots reached", _defender getVariable "maxShots"];
			hint "not firing";
		};

};

//Adding eventHandler to the unit.
if (_aimingQuality == 1 && _firinggun == 0) then {
alex_firedEH = _defender addEventHandler ["fired", {_this call alex_fnc_shotcounter}];

};	

but if you can find a better way to do this... i appreciate it

Thank you in advance

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  

×