![]() |
|
input._KEY_* problem - Printable Version +- Team Spartan Cookies & Milk Forums (https://teamscm.co.uk) +-- Forum: Garry's Mod (https://teamscm.co.uk/forum-4.html) +--- Forum: Starfall (https://teamscm.co.uk/forum-7.html) +--- Thread: input._KEY_* problem (/thread-2348.html) |
input._KEY_* problem - The17thDoctor - 24-06-2017 So i was trying to reproduce an E2 in SF and this E2 used an input to trigger , so i tried using input.KEY_ but it seems this function is totally broke with like examples when i use
It would do return a value only when pressing the W key or the CTRL key. The keys seems totally scrambled , i asked Link320 and arrived at the same conclusion , is that a bug or something ? If it is , let me know that and could you fix it ? Thank you
RE: input._KEY_* problem - TheOneAndOnlyTee - 24-06-2017 the specific inputs such as any letter are for clientside input and it's not a bug, the server only listens to the buttons you have bound in your settings so you'll have to either use one of those or the bind hook and then set a custom bind that key. I might be wrong tho so someone correct me if I am. RE: input._KEY_* problem - Person8880 - 25-06-2017 This is not a bug. The player keyDown() and keyUp() methods only accept input.IN_* values, as they only track bound keys as T-18 said. It even says that in the documentation. RE: input._KEY_* problem - The17thDoctor - 25-06-2017 (25-06-2017, 10:07 AM)Person8880 Wrote: This is not a bug. Ok thanks. RE: input._KEY_* problem - 4N0NYM - 25-06-2017 Well but still there is something strange, Keys like "W" or "S" works fine but when i want to use keys like "B" it dont work. oh with key W S or B i mean : input.KEY_W input.KEY_S input.KEY_B RE: input._KEY_* problem - Person8880 - 25-06-2017 It's not doing what you think it's doing. Both the KEY_* and IN_* values are numbers. In the case of the IN_*, it's actually powers of 2 which are used as a bitflag to check for keys pressed. Thus when you pass KEY_W in (whose value is 33), you're actually checking if either input 1 (primary attack) or input 32 (use button) are down. RE: input._KEY_* problem - 4N0NYM - 25-06-2017 ok could you maybe make a exemplare how it would work ? because i dont get it :/ RE: input._KEY_* problem - Person8880 - 25-06-2017 It's for input buttons, so:
RE: input._KEY_* problem - Kosmos - 26-06-2017 If you want to be extra fancy you could record all pressed buttons using the "playerbuttondown" hook (which should run on the server too). For the client you can obviously use "input.isButtonDown". Without ever having used custom player functions (except for testing this code), here's how I imagine it would look (you're encouraged to modify this so it only tracks the buttons you need): Code: local Player = starfall.getTypeDef("Player")
function Player:buttonDown(btn)
local buttons = self[Player.buttonDown]
if not buttons then return false end
return buttons[btn] or false
end
hook.add("PlayerButtonDown", tostring(Player.buttonDown), function(plr, btn)
local buttons = plr[Player.buttonDown]
if not buttons then
buttons = {}
plr[Player.buttonDown] = buttons
end
buttons[btn] = true
end)
hook.add("PlayerButtonUp", tostring(Player.buttonDown), function(plr, btn)
local buttons = plr[Player.buttonDown]
if buttons then buttons[btn] = nil end
end)
hook.add("think", "", function()
if ents.owner():buttonDown(input.KEY_B) then
error("LEL")
end
end) |