Overwriting clientside use

Is this even possible?

I’d like to do something where if the player holds use for more than 0.5 seconds, a UI element pops up. Otherwise, if they release it before 0.5 seconds, normal player use behavior occurs. I’ve tried hooking CreateMove, KeyRelease, KeyPress, but none of these seem like what I need.

I think you could hook KeyPress and check the time it would take for KeyRelease to occur.

I don’t know if there’s an actual way to see how long someone’s holding it besides something like that.

local nohold = CurTime()
hook.Add(“Think”, “stuff”, function()
if input.IsKeyDown(KEY_G) do
if CurTime() >= nohold + 0.5 then
–held down key for .5 seconds
nohold = CurTime()

or that

The thing is, I need to block use while its held down, and AFAIK a KeyRelease hook wont be called if IN_USE is being blocked during CreateMove. Just checking to see if the key down isn’t the issue, sorry if I wasn’t more clear on that.

Learn to explain shit next time you make a crap thread.

That still doesn’t BLOCK use though

Learn to explain shit next time you make a crap thread.

Don’t come in my thread and rate me dumb, faggot, I can’t be held liable for your incompetence.

(User was banned for this post ("flaming" - postal))

Just make it so that GM:PlayerUse() returns if the key is down or if the key has been pressed and not released.

I’d rather just scrap the idea all together then have the server involved in clientside HUD shit. It looks like that’s the only way to do it though.

Well the PlayerUse hook is serverside and it’s the only way to block it.

Yeah, that’s what I’m saying. You’d think you’d be able to just block it clientside.

Something like this:

local keyTime     = 0;local threshold = 0.35;
local allowUse  = false;

local function BlockUse(cmd)
    local buttons = cmd:GetButtons();
    local pressingUse = bit.band(buttons, IN_USE) == IN_USE;

    if allowUse then
        allowUse = false;
        buttons  = bit.bor(buttons, IN_USE);
    elseif pressingUse && not allowUse then
        keyTime  = keyTime + FrameTime();
        buttons  = buttons - IN_USE;
        if keyTime > 0 && keyTime < threshold then
            allowUse = true;
        keyTime = 0;

hook.Add("CreateMove", "RadialBlockUse", BlockUse);

This actually works, but the use only gets processed about 20% of the time…

Is there any way to force (from the client) the player to USE?