`Get Control Instructional Button` returns last 'correct' key when passed a hexadecimal value

  1. Client (production/canary) and FXServer version
    • Beta b3095
    • FXServer-master SERVER v1.0.0.7290 win32
  2. What you expected to happen
    • When passed a hexadecimal value after converting a command used by RegisterKeyMapping, GetControlInstructionalButton should return a value that matches the current key the command is mapped to.
      • E.g. if testCommand is mapped to V, GetControlInstructionalButton should return t_V.
  3. What actually happens
    • The last valid value is returned.
      • E.g. if you pass 8 to GetControlInstructionalButton, then pass 0x34BAA173 (testCommand mapped to V), it returns t_S instead of t_V.
  4. Category of bug (eg. client, server, weapons, peds, native)
    • client
    • native
  5. Reproducible steps, preferably with example script(s)
-- Note: Replace `0x34BAA173` with a valid `RegisterKeyMapping` entry, converted to hexadecimal

local buttonOne = GetControlInstructionalButton(2, 52)
local buttonTwo = GetControlInstructionalButton(2, 0x34BAA173)
local buttonThree = GetControlInstructionalButton(2, 38)
local buttonFour = GetControlInstructionalButton(2, 0x34BAA173)

return buttonOne .. " - " .. buttonTwo .. " - " .. buttonThree .. " - " .. buttonFour

Expected output: t_Q - t_V - t_E - t_V
Actual output: t_Q - t_Q - t_E - t_E

Dumb title

Ignore the spaced-out title, as always, Discourse does not like me.

1 Like

This works fine for me:

RegisterKeyMapping("+tst", "test", "KEYBOARD", "A")

RegisterCommand("+tst", function(src,args,raw)
	local buttonOne = GetControlInstructionalButton(2, 52)
	local buttonTwo = GetControlInstructionalButton(2, GetHashKey("+tst") | 0x80000000)
	local buttonThree = GetControlInstructionalButton(2, 38)
	local buttonFour = GetControlInstructionalButton(2, GetHashKey("+tst") | 0x80000000)

	print( buttonOne .. " - " .. buttonTwo .. " - " .. buttonThree .. " - " .. buttonFour )
end, false)

image

Edit: b3095 canary

2 Likes

Looks like I was missing the secret sauce, or in this case, the | 0x80000000.

I was attempting to use this tutorial which went about getting the input hash a different way. I’ll pop a comment on there for anyone else in the future that has the same problem lol…

Thanks @Kiminaze :call_me_hand:

1 Like