Jump to content
draoth

How to increase a local variable within an eventhandler? (Not solved)

Recommended Posts

Welcome,

To keep this short :

_hit = 0

I want this variable to increase everytime the object _Str been hit.

 

_Str addEventHandler ["HitPart",{_hit = _hit + 1}]; 

This doesn't work because the EH doesn't know the localvariable.

 

_Str addEventHandler ["HitPart",{hit = hit + 1}]; 

This does work because it is a globalvariable. But i need it to be a localvariable, because there are 200 objects that are being spawned using the same variable.  

 

waitUntil {_Hit > 3}; 
deletevehicle _Str; 

I want the obj to delete itself after being hit 3 times.

 

Is there workaround that i can use? Or maby a different way to approach this? 

 

Draoth

 

Share this post


Link to post
Share on other sites

 

 Cant you just have the eventhandler call a function that handles the hit=hit+1? Thats what i do

Share this post


Link to post
Share on other sites
21 hours ago, froggyluv said:

 

 Cant you just have the eventhandler call a function that handles the hit=hit+1? Thats what i do

Can you explain it? I don't really know what you mean by that? 

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

×