when if key pressed
#1

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.
Reply
#2

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

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
Reply
#4

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!
Reply
#5

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.
Reply
#6

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

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


Forum Jump:


Users browsing this thread: 1 Guest(s)