Jump to content
Sign in to follow this  
Valfunction

globalExecute help

Recommended Posts

I am trying to make a script where you can arrest someone and them move them to a location. When you arrest them they should put their hands on their heads. I'm having problems conveying this part in MP. I tried using globalExecute and everything up to the globalExecute runs fine but then nothing happens within the globalExecute. What am I doing wrong?

_thisunit = _this select 0;

release1 = _thisunit addAction ["Release", "CIS\release.sqf"];

_thisunit attachTO [player,[.5,.5,0]];

[-2, {
_thisunit switchMove "";
_thisunit setUnitPos "UP";
_thisunit playActionNow "Surrender";
_thisunit disableAI "MOVE";
_thisunit disableAI "ANIM";
}] call CBA_fnc_globalExecute;

Share this post


Link to post
Share on other sites
_thisunit = _this select 0;
release1 = _thisunit addAction ["Release", "CIS\release.sqf"];
_thisunit attachTO [player,[.5,.5,0]];
[-1, {_this switchMove "";_this playActionNow "Surrender";_this disableAI "MOVE";_this disableAI "ANIM"},_thisunit] call CBA_fnc_globalExecute;

Share this post


Link to post
Share on other sites

Thanks heaps man. Took me a couple of reads of your script but I got where I was going wrong.

Just curious is there a way to do this using CBA eventHandlers? Something like:

_thisunit = _this select 0;
release1 = _thisunit addAction ["Release", "CIS\release.sqf"];
_thisunit attachTO [player,[.5,.5,0]];
["Arrest", {_this switchMove "";_this playActionNow "Surrender";_this disableAI "MOVE";_this disableAI "ANIM"}, _thisunit] call CBA_fnc_addEventHandler;
["Arrest"] call CBA_fnc_globalEvent;

Share this post


Link to post
Share on other sites

As long as you understand how they work. EV's are usually set up early and then used throughout the mission.

So somewhere in init you'd have something like this:

   ["TAG_Arrest", {
	_unit = _this select 0;
	_unit switchMove "";
	_unit playActionNow "Surrender";
	_unit disableAI "MOVE";
	_unit disableAI "ANIM"}
] call CBA_fnc_addEventHandler;

And then later on in addaction script or whatever

_thisunit = _this select 0;
release1 = _thisunit addAction ["Release", "CIS\release.sqf"];
_thisunit attachTO [player,[.5,.5,0]];
["TAG_Arrest",[_thisunit]] call CBA_fnc_globalEvent;

Share this post


Link to post
Share on other sites

Yeah the idea would be to set them up in a events.sqf and then reference them from there. The above was just a quick syntax check to see if I had the right understanding of the syntax for setting them up and then calling them. So thanks for your reply it sorts that out and I wasn't quite sure how to pass a variable with them so thanks again.

I don't have a deep understanding of event handlers. Which method would be best? Using globalExecute or creating and then calling events and why?

Share this post


Link to post
Share on other sites

With globalExecute you're sending code over the network instead of just parameters / variables. Its primarly designed to be used for debugging, so out of a optimization (bandwith) viewpoint, eventhandlers are better. Still it's quite common to see in scripts since it's considered easier to use, I've seen a lot of people having problems figuring out how to use event handlers.

If you know how to use event handlers, I'd recommend using them, especially if it's code that is supposed to run several times during a mission.

Share this post


Link to post
Share on other sites

Thanks guys this was most helpful. Seeing as this event might happen many times per mission I reckon I'll use event handlers (and they are better for bandwidth). I have a better understanding of event handlers now and will keep on learning about them as they seem the way to go.

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  

×