Local Keys Plugin -
NaS - 06.07.2018
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).
Re: Local Keys Plugin -
Zeth - 06.07.2018
Useful.
Re: Local Keys Plugin -
Alexis17 - 06.07.2018
Beautiful!
Re: Local Keys Plugin -
GuyYahood1 - 06.07.2018
linux ?
Re: Local Keys Plugin -
Romz - 06.07.2018
Quote:
Originally Posted by GuyYahood1
linux ?
|
only windows
Re: Local Keys Plugin -
JR_Junior - 11.07.2018
Why not a plugin to detect keys pressed by player, like U B K L M G F1F2 F3 etc?
Re: Local Keys Plugin -
Verc - 11.07.2018
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
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..
Re: Local Keys Plugin -
BigETI - 11.07.2018
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.
Re: Local Keys Plugin -
iLearner - 11.07.2018
Good stuff, but can you tell me an example where it could be useful?
Re: Local Keys Plugin -
Locky_ - 11.07.2018
Quote:
Originally Posted by iLearner
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
...
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.
Re: Local Keys Plugin -
Moldova - 14.07.2018
NaS, the idea is good, but linux will be?
Re: Local Keys Plugin -
NaS - 14.07.2018
Quote:
Originally Posted by Moldova
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_
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.
Re: Local Keys Plugin -
Moldova - 15.07.2018
Quote:
Originally Posted by NaS
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
Re: Local Keys Plugin -
Riddick94 - 31.08.2018
What's the status of the client plugin?
Re: Local Keys Plugin -
sampkinq - 31.08.2018
How do I activate this in all players with the help of a new client?
Re: Local Keys Plugin -
Dayrion - 31.08.2018
Quote:
Originally Posted by sampkinq
How do I activate this in all players with the help of a new client?
|
Quote:
Originally Posted 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.
|
^^^^
Re: Local Keys Plugin -
sampkinq - 31.08.2018
Quote:
Originally Posted by Dayrion
^^^^
|
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.
Re: Local Keys Plugin -
NaS - 06.09.2018
Quote:
Originally Posted by sampkinq
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.
Re: Local Keys Plugin -
sampkinq - 09.09.2018
Quote:
Originally Posted by NaS
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 ?
Re: Local Keys Plugin -
NaS - 20.09.2018
Updated.
Added GetCursorPos() and SetCursorPos().