- Joined
- Jul 18, 2010
- Messages
- 2,379
This is an working version of an idea: disabling the keyboard input for specific players. It works by giving the keyboard focus to an EditBox. That focus is reapplied multiple times a second.
This disabling can be bypassed by the user by spamming the esc Button, the wanted hotkey and a mouse click. Although it still requires multiple seconds and dozens of tries to use the hotkey (quite much effort for one activation). This does not block the mouse input.
after one uses:
This disabling can be bypassed by the user by spamming the esc Button, the wanted hotkey and a mouse click. Although it still requires multiple seconds and dozens of tries to use the hotkey (quite much effort for one activation). This does not block the mouse input.
Lua:
do
local timer = CreateTimer()
local frame
-- the players having hotkeys disabled
local disablePlayers = {}
TimerStart(timer, 0.0, false, function()
-- create the Frame keeping the Keyboard focus
frame = BlzCreateFrameByType("EDITBOX", "", BlzGetOriginFrame(ORIGIN_FRAME_GAME_UI, 0), "", 0)
BlzFrameSetSize(frame, 0.001, 0.001)
BlzFrameSetAbsPoint(frame, FRAMEPOINT_BOTTOMLEFT, 0.001, 0.001)
-- Reapply the focus to the frame for the wanted players
TimerStart(timer, 0.01, true, function()
if disablePlayers[GetLocalPlayer()] then
BlzFrameSetFocus(frame, true)
end
end)
end)
function DisableHotkeys(player, flag)
disablePlayers[player] = flag
if GetLocalPlayer() == player then
BlzFrameSetFocus(frame, flag)
BlzFrameSetVisible(frame, flag)
BlzFrameSetEnable(frame, flag)
end
end
end
DisableHotkeys(Player(0), true)
. Player Red won't be able to chat nor use any hotkey.