Jump to content
Sign in to follow this  

Function / Script cannot be re-executed after terminate

Recommended Posts

Hi, I am using a function for conversations. It's defined in CfgFunctions and called via spawn command. Now I want to  archive that conversation stops if the unit (conversation partner) gets killed. The units with the conversation action are civilians, spawned dynamically via Engima's Civilians script.

I could do that with:

// inside attached action to all civilian units:

	...some code...
handle = [params] spawn createConversation;

// And this in unit's eventhandler:
if (not isNil {handle} and {not scriptDone handle}) then {
       terminate handle};

The problem is, when I want to start another conversation now with a different unit, the conversation (or better saying: the createConversation function) doesn't execute anymore. How can I make sure that the function gets executed again? As I understand, the terminate command fires when the spawned script is processed the next time by the scheduler. In my case it immediately stops the conversation when the civilian gets killed, but it seems to also terminating the next started conversation, and so on. I also tried it without the "killed" eventhandler, and instead in units callback (like init field) did this:

	// No conversations with dead civs
 	waitUntil {
  				// exit when unit gets deleted
  				if (isNull _unit) exitWith {true};

  				!alive _unit;
		sleep 1;
			_unit removeAction talk;
			if (not isNil {handle} and {not scriptDone handle}) then {
       terminate handle};

I couldn't find anything helpful... could someone help me, please? Thx 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