SA-MP Forums Archive
when if key pressed - 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: when if key pressed (/showthread.php?tid=468800)



when if key pressed - gotwarzone - 10.10.2013

Can you please help me make a "if key Pressed" Like when I press the "B" from the keyboard there should be a dialog will show. Is that possible? Because I want to make shortcut so players would not hesitate to type the whole command or something..

Thanks looking forward.


Re: show textdraw - Astralis - 10.10.2013

yes its possible, find all the keys at https://sampwiki.blast.hk/wiki/Keys


Re: when if key pressed - Konstantinos - 10.10.2013

Like Neonman said it's possible; however, with another key. B button/key is not detectable.

https://sampwiki.blast.hk/wiki/OnPlayerK..._being_pressed

https://sampwiki.blast.hk/wiki/OnPlayerKeyStateChange


Re: when if key pressed - gotwarzone - 10.10.2013

Thanks for your reply guys. But may I ask to if you can make a simple demo with what I wanted? If key press H then showplayerdialog? So I can review them after. Thanks!


Re: when if key pressed - Konstantinos - 10.10.2013

pawn Code:
#define PRESSED(%0) \
    (((newkeys & (%0)) == (%0)) && ((oldkeys & (%0)) != (%0)))
       
public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
{
    if(PRESSED(KEY_CROUCH))
    {
        // ShowPlayerDialog( ... );
    }
    return 1;
}
Note that when a player is in vehicle, the key is H/Caps Lock. Although, if a player is on foot, the key is C.


Re: when if key pressed - gotwarzone - 10.10.2013

Quote:
Originally Posted by Konstantinos
View Post
pawn Code:
#define PRESSED(%0) \
    (((newkeys & (%0)) == (%0)) && ((oldkeys & (%0)) != (%0)))
       
public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
{
    if(PRESSED(KEY_CROUCH))
    {
        // ShowPlayerDialog( ... );
    }
    return 1;
}
Note that when a player is in vehicle, the key is H/Caps Lock. Although, if a player is on foot, the key is C.
tnx. also may I ask if there is any single key that can trigger invehicle at the same time onfoot? If there none. then I will use what you gave.


Re: when if key pressed - xVIP3Rx - 10.10.2013

G - H - N - Y - Num 2-6-4-8
https://sampwiki.blast.hk/wiki/Keys