Jump to content
  • 0

fn_selfActions Reset


ViktorReznov

Question

So after having my prior post answered for cursorTargets and arrays, Ive been able to progress my code further but cannot get it to reset my actions. All other parts of my code are working except for resetting it and while Ive had many mods and all of fn_selfActions.sqf to read through, ive been unable to solve it.

this is the code to modify Olmatechoc's chameleon skin changer to use wardrobes/closets to initialize the male/female dialogs (now seperated, no field sex changes!) to change skins, no sense in using a button or 40 lines of code to add the dialog to skins

Spoiler

if (VR_useWardrobe) then { //init variable set to true so one can decide if they want to use this or not
		_cursorTarget = cursorTarget; //sets cursor target
		_isWardrobe = (typeOf (_cursorTarget) in VR_arrayWardrobes); //returns if cursor target is defined in my array! thanks @Salival
		_isFemale = (typeOf (player) in VR_femaleSkins); //returns if player is a female from array of skins
		if ((_isWardrobe) && (player distance _cursorTarget < 5)) then { // if cursor target is in wardrobe array and if player is within 5m of it
			if (s_changing_room < 0)) then { //self action variable 
				if (!_isFemale)) then { //if male then >
					s_changing_room = _cursorTarget addAction ["Men's Room","dayz_code\actions\SkinMenu\Male_Dialog.sqf",_cursorTarget, 0, true, true]; //addaction to wardrobe olmatechocs chameleon skin changer for males
					systemChat "Welcome to the Men's Room good sir!"; //just a little chat to show how many times its executing this! (there was a time it just kept executing)
					//s_changing_room = 1; //moved this all over trying to break the chain and reset the action
				};
				if (_isFemale) then { //if female then >
					s_changing_room = _cursorTarget addAction ["Gal's Room","dayz_code\actions\SkinMenu\Female_Dialog.sqf",_cursorTarget, 0, true, true]; //execute olmatechocs chameleon skin changer for females
					systemChat "Welcome to the Lady's Room ma'am!"; //just a little chat to show how many times its executing this! (there was a time it just kept executing)
					//s_changing_room = 1; //moved this all over trying to break the chain and reset the action
				};
			};	
		} else { //attempt to reset self action if cursorTarget is not wardrobe or if not within 5m
			_cursorTarget removeAction s_changing_room; //remove the action! This part is not working
			s_changing_room = -1; //reset the variable!
		};
	};

 

I have been working on this for the last few days and watched the code explode from a few lines to this jumbled mess, im at my wits end, i can get the code to either fire repeatedly and spam the action menu or just add the action every time you look at the object but it will not remove. I cannot figure out why and am looking for some explanation.

SO to clarify, code is working EXCEPT for removing the action, can someone help identify and explain where my code is wrong? TYVM!

Link to comment
Share on other sites

11 answers to this question

Recommended Posts

  • 0
20 minutes ago, ViktorReznov said:

So after having my prior post answered for cursorTargets and arrays, Ive been able to progress my code further but cannot get it to reset my actions. All other parts of my code are working except for resetting it and while Ive had many mods and all of fn_selfActions.sqf to read through, ive been unable to solve it.

this is the code to modify Olmatechoc's chameleon skin changer to use wardrobes/closets to initialize the male/female dialogs (now seperated, no field sex changes!) to change skins, no sense in using a button or 40 lines of code to add the dialog to skins

  Hide contents


if (VR_useWardrobe) then { //init variable set to true so one can decide if they want to use this or not
		_cursorTarget = cursorTarget; //sets cursor target
		_isWardrobe = (typeOf (_cursorTarget) in VR_arrayWardrobes); //returns if cursor target is defined in my array! thanks @Salival
		_isFemale = (typeOf (player) in VR_femaleSkins); //returns if player is a female from array of skins
		if ((_isWardrobe) && (player distance _cursorTarget < 5)) then { // if cursor target is in wardrobe array and if player is within 5m of it
			if (s_changing_room < 0)) then { //self action variable 
				if (!_isFemale)) then { //if male then >
					s_changing_room = _cursorTarget addAction ["Men's Room","dayz_code\actions\SkinMenu\Male_Dialog.sqf",_cursorTarget, 0, true, true]; //addaction to wardrobe olmatechocs chameleon skin changer for males
					systemChat "Welcome to the Men's Room good sir!"; //just a little chat to show how many times its executing this! (there was a time it just kept executing)
					//s_changing_room = 1; //moved this all over trying to break the chain and reset the action
				};
				if (_isFemale) then { //if female then >
					s_changing_room = _cursorTarget addAction ["Gal's Room","dayz_code\actions\SkinMenu\Female_Dialog.sqf",_cursorTarget, 0, true, true]; //execute olmatechocs chameleon skin changer for females
					systemChat "Welcome to the Lady's Room ma'am!"; //just a little chat to show how many times its executing this! (there was a time it just kept executing)
					//s_changing_room = 1; //moved this all over trying to break the chain and reset the action
				};
			};	
		} else { //attempt to reset self action if cursorTarget is not wardrobe or if not within 5m
			_cursorTarget removeAction s_changing_room; //remove the action! This part is not working
			s_changing_room = -1; //reset the variable!
		};
	};

 

I have been working on this for the last few days and watched the code explode from a few lines to this jumbled mess, im at my wits end, i can get the code to either fire repeatedly and spam the action menu or just add the action every time you look at the object but it will not remove. I cannot figure out why and am looking for some explanation.

SO to clarify, code is working EXCEPT for removing the action, can someone help identify and explain where my code is wrong? TYVM!

I've never understood the CORRECT way to properly do selfActions removal, different scripts do it one way and some the other.

The easiest way for me is to compare it to default epoch ones, i.e: https://github.com/EpochModTeam/DayZ-Epoch/blob/master/SQF/dayz_code/compile/fn_selfActions.sqf#L155-L166

So what that is doing in my opinion:

Checking if these conditions are met: 

if (_inVehicle && {_vehicle isKindOf "Air"} && {(([_vehicle] call FNC_getPos) select 2) < 30} && {speed _vehicle < 5} && {typeName _hasAttached == "OBJECT"}) then {

If they are, it adds the action, if they aren't it removes the action

The script it runs then does this: https://github.com/EpochModTeam/DayZ-Epoch/blob/master/SQF/dayz_code/actions/player_heliLift.sqf#L7-L8 (remove addaction, then set it to -1 so the fn_selfActions doesn't readd the action while running the external script.

This is my interpritation of it which may not be correct, these have always confused me and trial and error is how I do them.

Link to comment
Share on other sites

  • 0
24 minutes ago, JasonTM said:

You have extra parentheses here.


if (s_changing_room < 0)) then { //self action variable 
				if (!_isFemale)) then { //if male then >

Not sure if that will fix it, but start by correcting that.

ty, fixing that restored self actions to working and my code to spamming syschat without adding action.... fix one thing, break many others

Link to comment
Share on other sites

  • 0

Are you using skin names or player models? There is a difference. Skins are inventory and lootable items with skin_ in the classname. Player models do not have skin_. A cursorTarget would reference player model if you were pointing at a player character.

Link to comment
Share on other sites

  • 0
11 minutes ago, JasonTM said:

Are you using skin names or player models? There is a difference. Skins are inventory and lootable items with skin_ in the classname. Player models do not have skin_. A cursorTarget would reference player model if you were pointing at a player character.

this is that defined array

VR_femaleSkins = [
                "BanditW1_DZ","BanditW2_DZ","SurvivorW2_DZ","SurvivorW3_DZ","SurvivorWcombat_DZ","SurvivorWdesert_DZ","SurvivorWurban_DZ","SurvivorWpink_DZ"
                ];

switching the dialog from male to female is working, its just not removing the actions so my scroll actions, when looking at object defined in VR_arrayWardrobes, will add another action without removing prior actions.

Link to comment
Share on other sites

  • 0

@ViktorReznov If ure using it in fn_selfactions.sqf  you dont need define _cursortarget.  its already defined by default.  the systemchat msgs you can put them in the male_dialog.sqf/female_dialog.sqf

whats about

if (VR_useWardrobe) then { //a global variable defined by you in somewhere dont know.. init,variables,configvariables.
private ["_isWardrobe","_isFemale"];
_isWardrobe = (typeOf (_cursorTarget) in VR_arrayWardrobes); 
_isFemale = (typeOf (player) in VR_femaleSkins); 

if ((_isWardrobe) && (player distance _cursorTarget < 5)) then { 
if (s_changing_room < 0)) then { 
if (!_isFemale)) then { 
s_changing_room = player addAction ["Men's Room","dayz_code\actions\SkinMenu\Male_Dialog.sqf",_cursorTarget, 0, true, true]; 
}else{
s_changing_room = player addAction ["Gal's Room","dayz_code\actions\SkinMenu\Female_Dialog.sqf",_cursorTarget, 0, true, true]; 
};
};
} else { 
player removeAction s_changing_room; 
s_changing_room = -1; 
};
};

 

Link to comment
Share on other sites

  • 0
16 minutes ago, juandayz said:

@ViktorReznov If ure using it in fn_selfactions.sqf  you dont need define _cursortarget.  its already defined by default.  the systemchat msgs you can put them in the male_dialog.sqf/female_dialog.sqf

whats about


if (VR_useWardrobe) then { //a global variable defined by you in somewhere dont know.. init,variables,configvariables.
private ["_isWardrobe","_isFemale"];
_isWardrobe = (typeOf (_cursorTarget) in VR_arrayWardrobes); 
_isFemale = (typeOf (player) in VR_femaleSkins); 

if ((_isWardrobe) && (player distance _cursorTarget < 5)) then { 
if (s_changing_room < 0)) then { 
if (!_isFemale)) then { 
s_changing_room = player addAction ["Men's Room","dayz_code\actions\SkinMenu\Male_Dialog.sqf",_cursorTarget, 0, true, true]; 
}else{
s_changing_room = player addAction ["Gal's Room","dayz_code\actions\SkinMenu\Female_Dialog.sqf",_cursorTarget, 0, true, true]; 
};
};
} else { 
player removeAction s_changing_room; 
s_changing_room = -1; 
};
};

 

And there we go, that did it (fixed a couple of my extra parantheses). The code is working, what exactly needed to be changed and y? Id like to learn from this rather than be given answers so please explain good sir!

Finished product here, works with changing genders and everything

Spoiler

if (VR_useWardrobe) then { //a global variable defined by you in somewhere dont know.. init,variables,configvariables.
		private ["_isWardrobe","_isFemale"];
		_isWardrobe = (typeOf (_cursorTarget) in VR_arrayWardrobes); 
		_isFemale = (typeOf (player) in VR_femaleSkins); 

		if ((_isWardrobe) && (player distance _cursorTarget < 5)) then { 
			if (s_changing_room < 0) then { 
				if (!_isFemale) then { 
					s_changing_room = player addAction ["Men's Room","dayz_code\actions\SkinMenu\Male_Dialog.sqf",_cursorTarget, 0, true, true]; 
					systemChat "Welcome to the Men's Room good sir!"; //just a little chat to show how many times its executing this! (there was a time it just kept executing)
				}else{
					s_changing_room = player addAction ["Gal's Room","dayz_code\actions\SkinMenu\Female_Dialog.sqf",_cursorTarget, 0, true, true]; 
					systemChat "Welcome to the Lady's Room ma'am!"; //just a little chat to show how many times its executing this! (there was a time it just kept executing)
				};
			};
		} else { 
			player removeAction s_changing_room; 
			s_changing_room = -1; 
		};
	};

 

 

Link to comment
Share on other sites

  • 0
Quote

like to learn from this rather than be given answers so please explain good sir!

1-ok.. see you was defined _crusorTarget = cursorTarget;  (you dont need it.. if u see at top of fn_selfactions.sqf you will see:

_vehicle = vehicle player;
_inVehicle = (_vehicle != player);
_cursorTarget = cursorTarget;

2-This part:

if (!_isFemale)) then { 
};
if (_isFemale) then { 
};

you dont need define !_isFemale   and _isFemale.   the script assume that is not female  then is female...

so: 

if (!_isFemale) then {
}else{
//is female
};

3.-s_changing_room = _cursorTarget addAction ["Men's Room","dayz_code\actions\SkinMenu\Male_Dialog.sqf",_cursorTarget, 0, true, true];

Here you add the action "s_changing_room" to the cursor target(its not bad).. not to the player... this is good for change variables in objects or people who are the "_this select 0;"  like salivals do in his bury butcher or in take clothes...

but in this case you need add the action on player not in the wardrove... so:

_changing_room = player addAction ["Men's Room","dayz_code\actions\SkinMenu\Male_Dialog.sqf"];

 

4-and i have a question... you define in init.sqf

 VR_useWardrobe = true;

if u dont have other script who change it by false ... really you dont need it. (but i dont now)

 

Link to comment
Share on other sites

  • 0

so for example to get it a lil more clean...

first you dont need define it... you can use dayz_female

so remove it:

Spoiler

VR_femaleSkins = [
				"BanditW1_DZ","BanditW2_DZ","SurvivorW2_DZ","SurvivorW3_DZ","SurvivorWcombat_DZ","SurvivorWdesert_DZ","SurvivorWurban_DZ","SurvivorWpink_DZ"
				];

 

take oldma male_dialog.sqf

and change by:

Spoiler

if (!isNull (unitBackpack player)) exitWith { dayz_actionInProgress = false; cutText  [("Put your backpack and inventory in a storage item to change clothes"), "PLAIN DOWN"] };


if (typeOf player in DayZ_Female) then {
CHOCSKINS_CLOTHING_LIST = Female_Clothing;
}else{
CHOCSKINS_CLOTHING_LIST = Male_Clothing;
};

createDialog "ChooseSkin";

 

delete female_dialog.sqf

now in fn_selfactions.sqf

Spoiler

if (VR_useWardrobe) then {
if (_typeOfCursorTarget in VR_arrayWardrobes) then {
if (s_changing_room < 0)) then { 
_text = "dressRoom";
s_changing_room = player addAction [format["%1",_text], "dayz_code\actions\SkinMenus\Male_Dialog.sqf"];	
};

} else { 
player removeAction s_changing_room; 
s_changing_room = -1; 
};
};

 

 

 

Link to comment
Share on other sites

  • 0

Food for thought.

 

putting

player removeAction s_changing_room; 
s_changing_room = -1;

in the script the player runs will remove the scroll action when that code is being run.

eg.

In the fire dance script i shared you could scroll on a campfire and get an option to dance. If a player was dancing the option would be removed until the dance was finished.

also.

you could maybe try using

call dayz_resetSelfActions;

Make sure you have

s_changing_room = -1;

in your custom variables aswell.

Link to comment
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
  • Advertisement
  • Discord

×
×
  • Create New...