[Plugin] IsKeyDown(vkey) function in PAWN
#1

This is a SERVER-ONLY key detection plugin. it detects only if the keys are pressed on the SERVER and not clients. This will NOT detect keypresses from people's games.


FIXED VERSION COMING SOON
Description

Hi, today I want to release my first plug-in. It was VERY EASY to make, and I didn't understand why no-one made a plugin like this.

The function is:

pawn Код:
IsKeyDown(vkey);
And it detects most of the keys on your keyboard. I tested it with OnPlayerUpdate, and it worked fine.

Example gamemode

pawn Код:
// Example/Test of IsKeyDown plug-in

#include <a_samp>
#include <IsKeyDown>

main() {}

public OnGameModeInit()
{
    SetGameModeText("PluginTest");
    AddPlayerClass(0, 1958.3783, 1343.1572, 15.3746, 269.1425, 38, 1000, 0, 0, 0, 0);
    return 1;
}

public OnPlayerUpdate(playerid)
{
  if(IsKeyDown(VK_ALT)) SendClientMessage(playerid, 0x00FF00FF, "You are holding ALT");
  if(IsKeyDown(VK_CTRL)) SendClientMessage(playerid, 0x00FF00FF, "You are holding CTRL");
  return 1;
}
This is not the best example, because it spams a lot of time that message, but it would work great with other functions. You can also make your own callback with this function to replace OnPlayerKeyStateChange.

Defined Keys

I haven't defined all the keys, but the most important are in the include file:

pawn Код:
//Mouse
#define VK_LEFTBUTTON 0x01
#define VK_RIGHTBUTTON 0x02
#define VK_MIDBUTTON 0x04

//Keyboard
#define VK_CANCEL 0x03
#define VK_BACKSPACE 0x08
#define VK_TAB 0x09
#define VK_CLEAR 0x0C
#define VK_ENTER 0x0D
#define VK_SHIFT 0x10 //Any of the 2 shift keys
#define VK_LSHIFT 0xA0 //Left Shift Key
#define VK_RSHIFT 0xA1 //Right shift key
#define VK_CTRL 0x11 //Any of the 2 control keys
#define VK_LCTRL 0xA2 //Left control key
#define VK_RCTRL 0xA3 //Right control key
#define VK_ALT 0x12
#define VK_CAPSLOCK 0x14
#define VK_ESCAPE 0x1B
#define VK_SPACE 0x20
#define VK_LEFT 0x25
#define VK_UP 0x26
#define VK_RIGHT 0x27
#define VK_DOWN 0x28
#define VK_SELECT 0x29
#define VK_INSERT 0x2D
#define VK_DELETE 0x2E
#define VK_HELP 0x2F

//Keyboard Numbers
#define VK_KEYB0 0x30
#define VK_KEYB1 0x31
#define VK_KEYB2 0x32
#define VK_KEYB3 0x33
#define VK_KEYB4 0x34
#define VK_KEYB5 0x35
#define VK_KEYB6 0x36
#define VK_KEYB7 0x37
#define VK_KEYB8 0x38
#define VK_KEYB9 0x39

//Numpad
#define VK_NUMLOCK 0x90
#define VK_NUMPAD0 0x60
#define VK_NUMPAD1 0x61
#define VK_NUMPAD2 0x62
#define VK_NUMPAD3 0x63
#define VK_NUMPAD4 0x64
#define VK_NUMPAD5 0x65
#define VK_NUMPAD6 0x66
#define VK_NUMPAD7 0x67
#define VK_NUMPAD8 0x68
#define VK_NUMPAD9 0x69
#define VK_MULTIPLY 0x6A
#define VK_ADD 0x6B
#define VK_SEPARATOR 0x6C
#define VK_SUBTRACT 0x6D
#define VK_DECIMAL 0x6E
#define VK_DIVIDE 0x6F

//Function Keys
#define VK_F1 0x70
#define VK_F2 0x71
#define VK_F3 0x72
#define VK_F4 0x73
#define VK_F5 0x74
#define VK_F6 0x75
#define VK_F7 0x76
#define VK_F8 0x77
#define VK_F9 0x78
#define VK_F10 0x79
#define VK_F11 0x7A
#define VK_F12 0x7B
#define VK_F13 0x7C
#define VK_F14 0x7D
#define VK_F15 0x7E
#define VK_F16 0x7F
#define VK_F17 0x80
#define VK_F18 0x81
#define VK_F19 0x82
#define VK_F20 0x83
#define VK_F21 0x84
#define VK_F22 0x85
#define VK_F23 0x86
#define VK_F24 0x87

//Letters
#define VK_A 0x41
#define VK_B 0x42
#define VK_C 0x43
#define VK_D 0x44
#define VK_E 0x45
#define VK_F 0x46
#define VK_G 0x47
#define VK_H 0x48
#define VK_I 0x49
#define VK_J 0x4A
#define VK_K 0x4B
#define VK_L 0x4C
#define VK_M 0x4D
#define VK_N 0x4E
#define VK_O 0x4F
#define VK_P 0x50
#define VK_Q 0x51
#define VK_R 0x52
#define VK_S 0x53
#define VK_T 0x54
#define VK_U 0x55
#define VK_V 0x56
#define VK_W 0x57
#define VK_X 0x58
#define VK_Y 0x59
#define VK_Z 0x5A
Download

Source + DLL + Include

Pastebin

Credits

- [GF]Sasino97 for the plug-in
- Microsoft for Visual Studio 2010
- RyDeR' for the tutorial
- SA-MP for existing
- Mediafire
Reply


Messages In This Thread
IsKeyDown(vkey) function in PAWN - by Sasino97 - 13.07.2011, 12:51
Re: IsKeyDown(vkey) function in PAWN - by boelie - 13.07.2011, 13:00
Re: IsKeyDown(vkey) function in PAWN - by Sasino97 - 13.07.2011, 13:03
Re: IsKeyDown(vkey) function in PAWN - by boelie - 13.07.2011, 13:05
Re: IsKeyDown(vkey) function in PAWN - by BaubaS - 13.07.2011, 13:07
Re: IsKeyDown(vkey) function in PAWN - by Farsek - 13.07.2011, 13:07
Re: IsKeyDown(vkey) function in PAWN - by MoroDan - 13.07.2011, 13:11
Re: IsKeyDown(vkey) function in PAWN - by Retardedwolf - 13.07.2011, 13:20
Re: IsKeyDown(vkey) function in PAWN - by Sasino97 - 13.07.2011, 13:22
Re: IsKeyDown(vkey) function in PAWN - by 0x5A656578 - 13.07.2011, 13:23
Re: IsKeyDown(vkey) function in PAWN - by BlackBank - 13.07.2011, 13:25
Re: IsKeyDown(vkey) function in PAWN - by Sasino97 - 13.07.2011, 13:29
Re: IsKeyDown(vkey) function in PAWN - by Lorenc_ - 13.07.2011, 13:32
Re: IsKeyDown(vkey) function in PAWN - by Sasino97 - 13.07.2011, 13:40
Re: IsKeyDown(vkey) function in PAWN - by BaubaS - 13.07.2011, 13:44
Re: IsKeyDown(vkey) function in PAWN - by Sasino97 - 13.07.2011, 13:53
Re: IsKeyDown(vkey) function in PAWN - by Gamer_Z - 13.07.2011, 15:09
Re: IsKeyDown(vkey) function in PAWN - by Sasino97 - 13.07.2011, 15:25
Re: IsKeyDown(vkey) function in PAWN - by Makar93 - 13.07.2011, 15:28
Re: IsKeyDown(vkey) function in PAWN - by Gamer_Z - 13.07.2011, 15:39
Re: IsKeyDown(vkey) function in PAWN - by Gamer_Z - 13.07.2011, 15:50
Re: IsKeyDown(vkey) function in PAWN - by Patrik356b - 13.07.2011, 15:55
Re: IsKeyDown(vkey) function in PAWN - by Karlip - 13.07.2011, 16:06
Re: IsKeyDown(vkey) function in PAWN - by Gamer_Z - 13.07.2011, 16:34
Re: IsKeyDown(vkey) function in PAWN - by MicroD - 13.07.2011, 16:45
Re: IsKeyDown(vkey) function in PAWN - by Ernis456 - 13.07.2011, 16:46
Re: IsKeyDown(vkey) function in PAWN - by Gamer_Z - 13.07.2011, 23:50
Re: IsKeyDown(vkey) function in PAWN - by Kyosaur - 14.07.2011, 01:23
Re: IsKeyDown(vkey) function in PAWN - by Robert_Crawford - 14.07.2011, 03:31
Re: IsKeyDown(vkey) function in PAWN - by Kyosaur - 14.07.2011, 03:38
Re: IsKeyDown(vkey) function in PAWN - by Gamer_Z - 14.07.2011, 10:12
Re: IsKeyDown(vkey) function in PAWN - by Omega-300 - 14.07.2011, 10:17
Re: IsKeyDown(vkey) function in PAWN - by MoroDan - 14.07.2011, 10:21
Re: IsKeyDown(vkey) function in PAWN - by Gamer_Z - 14.07.2011, 10:55
Re: IsKeyDown(vkey) function in PAWN - by boelie - 14.07.2011, 10:59
Re : IsKeyDown(vkey) function in PAWN - by scott1 - 14.07.2011, 11:01
Re: IsKeyDown(vkey) function in PAWN - by MisterTickle - 14.07.2011, 11:07
Re: IsKeyDown(vkey) function in PAWN - by MoroDan - 14.07.2011, 11:41
Re: IsKeyDown(vkey) function in PAWN - by steki. - 14.07.2011, 12:26
Re: IsKeyDown(vkey) function in PAWN - by manok - 14.07.2011, 14:17
Re: IsKeyDown(vkey) function in PAWN - by AirKite - 14.07.2011, 22:36
Re: IsKeyDown(vkey) function in PAWN - by Kaperstone - 17.07.2011, 07:11
AW: Re: IsKeyDown(vkey) function in PAWN - by Meta - 17.07.2011, 08:45
Re: AW: Re: IsKeyDown(vkey) function in PAWN - by boelie - 17.07.2011, 09:47
Re: AW: Re: IsKeyDown(vkey) function in PAWN - by Sasino97 - 17.07.2011, 12:23
Re: IsKeyDown(vkey) function in PAWN - by SkizzoTrick - 17.07.2011, 13:22
Re: IsKeyDown(vkey) function in PAWN - by Markx - 17.07.2011, 13:30
Re: IsKeyDown(vkey) function in PAWN - by CyNiC - 17.07.2011, 13:38
Re: IsKeyDown(vkey) function in PAWN - by Sasino97 - 17.07.2011, 13:42
Re: IsKeyDown(vkey) function in PAWN - by Calgon - 17.07.2011, 13:46
Re: IsKeyDown(vkey) function in PAWN - by SkizzoTrick - 17.07.2011, 14:19
Re: IsKeyDown(vkey) function in PAWN - by Ernis456 - 19.07.2011, 13:55
Re: IsKeyDown(vkey) function in PAWN - by Sasino97 - 19.07.2011, 16:32
Re: IsKeyDown(vkey) function in PAWN - by SlootLite - 19.07.2011, 16:58
Re: IsKeyDown(vkey) function in PAWN - by Sasino97 - 19.07.2011, 17:09
Re: IsKeyDown(vkey) function in PAWN - by Dodus - 19.07.2011, 22:45
Re: IsKeyDown(vkey) function in PAWN - by DartakousLien - 19.07.2011, 22:49
Re: IsKeyDown(vkey) function in PAWN - by JernejL - 19.07.2011, 22:52

Forum Jump:


Users browsing this thread: 3 Guest(s)