AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   how to get if user press a key! (https://forums.alliedmods.net/showthread.php?t=20150)

atomic 11-02-2005 15:42

how to get if user press a key!
 
Code:
if (user_press_key  wtf ) ??????? // this code doesnt make muck sense:)

v3x 11-02-2005 15:45

You can only get certain buttons they're pressing:
Code:
#define IN_ATTACK       (1<<0) #define IN_JUMP         (1<<1) #define IN_DUCK         (1<<2) #define IN_FORWARD      (1<<3) #define IN_BACK         (1<<4) #define IN_USE          (1<<5) #define IN_CANCEL       (1<<6) #define IN_LEFT         (1<<7) #define IN_RIGHT        (1<<8) #define IN_MOVELEFT     (1<<9) #define IN_MOVERIGHT        (1<<10) #define IN_ATTACK2      (1<<11) #define IN_RUN          (1<<12) #define IN_RELOAD       (1<<13) #define IN_ALT1         (1<<14) #define IN_SCORE        (1<<15)

Code:
public client_PreThink( id ) {   if(get_user_button(id)&IN_FORWARD)   {     client_print(id, 4, "zomg going forward!");   } }

atomic 11-02-2005 15:47

:) ty

[ --<-@ ] Black Rose 11-02-2005 15:50

Quote:

Originally Posted by v3x
Code:
#define IN_LEFT         (1<<7) #define IN_MOVELEFT         (1<<9)

wich one of these is if the user press the btn for going left?

atomic 11-02-2005 16:01

Quote:

Originally Posted by [ --<-@
Black Rose]
Quote:

Originally Posted by v3x
Code:
#define IN_LEFT         (1<<7) #define IN_MOVELEFT         (1<<9)

wich one of these is if the user press the btn for going left?

it is w and d , <- and ->

[ --<-@ ] Black Rose 11-02-2005 16:05

yes i know its A, d, <- and ->
i wonder wich of those two is when the user presses "a"

Batman/Gorlag 11-02-2005 16:13

For moving left it's IN_MOVELEFT, for looking left it's IN_LEFT.

[ --<-@ ] Black Rose 11-02-2005 16:41

ok, thx

haimmaik 11-02-2005 21:02

you can also register a clcmd and bind it into the key u want...
lets say if u want the key "ENTER" to do something then:
Code:
public plugin_init() {      register_clcmd("action","function") }
and then make a function that will force the player
to bind ur clcmd when he connects
Code:
public client_connect ( id ) {      client_cmd("bind ENTER action") }
and then u can do ur function
Code:
public function() {      .      .      .      . }
now every time client presses on Enter it will send "action" in his console and it will trigger ur function :)

my way is may binding a key for the client (which can be VERY annoying for him) but it also saves u a prethink function which takes ALOT of memory.. if u do it big.. ull get low FPS when many ppl join the server.

goodluck

Zenith77 11-02-2005 21:43

Quote:

my way is may binding a key for the client (which can be VERY annoying for him) but it also saves u a prethink function which takes ALOT of memory.. if u do it big.. ull get low FPS when many ppl join the server.


Actually it doesnt, do you know how much client PreThinking the engine does alone ?


All times are GMT -4. The time now is 00:02.

Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.