Schilly 10 Posted July 18, 2009 Looking to find a way to tell if a Popup target has been hit in a multiplayer setting... addEventHandler only seems to work with single player... And I cannot for some reason get "animationPhase" to work. Share this post Link to post Share on other sites
Schilly 10 Posted July 20, 2009 Anyone have any ideas? Share this post Link to post Share on other sites
TurokGMT 0 Posted July 20, 2009 I borrowed a pop up target script for a sniper training map I made for arma on the avgani map. Here's the script - it might help you. I can't remember if I called the script from a the pop up target's init line, or from init.sqf. // this script should be being run by every pop up target on dedi server /* InitPopUpTarget.sqf * * SYNTAX: nil = [Object, Number, Boolean] execVM "InitPopUpTarget.sqf" * * PARAMETERS: Object: A pop-up target * Number: The number of hits it takes to knock the target down * Boolean: If set to True, the target will pop up again. * * NOTES: This function is meant to be placed in the Initialization field * of a pop-up target. * * Pop-up targets that are not initialized with this function will * stop working as expected: they won't pop up again. This is * because this function sets the global variable "nopop" to True. */ #define VERSION 0.1 #define HIT_COUNTER "HitCounter" #define ONHIT_PARAMS "AdvPopUp_OnHit_Params" #define ONHIT_HANDLER "AdvPopUp_OnHit_Handler" #define ONHIT_INDEX "AdvPopUp_OnHit_Index" nopop = true; _target = _this select 0; _requiredHits = _this select 1; _isPopUp = _this select 2; _hitHandler = { private ["_target", "_requiredHits", "_isPopUp", "_hitCount", "_keepUp"]; _target = _this select 0; _requiredHits = _this select 1; _isPopUp = _this select 2; if (_target animationPhase "terc" > 0.1) exitWith {}; _hitCount = (_target getVariable HIT_COUNTER) + 1; _keepUp = true; if (_hitCount == _requiredHits) then { //////////////// // ADDED CODE // //////////////// // code designed to fire an event handler defined in init.sqf myvar = _target; publicVariable "myvar"; // This executes the event handler on other machines /////////////////////// // END OF ADDED CODE // /////////////////////// _hitCount = 0; _target animate ["terc", 1]; sleep 3; _keepUp = _isPopUp; }; if _keepUp then { _target animate ["terc", 0]; }; _target setVariable [HIT_COUNTER, _hitCount]; }; _target setVariable [HIT_COUNTER, 0]; _target setVariable [ONHIT_PARAMS, _this]; _target setVariable [ONHIT_HANDLER, _hitHandler]; _code = { _t = _this select 0; (_t getVariable ONHIT_PARAMS) spawn (_t getVariable ONHIT_HANDLER); // weird! }; _index = _target addEventHandler ["Hit", _code]; _target setVariable [ONHIT_INDEX, _index]; Share this post Link to post Share on other sites