SA-MP Forums Archive
How to disable the option for key pressing - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: How to disable the option for key pressing (/showthread.php?tid=552898)



How to disable the option for key pressing - ThatThoseTheThy - 27.12.2014

Hello there,
I am trying to limit the use of F11 and F12 keys on the keyboard but I don't know how.
I looked into :
https://sampwiki.blast.hk/wiki/GetPlayerKeys
https://sampwiki.blast.hk/wiki/OnPlayerKeyStateChange
https://sampwiki.blast.hk/wiki/Keys


but in the list of keys only the keys from the Single Player apear not any key from the keyboard.


Re: How to disable the option for key pressing - Lorenc_ - 27.12.2014

Unfortunately, https://sampwiki.blast.hk/wiki/Keys pretty much contains the keys which you can only use at the moment.

I hear rumors that people have workarounds but generally they are either private or working for a single client lol.


Re: How to disable the option for key pressing - ThatThoseTheThy - 27.12.2014

I saw on servers that if you press 'Y' for example it starts a rolling animation or something like that.
Anyone know how to? does it work Like C# of sorts?


Re: How to disable the option for key pressing - HY - 27.12.2014

pawn Код:
#define PRESSED(%0) \
    (((newkeys & (%0)) == (%0)) && ((oldkeys & (%0)) != (%0)))

public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
{
    if(PRESSED(KEY_YES))
    {
        // Functions here.
        SetPlayerPos(playerid, 0.0, 0.0, 0.0); // If pressed Y, teleport him here. for example.
    }
    return 1;
}
OnPlayerKeyStateChange(playerid, newstate, oldstate)

SA-MP Keys


Re: How to disable the option for key pressing - ThatThoseTheThy - 27.12.2014

Quote:
Originally Posted by HY
Посмотреть сообщение
pawn Код:
#define PRESSED(%0) \
    (((newkeys & (%0)) == (%0)) && ((oldkeys & (%0)) != (%0)))

public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
{
    if(PRESSED(KEY_YES))
    {
        // Functions here.
        SetPlayerPos(playerid, 0.0, 0.0, 0.0); // If pressed Y, teleport him here. for example.
    }
    return 1;
}
OnPlayerKeyStateChange(playerid, newstate, oldstate)

SA-MP Keys
That I saw on the samp wiki but that wont help me I need something like

Код:
if(KeyCode_F12 == PRESSED)
{
//Do the Thing
}

Basically this will see if the Key on the Keyboard 'F12" is pressed, when it is do something within the "IF".
I need it for like when a player Uses F12 Key and stuff, The "Y" key was a example...


Re: How to disable the option for key pressing - Eyce - 27.12.2014

Yeah, the "Y" on the keyboard is equivalent to "KEY_YES".


Re: How to disable the option for key pressing - ThatThoseTheThy - 27.12.2014

Sorry I edited my last post, it consists the "F12" Key, not the Y key.


Re: How to disable the option for key pressing - Eyce - 27.12.2014

Quote:
Originally Posted by ThatThoseTheThy
Посмотреть сообщение
Sorry I edited my last post, it consists the "F12" Key, not the Y key.
I'm pretty much sure that it's not yet available to be manipulated script-wise. There could be some who do workarounds in order to control those "F" keys.