06.07.2018, 15:45
(
Last edited by NaS; 20/09/2018 at 11:58 PM.
)
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);
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-LocalPluginInstallation
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).