Jump to content
Jordan Booth

How to make keyhandler run script once

Recommended Posts

I am trying to make it so that in game i can spawn an Ifrit with shift + i and it works however when i hold down the keys it spawn loads of Ifrits all around the player. How do i make it so that it only spawns one per key press?

This is what i am using at the moment:  Thanks in advance.

 

keyhandler.sqf:

 

KeyFunctions = [
        [[35,    true,    false,    false], "weaponholster.sqf"], 
        [[23,    true,    false,    false], "ifritspawn.sqf"],
        [[35,     false,    true,    false], "weaponunholster.sqf"]];
        

while {isNull(findDisplay 46)} do {sleep 0};
(findDisplay 46) displayAddEventHandler ["KeyDown", {
    private _kpd = _this select [1, 4];
    {_x params ["_key", "_scr"]; if (_key isEqualTo _kpd) exitWith {execVM _scr; true}; false;
    } forEach KeyFunctions;
}];

 

ifritspawn.sqf:

 

_veh = "O_MRAP_02_F" createVehicle(position player);
 

Share this post


Link to post
Share on other sites

Look keyup instead than keydown

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

×