Jump to content

Recommended Posts

2 minutes ago, HazJ said:

It won't add the scope in the vest for you. Not just by setting variable.

https://community.bistudio.com/wiki/addItem

https://community.bistudio.com/wiki/addItemToVest

No I know I have everything in the loadout setup like everything works, it's just the only thing that doesn't work is the Scope 1 = "optic" in key handler I can do it anywhere else

Share this post


Link to post
Share on other sites

Show me your WHOLE code.

Share this post


Link to post
Share on other sites
13 minutes ago, HazJ said:

Show me your WHOLE code.

 

Easier if I give you the mission

 

Download: https://drive.google.com/open?id=1Xs8Xs_VdqIzlFj5DCIjimvCq5N5liYXd

 

Assign gear assigns all the items

Defineclasses has all the classnames etc

keys is the key handler i'm using

 

(if you load up the mission only select blufor)

Share this post


Link to post
Share on other sites

keys.sqf? Again:

22 minutes ago, HazJ said:

It won't add the scope in the vest for you. Not just by setting variable.

https://community.bistudio.com/wiki/addItem

https://community.bistudio.com/wiki/addItemToVest

You need to add the optic in key handler!

This is what your keys.sqf currently looks like:

waituntil {!isnull (finddisplay 46)};
_keyDown = (findDisplay 46) displayAddEventHandler ["KeyDown", {
_KeyCode = _this select 1;
_Shift = _this select 2;
_Ctrl = _this select 3;
_Alt = _this select 4;
_handled = false;

    switch (_KeyCode) do 
	{
		
		case 2: {
			if (Scope1 isEqualTo "optic_hamr") then // IF set to "optic_hamr" which is the RCO optic
			{
				// set to "optic_arco" which is ARCO optic
				Scope1 = "optic_arco";
				hintSilent format ["Scope1 changed to %1", Scope1];
			} else
			{
				// set to "optic_hamr" IF NOT set to RCO
				Scope1 = "optic_hamr";
				hintSilent format ["Scope1 changed to %1", Scope1];
			};
		};
    };
    _handled;
}];

 

Share this post


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

keys.sqf? Again:

You need to add the optic in key handler!

This is what your keys.sqf currently looks like:


waituntil {!isnull (finddisplay 46)};
_keyDown = (findDisplay 46) displayAddEventHandler ["KeyDown", {
_KeyCode = _this select 1;
_Shift = _this select 2;
_Ctrl = _this select 3;
_Alt = _this select 4;
_handled = false;

    switch (_KeyCode) do 
	{
		
		case 2: {
			if (Scope1 isEqualTo "optic_hamr") then // IF set to "optic_hamr" which is the RCO optic
			{
				// set to "optic_arco" which is ARCO optic
				Scope1 = "optic_arco";
				hintSilent format ["Scope1 changed to %1", Scope1];
			} else
			{
				// set to "optic_hamr" IF NOT set to RCO
				Scope1 = "optic_hamr";
				hintSilent format ["Scope1 changed to %1", Scope1];
			};
		};
    };
    _handled;
}];

 

Do you mean under the _handled or somewhere else?

Share this post


Link to post
Share on other sites

Dude, come on! I have explained it in pretty much plain detail. Besides, it isn't hard to put 1 + 1 together. Please try to READ what I say. Check the links i provide in the previous post as well. Inside the if statement.

			if (Scope1 isEqualTo "optic_hamr") then // IF set to "optic_hamr" which is the RCO optic
			{
				// set to "optic_arco" which is ARCO optic
				Scope1 = "optic_arco";
				player addItemToVest "optic_arco";
				hintSilent format ["Scope1 changed to %1", Scope1];
			} else
			{
				// set to "optic_hamr" IF NOT set to RCO
				Scope1 = "optic_hamr";
				player addItemToVest "optic_hamr";
				hintSilent format ["Scope1 changed to %1", Scope1];
			};

This will keep adding those items. You can do checks to see if item is already in vest. You can also ditch the Scope1 variable and replace it with vestItems command. I also recommend you use setVariable + getVariable on each client if you need to have variables. For this though, you can use vestItems commands as said.

https://community.bistudio.com/wiki/vestItems

Bookmark these:

https://community.bistudio.com/wiki/Category:Scripting_Commands_Arma_3

https://community.bistudio.com/wiki/Category:Arma_3:_Functions

https://community.bistudio.com/wiki/Arma_3:_Event_Handlers

https://community.bistudio.com/wiki/User_Interface_Event_Handlers

Share this post


Link to post
Share on other sites
22 minutes ago, HazJ said:

Dude, come on! I have explained it in pretty much plain detail. Besides, it isn't hard to put 1 + 1 together. Please try to READ what I say. Check the links i provide in the previous post as well. Inside the if statement.


			if (Scope1 isEqualTo "optic_hamr") then // IF set to "optic_hamr" which is the RCO optic
			{
				// set to "optic_arco" which is ARCO optic
				Scope1 = "optic_arco";
				player addItemToVest "optic_arco";
				hintSilent format ["Scope1 changed to %1", Scope1];
			} else
			{
				// set to "optic_hamr" IF NOT set to RCO
				Scope1 = "optic_hamr";
				player addItemToVest "optic_hamr";
				hintSilent format ["Scope1 changed to %1", Scope1];
			};

This will keep adding those items. You can do checks to see if item is already in vest. You can also ditch the Scope1 variable and replace it with vestItems command. I also recommend you use setVariable + getVariable on each client if you need to have variables. For this though, you can use vestItems commands as said.

https://community.bistudio.com/wiki/vestItems

Bookmark these:

https://community.bistudio.com/wiki/Category:Scripting_Commands_Arma_3

https://community.bistudio.com/wiki/Category:Arma_3:_Functions

https://community.bistudio.com/wiki/Arma_3:_Event_Handlers

https://community.bistudio.com/wiki/User_Interface_Event_Handlers

I have read everything you said, tried everything you said... try the mission file for yourself and you will probably see what I am trying to do.

Share this post


Link to post
Share on other sites

No. No need to try. I saw your keys.sqf and even posted it above in previous post. My last post again said what you need to do. Did you even try it? If so. Show code of the file. All of it.

 

EDIT: Even if you have the optics in vest to start with. You still need to equip them.

  • Like 1

Share this post


Link to post
Share on other sites

There is a fundamental misunderstanding of how mission files work here.

 

 In order to define unit classes/loadouts for the mission,  init.sqf calls defineclasses.sqf:

Line 145: 	[] call compile preprocessFileLineNumbers "defineclasses.sqf";

You are trying to dynamically edit defineclasses.sqf (and therefore that which it defines) after it has been run. This won't work for obvious reasons.

 

What is it you want to accomplish, exactly?

Share this post


Link to post
Share on other sites
1 hour ago, Harzach said:

What is it you want to accomplish, exactly?

 

Exactly.

Still confused since the first post is all about _weapon and dialog listbox, on page 2 it's about weapon scopes and key eventhandlers.

 

Cheers

  • Like 1

Share this post


Link to post
Share on other sites

From what I gathered from his posts. It seems on key press the optic is changed. Either added or pulled from vest which was created in loadout file. Both of these I have gave him info on how to do this.

  • Like 1

Share this post


Link to post
Share on other sites
6 hours ago, HazJ said:

From what I gathered from his posts. It seems on key press the optic is changed. Either added or pulled from vest which was created in loadout file. Both of these I have gave him info on how to do this.

 

He's currently attempting to change a variable in script that is compiled at mission init, during gameplay. Rather, he has replaced a classname in a loadout script with his variable Scope1 in the hopes of changing that inventory item on-the-fly.

 

The mission is Dynamic Take and Secure by @galzohar

  • Confused 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

×