Jump to content
Sign in to follow this  
bobby budnick

addaction inside of eventhandler in init

Recommended Posts

I have been trying to add an action to a unit after he respawns.  I have tried 2 different ways to do this with no success.

First way:

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">

this addeventhandler ["killed", {"this addaction (""Drop Chopper"", ""paradrop.sqs"")"}];

This is in the unit's init line.  

When he respawns the action is not added.  There are no errors.

Second way:

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">

this addeventhandler ["killed", {"_this exec (""addaction.sqs"")"}];

This is in the unit's init line.

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">

_unit = _this select 0

_unit addAction ["Drop Chopper", "paradrop.sqs", _unit, 0, false, false, ""];

This is in the script.

When he respawns the action is not added.  There are no errors.

Any ideas on this?

Share this post


Link to post
Share on other sites

add a repeating trigger

in the condition put (alive unitsname)

in the activation put the addaction that works in the units init line.

also remove the one from the units init line or you will have 2 actions

at mission start.

Share this post


Link to post
Share on other sites

Thanks for the help. My initial intent was to do it the cleaner way with eventhandlers and just add one line to each player and leave it at that. Apparently, it doesn't work that way. But, as this has been carrying on for too long, I just added triggers for everyone that I wanted to add an action for as you suggested.

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  

×