• 🏆 Texturing Contest #33 is OPEN! Contestants must re-texture a SD unit model found in-game (Warcraft 3 Classic), recreating the unit into a peaceful NPC version. 🔗Click here to enter!
  • It's time for the first HD Modeling Contest of 2024. Join the theme discussion for Hive's HD Modeling Contest #6! Click here to post your idea!

Disable User Keyboard input

Status
Not open for further replies.
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.
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
after one uses: DisableHotkeys(Player(0), true). Player Red won't be able to chat nor use any hotkey.
 
Level 6
Joined
Aug 28, 2015
Messages
213
Couldn't you use the mouse pressed and player skip cinematic natives to hook into to let the player focus again to your frame? So it should be impossible for them even with spam-clicking.
 
I got another more simple Idea to disable user input. One makes the Player an observer. As observers are not allowed to give orders.
Disable Input.
call SetPlayerState(Player(0), PLAYER_STATE_OBSERVER, 1)
Reverse the disabled Input
call SetPlayerState(Player(0), PLAYER_STATE_OBSERVER, 0)

Has some sideeffects though:
The player also can not trigger any sync events anymore (can't end it from the target player poistion).
It changes the upkeep text for that player.
The game saves the units one had selected before becoming a Observer and remembers it. Then when becoming a real Player again and giving Orders the remembered units will do the orders aswell (without being selected UI wise)
Until one selects and deselects them.
 
Last edited:
Status
Not open for further replies.
Top