Team Spartan Cookies & Milk Forums
  • Issue Tracker
  • Donations
  • Search
  • Member List
  • Help

Register

Team Spartan Cookies & Milk Forums Garry's Mod Starfall v
« Previous 1 … 7 8 9 10 11 … 18 Next »
input._KEY_* problem
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Threaded Mode
input._KEY_* problem
24-06-2017, 11:24 PM, (This post was last modified: 24-06-2017, 11:25 PM by The17thDoctor.)
#1
The17thDoctor Offline
TSCM Average Enjoyer
****
Posts: 1,100
Threads: 249
Joined: Oct 2015
Exclamation  input._KEY_* problem
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

 if ents.owner():keyDown(input.KEY_B) then
whatever()

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 Smile

The17thDoctor: Server take me to the most handsome person
srcds_linux: I cant send people to themselves...
Website Find
Reply
24-06-2017, 11:37 PM,
#2
TheOneAndOnlyTee Offline
GMod Admin
Posts: 755
Threads: 47
Joined: Oct 2013
RE: input._KEY_* problem
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.

Steam Profile
My Discord Server
Need help with E2 or SF? , just ask me and i'll try to help.
[Image: 98Dkcoz.gif]
Find
Reply
25-06-2017, 10:07 AM,
#3
Person8880 Offline
gpj.ecafllorT
*******
Posts: 2,407
Threads: 45
Joined: Sep 2013
RE: input._KEY_* problem
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.
Find
Reply
25-06-2017, 11:36 AM,
#4
The17thDoctor Offline
TSCM Average Enjoyer
****
Posts: 1,100
Threads: 249
Joined: Oct 2015
RE: input._KEY_* problem
(25-06-2017, 10:07 AM)Person8880 Wrote: 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.

Ok thanks.

The17thDoctor: Server take me to the most handsome person
srcds_linux: I cant send people to themselves...
Website Find
Reply
25-06-2017, 03:56 PM, (This post was last modified: 25-06-2017, 04:12 PM by 4N0NYM.)
#5
4N0NYM Offline
absens
****
Posts: 561
Threads: 211
Joined: Dec 2014
RE: input._KEY_* problem
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
Find
Reply
25-06-2017, 04:39 PM,
#6
Person8880 Offline
gpj.ecafllorT
*******
Posts: 2,407
Threads: 45
Joined: Sep 2013
RE: input._KEY_* problem
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.
Find
Reply
25-06-2017, 05:53 PM,
#7
4N0NYM Offline
absens
****
Posts: 561
Threads: 211
Joined: Dec 2014
RE: input._KEY_* problem
ok could you maybe make a exemplare how it would work ? because i dont get it :/
Find
Reply
25-06-2017, 07:42 PM,
#8
Person8880 Offline
gpj.ecafllorT
*******
Posts: 2,407
Threads: 45
Joined: Sep 2013
RE: input._KEY_* problem
It's for input buttons, so:
if ents.owner():keyDown( input.IN_FORWARD ) then
-- Player is holding their move forward key (usually W)
end
Find
Reply
26-06-2017, 01:14 PM,
#9
Kosmos Offline
GMod Admin
Posts: 180
Threads: 3
Joined: Dec 2013
RE: input._KEY_* problem
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)
Find
Reply
« Next Oldest | Next Newest »


  • View a Printable Version
Forum Jump:


Users browsing this thread: 1 Guest(s)
Contact UsTeam Spartan Cookies & MilkReturn to TopLite (Archive) ModeMark all forums readRSS Syndication

Powered By MyBB, © 2002-2026 MyBB Group.