jens198 0 Posted September 23, 2009 Hi folks, I got a little addEventhandler problem. I'm working on a little rifle range script and everything works fine so far. I check wether the the target is hit or not by using the addeventhandler (hit) command. _rtarget addEventHandler ["hit", {range_man sideChat "Target hit";}]; This line perfectly tells me if the target is hit or not. In addition I want to count the targets hit with a counter-variable (_count). _rtarget addEventHandler ["hit", {range_man sideChat "Target hit";}]; _rtarget addEventHandler ["hit", {_counter = _counter + 1";}]; Won't do it. _rtarget addEventHandler ["hit", {range_man sideChat "Target hit"; _counter = _counter + 1";}]; Won't do it either. So, I'm a little bit puzzled here. Any ideas how to solve this? Jens Share this post Link to post Share on other sites
seba1976 98 Posted September 23, 2009 Before the big ones here give you the answer, let me open up with this. I think you should not use _variable because the underscore refers to local variables. What you need is to update global scoped variables, so try your last example without the underscores. Share this post Link to post Share on other sites
poweruser 10 Posted September 23, 2009 Additional to making the counter variable a global one, you need to initialise it before it starts to count. in the init script and maybe in radio trigger to reset the counter. counter = 0; _rtarget addEventHandler ["hit", { counter = counter + 1"; range_man sideChat format["Target hit, hits so far: %1", counter];}]; Share this post Link to post Share on other sites
jens198 0 Posted September 25, 2009 Thanks guys, using a public variable solved my problem. Jens Share this post Link to post Share on other sites