Disable Spacebar - CommandMode ?

KrisiS

Member
Hi,

Can someone help me to disable the CommandMode which is accessed by pressing the spacebar.
With infistar running, the admins cannot access this via spacebar but the general players can.

I want to make it so that no-one can use the spacebar to scan the horizon and identify others.

Any help is greatly appreciated :)


I have tried this script but it doesn't seem to work:

init.sqf
Code:
[] execVM "Scripts\disableCommandMode.sqf";

disableCommandMode.sqf
Code:
if (isNull player) exitwith {} ;
//Borrowed heavily from Le_culto's technique to stop people using the command-mode

CMbindings = [];
CMoffbindings=[];
CMblocking =false ;

cam ;

updateKeyBindings =
{
     while {true} do {
      CMbindings = actionKeys "ForceCommandingMode";
      CMoffbindings= actionKeys "menuBack";
      sleep 2;
     };
};

check = {
     {
      if ((_x in CMbindings) and (! CMblocking)) then {
          
           CMBlocking = true ;
           titleText ["Please don't use command-mode in this game\nPress backspace to restore vision...",
              "Black Out"] ;
           cam = "camera" camCreate [0,0,100] ; ;
           cam cameraEffect ["Internal","Back"] ;
           cam camSetTarget [0,0,0] ;
           cam camCommit 0 ;

      } ;

      if ((_x in CMoffbindings) and (CMblocking)) then {
          
           titleText ["Thank you","Black in"] ;
           player cameraEffect ["terminate","back"];
           camDestroy cam ;
           CMBlocking = false ;
      } ;
     
     } forEach _this;
};

grenadeModeTimer=0 ;

grenadeSelect={
     if (time -grenadeModeTimer > 0.5) then {
      //The first time the button is pressed assume
      //that handgrenades are wanted but start a timer
      //to look for a double-tap
      grenadeModeTimer=time ;
      player selectWeapon "handGrenadeMuzzle" ;
      //after 2 seconds then switch back to primary weapon
      sleep 2 ;
      //put a check here because we the user might have
      //pressed space slowly or even a third time
      if (time-grenadeModeTimer >=2) then {
           player selectWeapon primaryWeapon player ;
      } ;
     } else {
      //If the space bar is tapped twice quickly
      //then switch to smoke shells
      player selectWeapon "SmokeShellMuzzle" ;
     
     } ;
} ;

//
//I don't know why a delay is necessary :-(
sleep 5;
(FindDisplay 46) DisplaySetEventHandler [
     "keydown",
     " _r = false ; if ((_this select 1) in CMbindings) then {[] spawn grenadeSelect;_r=true;};_r;"
     ];

[] call updateKeyBindings ;
 
Top