Jump to content
  • 0

Need help switching weapons


Zelik

Question

I have been trying to make a right click option for pistols, I want to be able to switch to the pistol by right clicking it. I have tried many different ways but nothing has worked. I could use some help. I thought that i could use this syntax.

Private ["_Current","_Secondary"]
_Current = currentWeapon player;
_Secondary = secondaryWeapon player;
if ((_Current) != _Secondary)
then 
{player selectWeapon _Secondary;} 
else 
{ //Whatever else here }

Any info on this subject is needed. Thanks in advance. I have looked and looked for workarounds for this but have came up short every time.

FYI, I have all of the right click scripts installed on my server, I can get scripts to run via the right click menu, I just need help with this particular coding.

Edited by Zelik
Link to comment
Share on other sites

20 answers to this question

Recommended Posts

  • 0

Maybe something like this

closeDialog 0;
_current = currentWeapon player;
_primary = primaryWeapon player;
_secondary = secondaryWeapon player;

if (_current == _primary) then {
	player selectWeapon _secondary;
} else { 
	cutText ["You are already holding a secondary weapon!","PLAIN"];
};
Link to comment
Share on other sites

  • 0

 

Maybe something like this

closeDialog 0;
_current = currentWeapon player;
_primary = primaryWeapon player;
_secondary = secondaryWeapon player;

if (_current == _primary) then {
	player selectWeapon _secondary;
} else { 
	cutText ["You are already holding a secondary weapon!","PLAIN"];
};

Your cutText code is working when I am already switched to the secondary but not the selectWeapon part. Any clues? Is the syntax correct? Thanks in advance.

Link to comment
Share on other sites

  • 0

Did you get any errors? Check client .rpt or add -showScriptErrors to your start parameters.

14:05:18 bin\config.bin/CfgMovesZombie/States/AmovPercMrunSnonWnonDfr.InterpolateTo: item count not multiple of 2 (is 17)
14:05:18   bin\config.bin/CfgMovesZombie/States/AmovPercMrunSnonWnonDfr.InterpolateTo: Bad move 
14:05:18 bin\config.bin/CfgMovesZombie/States/AmovPpneMrunSnonWnonDl.InterpolateTo: item count not multiple of 2 (is 9)
14:05:18   bin\config.bin/CfgMovesZombie/States/AmovPpneMrunSnonWnonDl.InterpolateTo: Bad move 
14:05:18 bin\config.bin/CfgMovesZombie/States/AmovPpneMrunSnonWnonDb.InterpolateTo: item count not multiple of 2 (is 9)
14:05:18   bin\config.bin/CfgMovesZombie/States/AmovPpneMrunSnonWnonDb.InterpolateTo: Bad move 
14:05:18 bin\config.bin/CfgMovesZombie/States/AmovPpneMrunSnonWnonDbr.InterpolateTo: item count not multiple of 2 (is 9)
14:05:18   bin\config.bin/CfgMovesZombie/States/AmovPpneMrunSnonWnonDbr.InterpolateTo: Bad move 
14:05:18 bin\config.bin/CfgMovesZombie/States/AmovPpneMrunSnonWnonDfr.InterpolateTo: item count not multiple of 2 (is 11)
14:05:18   bin\config.bin/CfgMovesZombie/States/AmovPpneMrunSnonWnonDfr.InterpolateTo: Bad move 
14:05:18   bin\config.bin/CfgMovesZombie/States/AinvPknlMstpSnonWnonDnon_medic.ConnectTo: Bad move AinvPknlMstpSnonWnonDnon_medicEnd
14:05:18   bin\config.bin/CfgMovesZombie/States/AinvPknlMstpSnonWnonDnon_medic.ConnectTo: Bad move AinvPknlMstpSnonWnonDnon_medic0S
14:05:18   bin\config.bin/CfgMovesZombie/States/AinvPknlMstpSnonWnonDnon_medic.ConnectTo: Bad move AinvPknlMstpSnonWnonDnon_medic0
14:05:18   bin\config.bin/CfgMovesZombie/States/AinvPknlMstpSnonWnonDnon_medic.ConnectTo: Bad move AinvPknlMstpSnonWnonDnon_medic1
14:05:18   bin\config.bin/CfgMovesZombie/States/AinvPknlMstpSnonWnonDnon_medic.ConnectTo: Bad move AinvPknlMstpSnonWnonDnon_medic2
14:05:18   bin\config.bin/CfgMovesZombie/States/AinvPknlMstpSnonWnonDnon_medic.ConnectTo: Bad move AinvPknlMstpSnonWnonDnon_medic3
14:05:18   bin\config.bin/CfgMovesZombie/States/AinvPknlMstpSnonWnonDnon_medic.ConnectTo: Bad move AinvPknlMstpSnonWnonDr_medic3
14:05:18   bin\config.bin/CfgMovesZombie/States/AinvPknlMstpSnonWnonDnon_medic.ConnectTo: Bad move AinvPknlMstpSnonWnonDr_medic4
14:05:18   bin\config.bin/CfgMovesZombie/States/AinvPknlMstpSnonWnonDnon_medic.ConnectTo: Bad move AinvPknlMstpSnonWnonDr_medic5
14:05:18   bin\config.bin/CfgMovesZombie/States/AinvPknlMstpSnonWnonDnon_medic.ConnectTo: Bad move AinvPknlMstpSnonWnonDnon_medic4
14:05:18   bin\config.bin/CfgMovesZombie/States/AinvPknlMstpSnonWnonDnon_medic.ConnectTo: Bad move AinvPknlMstpSnonWnonDnon_medic5
14:05:18   bin\config.bin/CfgMovesZombie/States/AinvPknlMstpSnonWnonDnon_medic.ConnectTo: Bad move AinvPknlMstpSnonWnonDr_medic0S
14:05:18   bin\config.bin/CfgMovesZombie/States/AinvPknlMstpSnonWnonDnon_medic.ConnectTo: Bad move AinvPknlMstpSnonWnonDr_medic0
14:05:18   bin\config.bin/CfgMovesZombie/States/AinvPknlMstpSnonWnonDnon_medic.ConnectTo: Bad move AinvPknlMstpSnonWnonDr_medic1
14:05:18   bin\config.bin/CfgMovesZombie/States/AinvPknlMstpSnonWnonDnon_medic.ConnectTo: Bad move AinvPknlMstpSnonWnonDr_medic2
14:05:18   bin\config.bin/CfgMovesZombie/States/AinvPknlMstpSnonWnonDnon_medic.InterpolateTo: Bad move AinvPknlMstpSnonWnonDnon_medic0S
14:05:18   bin\config.bin/CfgMovesZombie/States/AinvPknlMstpSnonWnonDnon_medic.InterpolateTo: Bad move AinvPknlMstpSnonWnonDr_medic0S
14:07:01 "get: STRING (134757638), sent: STRING (134757638)" 

These are the errors I get from the right click option.

Link to comment
Share on other sites

  • 0

 

This should work.

closeDialog 0;
_current = currentWeapon player;
_primary = primaryWeapon player;

if (_current == _primary) then {
	player action ["handGunOn", player];	
} else { 
	cutText ["You are already holding a secondary weapon!","PLAIN"];
};

Giving it a try now, thanks.

Link to comment
Share on other sites

  • 0

 

This should work.

closeDialog 0;
_current = currentWeapon player;
_primary = primaryWeapon player;

if (_current == _primary) then {
	player action ["handGunOn", player];	
} else { 
	cutText ["You are already holding a secondary weapon!","PLAIN"];
};

Your code works but, the handGunOn action "plays" immediately, couldn't I use the waituntil?

//Example:
waitUntil player action ["handGunOn", player]; 

Not sure the syntax but something like that? Thanks in advance

Link to comment
Share on other sites

  • 0

So "handGunOn" doesn't have the gun swap animation. Well, beats me. I wonder why player selectWeapon doesn't work. You could always use Switchmove and play the animation first but sounds much more complicated than it should be.

Link to comment
Share on other sites

  • 0

 

This should work.

closeDialog 0;
_current = currentWeapon player;
_primary = primaryWeapon player;

if (_current == _primary) then {
	player action ["handGunOn", player];	
} else { 
	cutText ["You are already holding a secondary weapon!","PLAIN"];
};

I think it may work if I add sleep like lmapper said, I believe the animation is being interrupted by the else section of the code. Sleeping for about 3 seconds should allow the action to complete before the rest of the code is called. What do you think? I haven't tried it yet but, it sounds very plausible. By the way, thank you for the help. I appreciate it very much. 

Link to comment
Share on other sites

  • 0

Good. What did you end up with?

closeDialog 0;
_current = currentWeapon player;
_primary = primaryWeapon player;

if (_current == _primary) then {
	player action ["WeaponOnBack", player] //puts primary weapon on your back
	sleep 1; //waits long enough to finish animation
	player action ["handGunOn", player]; //switches to pistol
	sleep 1; //extra wait, just in case the animation is interrupted, via movement etc.
} else { 
	cutText ["You are already holding a secondary weapon!","PLAIN"];
};
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...