[Include] gKey - OnPlayerKeyStateChange simplified!
#1

gKeys


*About*
Hey guys, since i was a bit bored and got some inspiration, i decided to make gKeys!
It is just like zcmd/gDialog, a shortcut with a easyer way of using player hotkeys!


*Callbacks*
pawn Код:
KEYHANDLER:key(playerid,type)
{
    return 1;
}
Information
KEYHANDLER:Will define the callback for the given key
keyInsert your key here (without KEY_ in front of it! e.x. KEYHANDLER:SPRINT)
playeridthe playerid pressing the key
type0 = holding, 1 = pressed, 2 = released (please note that pressed will also be called when the player is holding a key!)


*Example usage*
pawn Код:
//Example filterscript showing how to create a repair key with gKeys (numpad +)
#include <a_samp>
#include <gKeys>

KEYHANDLER:SUBMISSION(playerid,type)
{
    if(type == 2) //if the key is released
    {
        RepairVehicle(GetPlayerVehicleID(playerid));
        GameTextForPlayer(playerid,"~y~Your ~g~vehicle ~y~has been ~r~repaired ~y~!",3000,4);
    }
    return 1;
}

*Download*
http://pastebin.com/DQYR9xbs
Don't forget to also check http://www.gamer93.net/ to donate and/or see more of my work!
Reply
#2

i love you (no gay) this is epic.
Reply
#3

Very useful good job gamer.
Reply
#4

Nice
Way easier then using the OnPlayerKeyStateChange IMO; gonna be useful!
Thanks
Reply
#5

It's supporting arrow keys(GetPlayerKeys)?
Reply
#6

Quote:
Originally Posted by Bumbis
Посмотреть сообщение
It's supporting arrow keys(GetPlayerKeys)?
KEY_UP, KEY_DOWN, KEY_LEFT and KEY_RIGHT are supported (took the keys from the SA-MP wiki) so i guess it does!

Edit: Just tested it, those keys didnt work...
will maybe make a fix tomorrow
Reply
#7

good work man, really nice
Reply
#8

Any speed advantage?
Reply
#9

Quote:
Originally Posted by MisterTickle
Посмотреть сообщение
Any speed advantage?
I wouldn't imagine so, but it appears that CallLocalFunction is used, so I'm not exactly sure if it's the same with key detection.
Reply
#10

It's very Useful, i gotta use this

+REP
Reply
#11

Indeed useful and simplified.
Good job, gamer!
Reply
#12

Nice idea; is there any way to make it faster?
Reply
#13

Quote:
Originally Posted by gamer931215
Посмотреть сообщение
KEY_UP, KEY_DOWN, KEY_LEFT and KEY_RIGHT are supported (took the keys from the SA-MP wiki) so i guess it does!

Edit: Just tested it, those keys didnt work...
will maybe make a fix tomorrow
These work only with GetPlayerKeys.
Reply
#14

Nice.
Reply
#15

Quote:
Originally Posted by Generation-X
Посмотреть сообщение
Nice idea; is there any way to make it faster?
It might be hard though calling it simply like a function:

DoThisCode(playerid);
Reply
#16

Nice include.
Suggestion: make an array to store which keyhandlers are exist. Then check if it exists (under OPKS), and call function.
Reply
#17

Another cool release. Thanks Gamer!
Reply
#18

Good Work!
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)