ravennx 0 Posted July 4, 2007 When its below 5 rounds. <table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">this addEventHandler ["fired",{if (count magazines this <5) then {[West, "HQ"] sideChat "[M119X6] OUT OF AMMO. TALK TO RESUPPLY OFFICER IN BASE TO REARM"}}] However this doesent work. any pointers? thanks ravennx Share this post Link to post Share on other sites
ManDay 0 Posted July 4, 2007 this addEventHandler ["fired",{if (count magazines<span style='color:red'>( _this select 0 )</span><5) then {[West, "HQ"] sideChat "[M119X6] OUT OF AMMO. TALK TO RESUPPLY OFFICER IN BASE TO REARM"}}] You have to understand that first an EH is assigned and the code you put there (for the eventhandler) is stored within the EH. It will be executed by the EH as soon as the condition hits. And when the evenhandler executes there will be no "THIS" you may use. So you have to look at the EH independently from the rest. http://community.bistudio.com/wiki/ArmA:_Event_Handlers#Fired of course, you may also use the right name instead of "_this select 0". For instance "arti1" if that's the name of the object. But don't be frustrated because your mistake is not that obiviious to you. In actual fact there are certain programming languages where this would work. Those language work by "replacive string interpretation" rather than by "code evaluation". For instance see TCL/TK (tcl.tk). Coding as such could (not nessesarily - but i may happen) first replace the "this" with the according name of the actual unit. but arma doesnt PS: Watch out while you go further: eventHandlers are added localy! so make sure they are added on the right clients if you want to play it in MP. put some semicolons in. finally i suggest you use eventhandlers with scripts. its more comprehensive. Share this post Link to post Share on other sites
ravennx 0 Posted July 5, 2007 great thanks for the reply.. i wont be writing scripts for a bit now that i sprained my wrist real bad. thanks again. ravennx Share this post Link to post Share on other sites
ravennx 0 Posted July 7, 2007 That still doesent work. I added it to the init field and it will trigger the radio message with every shot. I need it to count ammo since it has 30 rounds and no mags. Thanks RAvennX Share this post Link to post Share on other sites