Jump to content
Sign in to follow this  
Nobody111

Using addAction in a while loop

Recommended Posts

Hey guys,

i have the following problem:

I want to create a script which gives the Player an "addAction" when he is facing one specific Trucktype. So when i use for example a while loop and a cursorTarget check the Player gets an Action every loop. I want it to give him only one Action, no matter how Long he is facing the Truck, but i want it to be removed at the time the Player faces away from the truck. 

Could someone give me a hint on how to solve this? 

Thank you guys and have a nice time!

  • Like 1

Share this post


Link to post
Share on other sites
1 minute ago, Nobody111 said:

Hey guys,

i have the following problem:

I want to create a script which gives the Player an "addAction" when he is facing one specific Trucktype. So when i use for example a while loop and a cursorTarget check the Player gets an Action every loop. I want it to give him only one Action, no matter how Long he is facing the Truck, but i want it to be removed at the time the Player faces away from the truck. 

Could someone give me a hint on how to solve this? 

Thank you guys and have a nice time!

 

You can add the truck type as a condition for the addAction to show, since using a loop would be way too clumsy for this:

player addAction ["Blow up car",{

	cursorObject setDamage 1;

	},[],0,true,true,"","typeOf cursorObject isEqualTo 'C_Offroad_01_F'"];

This is also the recommended way instead of adding actions to multiple objects, have the action run on the player and make the condition parameter match your criteria.

 

Cheers

  • Like 1

Share this post


Link to post
Share on other sites

Thank you Grumpy Old Man, this works fine for me! 

 

In this way i got another Question (sorry :D) 

The Action i add attaches objects to the Player. Now i want an other Action to be added which allows the Player to detach and delete These items. After the Player used this, i want the detach Action to disapear. The Problem with "removeAction" is, that the index for the addAction (detachaction) is rising every time the Player uses it. So the detachaction i added works, but does not disappear after the second use. Is there a possibility to realize my thought?

 

I hope my Explanation is Kind of understandable. 

Thanks you very much!

Share this post


Link to post
Share on other sites
3 minutes ago, Nobody111 said:

Thank you Grumpy Old Man, this works fine for me! 

 

In this way i got another Question (sorry :D) 

The Action i add attaches objects to the Player. Now i want an other Action to be added which allows the Player to detach and delete These items. After the Player used this, i want the detach Action to disapear. The Problem with "removeAction" is, that the index for the addAction (detachaction) is rising every time the Player uses it. So the detachaction i added works, but does not disappear after the second use. Is there a possibility to realize my thought?

 

I hope my Explanation is Kind of understandable. 

Thanks you very much!

You could set a variable to true once you've attached objects and put this variable in the condition of the second Action to detach the objects. Then in the detach action, you need to set the variable back to false.

Share this post


Link to post
Share on other sites

oh well thats Pretty obvious! :D Thank you very much for your help! it works like a Charme!

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  

×