Jump to content
militarypolice

Help with making popup targets go down after multiple hits

Recommended Posts

Hello,

 

I'm making a shoothouse and need the targets to pop down after 2 hits. I found a script on https://www.ofpec.com/forum/index.php?topic=32607.0;all and it does work in SP and on a Client Hosted Server. But, it does not work on a dedicated server. The script needs "nopop" to eq true. So, in the init.sqf of the mission nd initserver.sqf I put "nopop = true". Though nopop is a global variable it seems that this script thinks that nopop is false? Can someone take a look and let me know? Or teach me how to create a global variable? Or is it possible to create a version of this for MP use? I modified the script to be two round hits before the target goes down.

This is in the init of each popup target:

if (!isDedicated) then {this addEventHandler ["Hit", {[_this, 2, true] execVM "AdvancedPopUpTarget.sqf"}];};

I added the If statement. Originally, it does not have an If statement.

Original
this addEventHandler ["Hit", {[_this, 2, true] execVM "AdvancedPopUpTarget.sqf"}];

Here is the script (Credit should go to Worldeater):

#define ERROR_NOPOP hint str(__FILE__ + "\n\nERROR:\nThis script requires the global variable nopop to be true")

if isNil("nopop") exitWith { ERROR_NOPOP };
if not nopop      exitWith { ERROR_NOPOP };

_eventInfo    = _this select 0;
_requiredHits = _this select 1;
_stayDown     = _this select 2;

_target = _eventInfo select 0;
if (_target animationPhase "terc" > 0) exitWith {};

_hitCount = _target getVariable "HitCounter";
if isNil "_hitCount" then { _hitCount = 0 };

_hitCount = _hitCount + 1;
_keepUp = true;

if (_hitCount == _requiredHits) then {
	_hitCount = 0;
	_target animate ["terc", 1];
	sleep 3;
	_keepUp = not _stayDown;
};

if _keepUp then {
	_target animate ["terc", 0];
};

_target setVariable ["HitCounter", _hitCount];

 

Again, i do not take credit of the script, just wanted to give anyone willing to help an idea of what I am trying to do.

 

If we can create a completely new script, I am all game for that as well!

 

Thanks for the help!

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

×