Jump to content
bumyplum

Knock Down Script HELP

Recommended Posts

So i'm attempting to create a knockdown script with the key bindings of Shift + G which complicates things due to it attempting to throw grenades. At the moment i've got a script which stops the player from throwing the grenade and the grenade animation works as a knock down one, how ever grenades thrown after also don't work, i'm asking how would i disable the grenade whilst the player presses shft + g how ever when the player presses g by it's self throws a grenade, this is the script i have at the moment:

 

(findDisplay 46) displayRemoveEventHandler ["KeyUp",_event]; 
_event = (findDisplay 46) displayAddEventHandler ["KeyUp",{  
  _key = _this select 1; 
  _shift = _this select 2; 
  if(_key == 34 && _shift) then {


[]spawn Wigma_NoFrag;
  }; 
 }]; 


Wigma_NoFrag = {
NoFrag = player addEventHandler["Fired",{
_Throwables = [
"HandGrenadeMuzzle",
"MiniGrenadeMuzzle",
"ChemlightBlueMuzzle",
"ChemlightGreenMuzzle",
"ChemlightRedMuzzle",
"ChemlightYellowMuzzle",
"IRGrenade",
"SmokeShellMuzzle",
"SmokeShellYellowMuzzle",
"SmokeShellGreenMuzzle",
"SmokeShellRedMuzzle",
"SmokeShellPurpleMuzzle",
"SmokeShellOrangeMuzzle",
"SmokeShellBlueMuzzle"
];
if((_this select 2) in _Throwables) then{deleteVehicle (_this select 6)}
}];
player removeEventHandler ["Fired", NoFrag];
};
 

 

 

 

 

How ever at the moment it doesn't work as with the event handler being removed it still throws the grenade with shift + g.

Share this post


Link to post
Share on other sites
TRUE; // override

Please use code tags. You basically created two threads for completely same thing as both were relevant to one. See above.This will override default functionality for your key bind, Shift + G. Use KeyDown.

THIS IS THE LAST TIME I am gonna do it for you. Starting to get the impression you just want it all done for you. Also, sending me a PM for my Discord to be your personal solution (what I got from that) isn't ideal. I don't mind getting PMs. It is just more beneficial to everyone if you use the forums for their purpose.

(findDisplay 46) displayAddEventHandler ["KeyDown",
{
	params ["_display", "_key", "_shift", "_ctrl", "_alt"];
	if (_key isEqualTo 0x22 && _shift) then // 0x22 = G (only G, if you want to bind it to actual control Throw Grenade key, see actionKeys link below...)
	{
		hintSilent "Player knocked out.";
		// Your code... Whatever.
		cursorObject playMoveNow "AmovPercMstpSrasWrflDnon_AmovPpneMstpSrasWrflDnon"; // makes cursorObject go prone...
		// Adjust to whatever you need.
		TRUE;
	};
}];

Start reading the Wiki and getting familiar with it. Start off small, don't leap in.

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

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

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

Share this post


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

TRUE; // override

Please use code tags. You basically created two threads for completely same thing as both were relevant to one. See above.This will override default functionality for your key bind, Shift + G. Use KeyDown.

THIS IS THE LAST TIME I am gonna do it for you. Starting to get the impression you just want it all done for you. Also, sending me a PM for my Discord to be your personal solution (what I got from that) isn't ideal. I don't mind getting PMs. It is just more beneficial to everyone if you use the forums for their purpose.


(findDisplay 46) displayAddEventHandler ["KeyDown",
{
	params ["_display", "_key", "_shift", "_ctrl", "_alt"];
	if (_key isEqualTo 0x22 && _shift) then // 0x22 = G (only G, if you want to bind it to actual control Throw Grenade key, see actionKeys link below...)
	{
		hintSilent "Player knocked out.";
		// Your code... Whatever.
		cursorObject playMoveNow "AmovPercMstpSrasWrflDnon_AmovPpneMstpSrasWrflDnon"; // makes cursorObject go prone...
		// Adjust to whatever you need.
		TRUE;
	};
}];

Start reading the Wiki and getting familiar with it. Start off small, don't leap in.

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

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

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

I don't want it done for me, i'd far prefer to do it my self and i spent several hours trying, however im newish to coding and can't wrap my head around certain things, I appreciate everything you say as it helps me in the longer run, thanks.

Share this post


Link to post
Share on other sites

Okay. Tip: When posting, try explaining what you've done already, what didn't and how, etc... This will at least show you've tried more than just explaining the overall issue. I know I seem I'm coming across harsh because I am (LOL) but that's because I like to encourage people to do it themselves and learn. Did you get it working anyway? Do you also understand the code I posted? If not, just say so I can explain. It is always better to understand it, that way you learn and understand the code then can tweak in future / make it again on your own.

Share this post


Link to post
Share on other sites
On 2/23/2019 at 7:01 PM, HazJ said:

Okay. Tip: When posting, try explaining what you've done already, what didn't and how, etc... This will at least show you've tried more than just explaining the overall issue. I know I seem I'm coming across harsh because I am (LOL) but that's because I like to encourage people to do it themselves and learn. Did you get it working anyway? Do you also understand the code I posted? If not, just say so I can explain. It is always better to understand it, that way you learn and understand the code then can tweak in future / make it again on your own.

I havn't finished the script due to lack of knowledge on how to get it to work, I've got to the point where i want the player your supposedly knocking down to be unconscious for a certain time period, how ever i am unable to do so, i've attempted to use this script:
 [] spawn {
   _pla = cursorTarget;   
   _pla setUnconscious true;
   sleep 10.32;
   _pla setUnconscious false;
    };

Which seems to work on Ai how ever doesn't work on players which confuses me

Share this post


Link to post
Share on other sites
5 minutes ago, bumyplum said:

I havn't finished the script due to lack of knowledge on how to get it to work, I've got to the point where i want the player your supposedly knocking down to be unconscious for a certain time period, how ever i am unable to do so, i've attempted to use this script:
 [] spawn {
   _pla = cursorTarget;   
   _pla setUnconscious true;
   sleep 10.32;
   _pla setUnconscious false;
    };

Which seems to work on Ai how ever doesn't work on players which confuses me

Are you testing the command in multiplayer? I'm not sure about the cursorTarget command, but I think it should return the cursorTarget (as long as it is known to the player) regardless of locality.

If you are testing this on yourself, obviously, you should change the first line to: _pla = player. Also, when you run this, the camera must be on the player. If for some reason it's not (e.g during a cutscene), you can save the original player to a variable (e.g myPlayer = player) before switching the camera, then use that variable instead.

Share this post


Link to post
Share on other sites
1 minute ago, Leopard20 said:

Are you testing the command in multiplayer? I'm not sure about the cursorTarget command, but I think it should return the cursorTarget (as long as it is known to the player) regardless of locality.

If you are testing this on yourself, obviously, you should change the first line to: _pla = player. Also, when you run this, the camera must be on the player. If for some reason it's not (e.g during a cutscene), you can save the original player to a variable (e.g myPlayer = player) before switching the camera, then use that variable instead.

I am running it locally whilst looking at a player

Share this post


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

I am running it locally whilst looking at a player

Dunno...maybe you're pointing at the player's weapon? Also test cursorObject, see if you have any luck.

Share this post


Link to post
Share on other sites
5 minutes ago, Leopard20 said:

Dunno...maybe you're pointing at the player's weapon? Also test cursorObject, see if you have any luck.

I've just tested cursorOject and cursorTarget and made sure i was looking at the play and both seem to not work

Share this post


Link to post
Share on other sites
2 hours ago, bumyplum said:

 [] spawn {
   _pla = cursorTarget;   
   _pla setUnconscious true;
   sleep 10.32;
   _pla setUnconscious false;
    };

Which seems to work on Ai how ever doesn't work on players which confuses me

I think variables need to be local. Try:

[_pla, true/false] remoteExec ["setUnconscious", _pla];

 

Share this post


Link to post
Share on other sites
21 hours ago, Spatsiba said:

I think variables need to be local. Try:


[_pla, true/false] remoteExec ["setUnconscious", _pla];

 

Thank you for the knowledge, much appreciated

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

×