SA-MP Forums

Go Back   SA-MP Forums > SA-MP Scripting and Plugins > Plugin Development

Reply
 
Thread Tools Display Modes
Old 06/07/2018, 03:45 PM   #1
NaS
High-roller
 
NaS's Avatar
 
Join Date: Mar 2008
Posts: 1,584
Reputation: 466
Default Local Keys Plugin

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).

Last edited by NaS; 20/09/2018 at 11:58 PM.
NaS is online now   Reply With Quote
Old 06/07/2018, 04:22 PM   #2
Zeth
Gangsta
 
Zeth's Avatar
 
Join Date: Feb 2017
Location: Titan
Posts: 503
Reputation: 114
Default Re: Local Keys Plugin

Useful.
__________________
server.one-rp.com
Zeth is offline   Reply With Quote
Old 06/07/2018, 04:29 PM   #3
Alexis17
Little Clucker
 
Join Date: Nov 2017
Posts: 19
Reputation: 0
Default Re: Local Keys Plugin

Beautiful!
Alexis17 is offline   Reply With Quote
Old 06/07/2018, 08:02 PM   #4
GuyYahood1
Big Clucker
 
Join Date: Dec 2010
Posts: 177
Reputation: 6
Default Re: Local Keys Plugin

linux ?
__________________
GuyYahood1 is offline   Reply With Quote
Old 06/07/2018, 10:52 PM   #5
Romz
High-roller
 
Romz's Avatar
 
Join Date: Jun 2013
Location: Ukraine
Posts: 1,047
Reputation: 59
Default Re: Local Keys Plugin

Quote:
Originally Posted by GuyYahood1 View Post
linux ?
only windows
__________________
Romz is offline   Reply With Quote
Old 11/07/2018, 04:16 AM   #6
JR_Junior
Huge Clucker
 
Join Date: Nov 2011
Location: Brazil
Posts: 226
Reputation: 54
Default Re: Local Keys Plugin

Why not a plugin to detect keys pressed by player, like U B K L M G F1F2 F3 etc?
JR_Junior is offline   Reply With Quote
Old 11/07/2018, 04:21 AM   #7
Verc
Big Clucker
 
Verc's Avatar
 
Join Date: Apr 2018
Location: 🇯🇵
Posts: 173
Reputation: 29
Default Re: Local Keys Plugin

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..

Last edited by Verc; 11/07/2018 at 04:57 AM.
Verc is offline   Reply With Quote
Old 11/07/2018, 08:12 AM   #8
BigETI
High-roller
 
BigETI's Avatar
 
Join Date: Mar 2010
Location: Germany
Posts: 1,005
Reputation: 323
Default Re: Local Keys Plugin

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.
BigETI is offline   Reply With Quote
Old 11/07/2018, 11:36 AM   #9
iLearner
Gangsta
 
iLearner's Avatar
 
Join Date: Apr 2017
Posts: 650
Reputation: 133
Default Re: Local Keys Plugin

Good stuff, but can you tell me an example where it could be useful?
iLearner is online now   Reply With Quote
Old 11/07/2018, 01:24 PM   #10
Locky_
High-roller
 
Locky_'s Avatar
 
Join Date: Jul 2012
Posts: 1,589
Reputation: 321
Default Re: Local Keys Plugin

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.
__________________


Locky_ is offline   Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
[Map] A Local Town, For Local People VantagePoint Maps 12 21/07/2016 07:05 PM
MySQL Plugin r39-2 Error: Can't connect to local MySQL server through socket Emre__ Scripting Help 10 30/07/2014 08:26 AM
Local Messages (Using y_iterate and Incognito's Streamer Plugin) Maxips2 Scripting Help 2 29/03/2013 11:10 PM
Local Messages (Using y_iterate and Incognito's Streamer Plugin) Maxips2 Scripting Help 0 29/03/2013 12:18 PM
Plugin Keys Search? Fuck keys playerid. Manowar Scripting Help 16 21/10/2012 06:04 AM


All times are GMT. The time now is 11:12 PM.


Powered by vBulletin® Version 3.8.6
Copyright ©2000 - 2018, Jelsoft Enterprises Ltd.