[Plugin] Local Keys Plugin
#1

Local Keys Plugin by NaS
Yet another Plugin for accessing all local keys that are pressed on the machine the server is running on (keyboard and mouse).

This does NOT work for any other player that is connected to the server. It is meant for debugging, MapEditors and test scripts.

This plugin adds a callback. You need to toggle the keys you want to check via ToggleKey() (this prevents callback spam on every key press and reduces the amount of keys that are listened for).

In case you want to listen for all keys:

Code:
for(new i = 0; i < 256; i ++) ToggleKey(i);
The keys are always detected, whether or not you are playing or even connected to the server.
Use IsSAMPFocused() if you want to check if the SAMP Client is currently focused.

Natives
IsLocalKeyPressed(key)
Checks if a key ID is currently pressed.

IsSAMPFocused()
Checks if the SAMP client is the foreground application (by window name).

GetVKName(key, const name[], maxlen = sizeof name)
Gets the complete name of a key.

ToggleKey(key, toggle = 1)
Toggles the given key for OnLocalKeyStateChange. IsLocalKeyPressed is not affected by this.
All keys are off by default!

IsKeyToggled(key)
Checks if a key is toggled.

Update:

GetCursorPos(&x, &y)
Gets the current Cursor Position.

SetCursorPos(x, y)
Sets the Cursor Position.

Key Defnitions
All Windows Keys are defined inside the include.

Download
https://github.com/Naseband/SAMP-LocalPlugin

Installation
Drop LocalKeys.dll into your plugins directory and add LocalKeys.dll to your server.cfg (under plugins).
Copy LocalKeys.inc into your pawn/include/ directory and include it in your script.

Done!


This is a snippet of a server-/client plugin which I will release when ready (the main purpose being MapEditors etc).
Reply
#2

Useful.
Reply
#3

Beautiful!
Reply
#4

linux ?
Reply
#5

Quote:
Originally Posted by GuyYahood1
View Post
linux ?
only windows
Reply
#6

Why not a plugin to detect keys pressed by player, like U B K L M G F1F2 F3 etc?
Reply
#7

I don't understand why Kye never put this to sa-mp official update,I mean.. it's possible with .asi file why Kye doesn't do that already?

OT: Good job!

Quote:
Originally Posted by JR_Junior
View Post
Why not a plugin to detect keys pressed by player, like U B K L M G F1F2 F3 etc?
What are you talking about? This plugin detects it..
Reply
#8

If you are able to read keyboard input for each player, then you are able to craft a keylogger effectively. This plugin isn't able to read keyboard input of any player. However this plugin can read keyboard input of the system where it is running on.
Reply
#9

Good stuff, but can you tell me an example where it could be useful?
Reply
#10

Quote:
Originally Posted by iLearner
View Post
Good stuff, but can you tell me an example where it could be useful?
Did you read the topic at least?
Quote:
Originally Posted by NaS
View Post
...
This does NOT work for any other player that is connected to the server. It is meant for debugging, MapEditors and test scripts.
....
If I'm not mistaken, the TDEditor filterscript uses this plugin.

Good job NaS.
Reply
#11

NaS, the idea is good, but linux will be?
Reply
#12

Quote:
Originally Posted by Moldova
View Post
NaS, the idea is good, but linux will be?
What for? 90% of people that run the server on Linux do not have access to the physical keyboard as it runs on a server they only have remote access to (rented root server, vps, etc). Remember this only gives access to the keys that are pressed on the host machine, not the connected players.
Furthermore the idea was to have more keys available ingame for the host - and the game only runs on Windows (at least officially).

If you use a Linux OS on your PC at home a Linux version would be useful for you. If that really is the case I can try to make a Linux version, but I have little to none experience with Linux key states so I need to look into it first.

Quote:
Originally Posted by Locky_
View Post
Did you read the topic at least?

If I'm not mistaken, the TDEditor filterscript uses this plugin.

Good job NaS.
Thanks, but this is not the same plugin as the one TDE uses. IIRC it also has access to the Cursor Pos.
The reason I made this is basically only access to the keyboard anytime (even when not ingame) and the callback.

Didn't make it to replace the other ones, but as I threw this together I thought why not release it.
Reply
#13

Quote:
Originally Posted by NaS
View Post
What for? 90% of people that run the server on Linux do not have access to the physical keyboard as it runs on a server they only have remote access to (rented root server, vps, etc). Remember this only gives access to the keys that are pressed on the host machine, not the connected players.
Furthermore the idea was to have more keys available ingame for the host - and the game only runs on Windows (at least officially).

If you use a Linux OS on your PC at home a Linux version would be useful for you. If that really is the case I can try to make a Linux version, but I have little to none experience with Linux key states so I need to look into it first.
ok thx
Reply
#14

What's the status of the client plugin?
Reply
#15

How do I activate this in all players with the help of a new client?
Reply
#16

Quote:
Originally Posted by sampkinq
View Post
How do I activate this in all players with the help of a new client?
Quote:
Originally Posted by NaS
View Post
Yet another Plugin for accessing all local keys that are pressed on the machine the server is running on (keyboard and mouse).

This does NOT work for any other player that is connected to the server. It is meant for debugging, MapEditors and test scripts.
^^^^
Reply
#17

Quote:
Originally Posted by Dayrion
View Post
^^^^
What I mean is that I want to combine this add-on with a client that I wrote myself and everyone presses the key detection. I think I need the RakNet Library for that.
Reply
#18

Quote:
Originally Posted by sampkinq
View Post
What I mean is that I want to combine this add-on with a client that I wrote myself and everyone presses the key detection. I think I need the RakNet Library for that.
You could look into SAMP+ or other similar plugins to see how they did it. It also uses SAMP's RakNET connection to send their data.

I'd suggest not sending all key inputs but just the ones the server requests. Otherwise you'll have a keylogger, that's why I'm working with key binds to make it impossible for the server to know which key the player pressed.
Reply
#19

Quote:
Originally Posted by NaS
View Post
You could look into SAMP+ or other similar plugins to see how they did it. It also uses SAMP's RakNET connection to send their data.

I'd suggest not sending all key inputs but just the ones the server requests. Otherwise you'll have a keylogger, that's why I'm working with key binds to make it impossible for the server to know which key the player pressed.
I did a little research, but I couldn't find the place to contact. Can you help me ?
Reply
#20

Updated.

Added GetCursorPos() and SetCursorPos().
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)