RED 0 Posted March 17, 2003 Is there any reason for an eventhandler to be added more than once? I am adding my handler with this: </span><table border="0" align="center" width="95%" cellpadding="3" cellspacing="1"><tr><td>Code Sample </td></tr><tr><td id="CODE">"_x addEventHandler [""hit"", {_this exec {injured.sqs}}]" forEach units group1<span id='postcolor'> Injured.sqs: </span><table border="0" align="center" width="95%" cellpadding="3" cellspacing="1"><tr><td>Code Sample </td></tr><tr><td id="CODE"> _unit = _this select 0 _unit removeAllEventHandlers "hit" ~random 2 _unit sidechat "Test" <span id='postcolor'> I can see that the event has been triggered more than once as the unit activates the sidechat when the script is executed. Sometimes I only get one sidechat message from the unit, others I get two or three messages. This leads me to believe that the units "damage level" is still dropping when the event is triggered, causing the unit to trigger the event again, is this correct? This is a big problem for me so I would be happy if someone could tell me where I am going wrong, thanks. RED Share this post Link to post Share on other sites
uiox 0 Posted March 17, 2003 It's a problem of syntax coz this works : {_x addEventHandler ["Killed", { If ({alive _x} count units G1 <= 6) then {deleteVehicle (_this select 0)} }]} foreach units g1 Share this post Link to post Share on other sites
Doolittle 0 Posted March 17, 2003 I find "Hit" and "Dammaged" to not be 100% reliable. Â For example, unload a full clip on a helicopter & it will never activate. Â Hit it with a Sabot and it will. Â And sometimes "Dammaged" goes off once, twice, three times...I suppose from splash damage?? Doolittle Share this post Link to post Share on other sites
RED 0 Posted March 17, 2003 Right, I will do some more tests then. Thanks Doolittle and Uiox, any more suggestions? RED Share this post Link to post Share on other sites
RED 0 Posted March 18, 2003 Bump, suma do you have any comments on this? RED Share this post Link to post Share on other sites
Guest jacobaby Posted March 18, 2003 The Hit handler will be triggered each time the unit is hit until it is killed AFAIK, so if you shoot him in the legs, heal him and shoot him again, it will keep triggering. The result of the EH is not boolean but Scalar. if you can change the firing condition to a boolean value you may get a more consistent response. I use hint format [etc etc] to give me the values of the EH while I am testing them, do this to find out the value then incorporate a value check in the firing line, along the lines of; ? this select 1 >0.7 then blah blah. I cant see why the EH would still be working after you remove it though, maybe a timing issue. TJ Share this post Link to post Share on other sites
RED 0 Posted March 18, 2003 An interesting idea, I will test that out a bit later. The purpose of my script is to have units that are damaged join a group of injured soldiers , I use: ?this select 1 >0.4: [_this select 1] join injured The code is slightly different but you should get the idea. I am still confused as to why the hit event would occur more than once, I will test to see if it makes any difference as to what weapon is used. RED Share this post Link to post Share on other sites
suma 8 Posted April 7, 2003 </span><table border="0" align="center" width="95%" cellpadding="3" cellspacing="1"><tr><td>Quote (Doolittle @ Mar. 17 2003,19:34)</td></tr><tr><td id="QUOTE">I find "Hit" and "Dammaged" to not be 100% reliable. Â For example, unload a full clip on a helicopter & it will never activate. Â Hit it with a Sabot and it will. Â And sometimes "Dammaged" goes off once, twice, three times...I suppose from splash damage??<span id='postcolor'> Both "Hit" and "dammaged" can be triggered several times. With dammaged the reason is quitle clear: various parts of solider (vehicle) body can be dammged, and with various degree - each of them triggering appropriate event. Similiar mechanism takes place with hit (you can get both direct and indirect hit from one bullet / shell). Share this post Link to post Share on other sites
RED 0 Posted April 7, 2003 Thanks Suma, I will have to think of a workaround then. RED Share this post Link to post Share on other sites
Guest jacobaby Posted April 7, 2003 what about ? dammage >0.4 and this not in group : join group.... if ya get me...... Share this post Link to post Share on other sites
RED 0 Posted April 7, 2003 I have the units joining the new group correctly. Now the problem sometimes the radio message that is in the script gets activated twice because of the script activating more than once. RED Share this post Link to post Share on other sites
Guest BratZ Posted April 7, 2003 Using the "gear" eventhandler for custom gear,I notice that the gear functions don't always show in the useraction menu either. Share this post Link to post Share on other sites
Doolittle 0 Posted April 7, 2003 </span><table border="0" align="center" width="95%" cellpadding="3" cellspacing="1"><tr><td>Code Sample </td></tr><tr><td id="CODE"> Â Â "Gear" bool:gearState <span id='postcolor'> "Gear" only runs when you lower or raise the gear, it doesn't create addAction menus. Unless I misunderstand your question? Doolittle Share this post Link to post Share on other sites