Jump to content
🛡️FORUMS ARE IN READ-ONLY MODE Read more... ×
Sign in to follow this  
x3djokerx

MP addaction + remove action... help please?

Recommended Posts

Here is the scenerio. A side mission pops up in my mission. When that SM objective is done spawning I am running a script to add an action to plant c4 on it to blow it up. This is fine and works flawlessly. The problem I run into is that I want it to remove the action after 120 seconds, and then put it back on the object again after another 300 seconds.

here is the code I am using.....

functions.sqf

aw_fnc_MPaddAction = {
private["_object","_screenMsg","_scriptToCall"];
_object = _this select 0;
_screenMsg = _this select 1;
_scriptToCall = _this select 2;

if(isNull _object) exitWith {};

_object addaction [_screenMsg,_scriptToCall];
};

then when the sideObj is spawned, this is used to apply the addaction..

		sideMissionUp = true;
		publicVariable "sideMissionUp";
		_null = [] execVM "sm\smUp.sqf";
		//Wait until objective is destroyed
		waitUntil {sleep 0.5; !alive sideObj};

		sideMissionUp = false;
		publicVariable "sideMissionUp";


and finally the actual code to place the addaction on the object..

smUp.sqf

while {true} do {

   if (sideMissionUp) then {
   	sleep 300;
		[[sideObj,"<t color='#ffff00'>Place C4 Charge</t>","sm\sabotage.sqf"],"aw_fnc_MPaddAction",true,true] spawn BIS_fnc_MP;
		sleep 120;
		removeAllActions sideObj;
    } else {};
};

This is the problem though. It for some reason applies 2 addactions to the object. so the scroll wheel will show "place c4 charge" and the next line "place c4 charge"

and for testing if I drop the seconds to just 10 a piece it will end up creating 4-6 of the actions and then after they are removed, add 2 more right after.

What am I doing wrong? And also how would I make it so that when the action is used, it removes it from the list so they cannot use it multiple times.?

Any help would be greatly appreciated! Thank you in advance.

Share this post


Link to post
Share on other sites
Sign in to follow this  

×