Jump to content
Frenki

How to create addAction wich is usable limited number of times?

Recommended Posts

Guys has anyone got idea how i can create addAction button wich i can use for example 10 times and than it delete itself. I am making mission and i want to rearm my RHS M2 Static from backpack, but becouse there is no magazines for it in game i need to improvise with add action on my backpack from wich i will rearm it but i want to make it limited number of times.

Share this post


Link to post
Share on other sites

Maybe something like this:

 

player setVariable ["mgMags", 10];


_id = player addAction ["<t color='#f4ee42'>Reload</t>", 
{
hint format["Reloading! %1", (player getVariable ["mgMags", 0])];

// <------------------- Insert weapon reloading code here!

player setVariable ["mgMags", (player getVariable ["mgMags", 0]) - 1]; 

}, nil, 1.5, true, true,"","(player getVariable ['mgMags', 0]) > 0",3];

 

Share this post


Link to post
Share on other sites

Looks intresting but where did you defined wich weapon and with wich ammo to reload it, i am using:

 

mitraljez addMagazineTurret ["rhs_mag_100rnd_127x99_mag_Tracer_Red",[0]];

mitraljez addMagazineTurret ["rhs_mag_100rnd_127x99_mag_Tracer_Red",[0]];

 

I am not so good with code, but if i get it properly i can put an animation for reload also so it looks like something is happening.

Share this post


Link to post
Share on other sites
36 minutes ago, Frenki said:

Looks intresting but where did you defined wich weapon and with wich ammo to reload it, i am using:

 

I didn't but you can insert your code there. Updating my post to show where...

Share this post


Link to post
Share on other sites

everytime you click the action the variable goes up by 1, once you click it the 10th time the action is no longer there

player setVariable ["actionUsed", 0, false];

object addAction ["Click me",
{
	params ["_object", "_me"];
	_count = _me getVariable ["actionUsed", 0];
	if (_count <= 10) then
	{
		_me setVariable ["actionUsed", _count + 1, false];
		//put script to do the magazine thing here(didnt read rest of thread)
	};
	if (_count isEqualTo 10) then {removeAllActions _object};
}];

 

  • Thanks 1

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

×