26.06.2007, 02:02
I'm not sure if this is where it goes, but I was lookign all over for this info and finally got some answers,
First off key values for players who are on foot are not the same as players who are in are car,
I couldnt' find the key values around here, so I found a funtion to get them, and labeled them as such,
On Foot:
--------
1=TAB
2=CROUCH
4=ATTACK
8=SPRINT
16=ENTER VEHICLE
32=JUMP
64=
(I couldn't find it)
128=AIM WEAPON
256=
(I couldn't find it)
512=LOOK BEHIND
1024=SNEAK/WALK
8192=LEFT ARROW(4) ON KEYPAD*
16384= RIGHT ARROR(6) ON KEYPAD*
In Vehicle:
----------
1=ATTACK
2=HORN/SIRENS
8=GAS
16=EXIT VEHICLE(EDIT: and I couldn't find this the first run lol)
32=FOOT BRAKE
64=LOOK RIGHT
128=HAND BRAKE
256=LOOK LEFT
320=LOOK BEHIND(Combo of LOOK RIGHT(64) and LOOK LEFT(256))
2048= DELETE & UP ARROW(8 ) ON KEYPAD*
4096= END & DOWN ARROW(2) ON KEYPAD*
8192=LEFT ARROW(4) ON KEYPAD*
16384=RIGHT ARROW(6) ON KEYPAD*
4=LEFT ALT(Sneak on foot for me)**
132=RIGHT Ctrl.**
512=PLUS(+) ON KEYPAD**
Keep in mind alot of these values can be added together, to catch two presses, if I am on foot and press 8=SPRINT + 1024=SNEAK/WALK my 'newkeys' would then equal 1032.
*Though these buttons did things, such as move the camera and change radio stations, but I don't know if these will be the same on everyones machine, as they are kinda sketchy, and I can change stations and move camera with mouse, and it doesn't return a value, and I know that
6144(UP(204
+DOWN(4096)) and
24576(LEFT(8192)+RIGHT(16384))
will not catch, maybe a smarter person can shed some light on them?
After looking over the defines, I'm thinking that these can hook someone using an analog controller(maybe?)
**These buttons didn't do anything, I'm thinking its more the buttons themselves, than what they do like the other values, like aiming your weapon will always come back as 128 no matter what key u have it bound to.
Anyway, I hope this helps someone, as I couldn't find this info anywhere, though maybe I'm not looking hard enough, lol.
EDIT:
I used [NB]Boylett's function,
to find the the key values, thanks Boylett 
EDIT:
After Y-Less's statement, I wanted to add in the key press defines from 'a_samp.inc'(included with pawno),
Though once agian, I will remind people, values for 'on foot' and 'in car' are not the same.
Example:
Above in my post, is one way around this problem.
I hope it helps someone...
pawn Code:
public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
{
//Put hooks for players in a car here
if(GetPlayerState(playerid) == PLAYER_STATE_ONFOOT){
// Put stuff for player on foot here
if (newkeys == 1032){//SPRINT(8) + SNEAK/WALK(1024)
SendClientMessage(playerid,0xFFFFFFFF,"You have hooked the combo");
return 1;
}
}
return 0;
}
I couldnt' find the key values around here, so I found a funtion to get them, and labeled them as such,
On Foot:
--------
1=TAB
2=CROUCH
4=ATTACK
8=SPRINT
16=ENTER VEHICLE
32=JUMP
64=

128=AIM WEAPON
256=

512=LOOK BEHIND
1024=SNEAK/WALK
8192=LEFT ARROW(4) ON KEYPAD*
16384= RIGHT ARROR(6) ON KEYPAD*
In Vehicle:
----------
1=ATTACK
2=HORN/SIRENS
8=GAS
16=EXIT VEHICLE(EDIT: and I couldn't find this the first run lol)
32=FOOT BRAKE
64=LOOK RIGHT
128=HAND BRAKE
256=LOOK LEFT
320=LOOK BEHIND(Combo of LOOK RIGHT(64) and LOOK LEFT(256))
2048= DELETE & UP ARROW(8 ) ON KEYPAD*
4096= END & DOWN ARROW(2) ON KEYPAD*
8192=LEFT ARROW(4) ON KEYPAD*
16384=RIGHT ARROW(6) ON KEYPAD*
4=LEFT ALT(Sneak on foot for me)**
132=RIGHT Ctrl.**
512=PLUS(+) ON KEYPAD**
Keep in mind alot of these values can be added together, to catch two presses, if I am on foot and press 8=SPRINT + 1024=SNEAK/WALK my 'newkeys' would then equal 1032.
*Though these buttons did things, such as move the camera and change radio stations, but I don't know if these will be the same on everyones machine, as they are kinda sketchy, and I can change stations and move camera with mouse, and it doesn't return a value, and I know that
6144(UP(204

24576(LEFT(8192)+RIGHT(16384))
will not catch, maybe a smarter person can shed some light on them?
After looking over the defines, I'm thinking that these can hook someone using an analog controller(maybe?)
**These buttons didn't do anything, I'm thinking its more the buttons themselves, than what they do like the other values, like aiming your weapon will always come back as 128 no matter what key u have it bound to.
Anyway, I hope this helps someone, as I couldn't find this info anywhere, though maybe I'm not looking hard enough, lol.
EDIT:
I used [NB]Boylett's function,
pawn Code:
public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
{
new string[STR];
format(string,STR,"You pressed key number %d", newkeys);
SendClientMessage(playerid,0xFFFFFFAA,string);
}

EDIT:
After Y-Less's statement, I wanted to add in the key press defines from 'a_samp.inc'(included with pawno),
pawn Code:
#define KEY_ACTION 1
#define KEY_CROUCH 2
#define KEY_FIRE 4
#define KEY_SPRINT 8
#define KEY_SECONDARY_ATTACK 16
#define KEY_JUMP 32
#define KEY_LOOK_RIGHT 64
#define KEY_HANDBRAKE 128
#define KEY_LOOK_LEFT 256
#define KEY_SUBMISSION 512
#define KEY_LOOK_BEHIND 512
#define KEY_WALK 1024
#define KEY_ANALOG_UP 2048
#define KEY_ANALOG_DOWN 4096
#define KEY_ANALOG_RIGHT 8192
#define KEY_ANALOG_LEFT 16384
#define KEY_UP -128
#define KEY_DOWN 128
#define KEY_LEFT -128
#define KEY_RIGHT 128
Example:
pawn Code:
public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
{
if (newkeys == KEY_HANDBRAKE){ //Would work fine if they were in a car, but if they were on foot, it would also hook every time they aimed their weapon
SendClientMessage(playerid,0xFFFFFFFF,"You have used the handbrake...or aimed your weapon..");
return 1;
}
return 0;
}
