Jump to content
  • 0

addAction help


oSoDirty

Question

I have an addaction in my fn_selfActions that triggers a script of... more addactions.

 

It all works well since once you move all but the fn_selfActions added actions are removed until said action is triggered again. These actions in turn run some simple hint menus.

 

My issue, which isnt a huge issue since you would only be trolling yourself by doing it, is. The addaction from fn_selfActions can be activated over and over spamming the action menus with duplicatesas long as you dont move.

 

Just being picky, i am looking for a way to either remove the original action menu once activated in turn revealing the other actions without having to scroll again, resetting once other actions are removed. or

Disable the original action once used until others are removed.

 

This is what im working with.

 

fn_selfActions lines are:

//rules start
if(speed player <= 1) then {
    if (s_rules < 0) then {
        s_rules = player addaction[("<t color=""#c70000"">" + ("Rules and Info") +"</t>"),"custom\rules\rules_init.sqf","",-3,false,false,"",""];
    };
} else {
    player removeAction s_rules;
    s_rules = -1;
    };
//rules end

works if im not walking, 

 

the init

if(speed player <= 0) then {
	_isDirty = true;
		if(_isDirty) then {
		_rule_set1 = player addAction["PVP","custom\rules\pvp.sqf","",-5,false,false,"",""];
		_rule_set2 = player addAction["Safezones","custom\rules\safezone.sqf","",-6,false,false,"",""];
		_rule_set3 = player addAction["Chat","custom\rules\chat.sqf","",-7,false,false,"",""];
		_rule_set4 = player addAction["Building","custom\rules\building.sqf","",-8,false,false,"",""];
		_rule_set5 = player addAction["Cheating","custom\rules\cheating.sqf","",-9,false,false,"",""];
		_rule_set6 = player addAction["Thanks","custom\rules\thanks.sqf","",-12,false,true,"",""];
		_rule_set7 = player addAction["Ts3","custom\rules\ts3.sqf","",-10,false,false,"",""];
		_rule_set8 = player addAction["Reporting","custom\rules\report.sqf","",-11,false,false,"",""];
		waitUntil { speed player > 0 };
			player removeAction _rule_set1;
			player removeAction _rule_set2;
			player removeAction _rule_set3;
			player removeAction _rule_set4;
			player removeAction _rule_set5;
			player removeAction _rule_set6;
			player removeAction _rule_set7;
			player removeAction _rule_set8;
			_rule_set1 = -1;
			_rule_set2 = -1;
			_rule_set3 = -1;
			_rule_set4 = -1;
			_rule_set5 = -1;
			_rule_set6 = -1;
			_rule_set7 = -1;
			_rule_set8 = -1;
			};
		};
	};
};

 

I have looked around google, the wiki, and a few forums and tried a few things but no luck.

I'm sure i have looked at it in my searches and it just went over my head. Pardon my noobishness =]

 

Any info or suggestions?

 

Any help would be great.

Link to comment
Share on other sites

2 answers to this question

Recommended Posts

  • 0

yeah, first of all in your variables.ini under 

dayz_resetSelfActions = {

you have to put 

s_rules = -1;

This is where you initialize your values, so you dont get the nasty "Undefined variable" error.

Ok...so what this does is for the first time when fn_self_action runs it will actually go into your

if (s_rules < 0) then {
    s_rules = player addaction[("<t color=""#c70000"">" + ("Rules and Info") +"</t>"),"custom\rules\rules_init.sqf","",-3,false,false,"",""];
};

since s_rules = -1.

 

Now...how to remove the extra addactions....

There are 2 'places' in the fn_selfactions where you can add stuff...One is before this line here:

if (!isNull cursorTarget && !_inVehicle && !_isPZombie && (player distance cursorTarget < _allowedDistance) && _canDo) then {

and one is inside it. You add actions before it, for things that dont require a 'some object in your crosshair', like a car or vault etc....and basically things you want activated when stuff happens...like a player picks up an object, has speed under 1 etc etc.

If you have to add an addaction though inside this if, for example lets say you were adding your action when a player was looking at a car......then you have to also add

player removeAction s_rules;
s_rules = -1;

this, at the bottom of the file inside the } else {   statement of the above if.

So when the player is not looking at an object, then the addaction will get removed...since it gets back its initial = -1 value...so its not true.

 

Now....back to your question...you want the action to disappear when you select something. That means you have to somehow reset that s_rules again to -1 so that it wont show again, and also remove the action itself.....and how to do that?

Well you have to do the same trick inside your action file now...since thats when you want it to disappear.

So open up your "custom\rules\rules_init.sqf"  file and at the top add:

player removeAction s_rules;
s_rules = -1;

and bam....the action is gone when you select the player selects Rules and Info.

 

So to recap, we have :

- The initial value in variables.sqf so you dont get errors

- Before the "if !isNull target" in fnselfactions you just need to add the initialize (=-1) again and player remove action, in your own else statement and inside the actual action file

- If you want the effect to happen when looking at an object, then you have to add the -1, and player remove action INSIDE the } else { section again, at bottom of fn_selfactions.

 

Hope that helps clear things through.

Link to comment
Share on other sites

  • 0

..............................................................

Hope that helps clear things through.

 

 

It was very helpful! Thank you!  I had only one issue which was in the rules_init  since i am also using player speed to add/removeAction in fn...., it would reappear as soon as it was removed by the  init.  so instead of

player removeAction s_rules;;
s_rules = -1;

i used

player removeAction s_rules;;
s_rules = 1;

and just after my  waitUntil i reset it to -1 and problem solved.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Discord

×
×
  • Create New...