Raised This Month: $51 Target: $400
 12% 

How to register if numpad keys are pressed?


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Grovliom
Member
Join Date: Mar 2020
Location: somewhere in Serbia
Old 04-12-2020 , 07:38   How to register if numpad keys are pressed?
Reply With Quote #1

hi, i was trying to make a Piano plugin but don't know how to make it so if you press the Num Pad 1 key it plays a sound, please help
Grovliom is offline
OciXCrom
Veteran Member
Join Date: Oct 2013
Location: Macedonia
Old 04-12-2020 , 07:48   Re: How to register if numpad keys are pressed?
Reply With Quote #2

Not possible. You can only hook commands assigned to keys, not the keys themselves.
__________________
OciXCrom is offline
Send a message via Skype™ to OciXCrom
Grovliom
Member
Join Date: Mar 2020
Location: somewhere in Serbia
Old 04-12-2020 , 07:49   Re: How to register if numpad keys are pressed?
Reply With Quote #3

oh, guess i need to find another way of doing this...
Grovliom is offline
georgik57
Veteran Member
Join Date: Oct 2008
Location: 🎧Music World
Old 04-12-2020 , 09:03   Re: How to register if numpad keys are pressed?
Reply With Quote #4

just use slot1 to slot10?
__________________
georgik57 is offline
Send a message via MSN to georgik57 Send a message via Yahoo to georgik57 Send a message via Skype™ to georgik57
Grovliom
Member
Join Date: Mar 2020
Location: somewhere in Serbia
Old 04-12-2020 , 10:37   Re: How to register if numpad keys are pressed?
Reply With Quote #5

this worked fine, i just made a menu...

PHP Code:
new const noteC[] = "piano/C.wav"
new const noteD[] = "piano/D.wav"
new const noteE[] = "piano/E.wav"
new const noteF[] = "piano/F.wav"
new const noteG[] = "piano/G.wav"
new const noteA[] = "piano/A.wav"
new const noteB[] = "piano/B.wav"
new const noteC2[] = "piano/C2.wav"



public plugin_init() {
    
register_plugin(PLUGINVERSIONAUTHOR)
    
register_clcmd("p_menu","P_ENABLE")
    
// Add your code here...
}
public 
plugin_precache()
{
    
precache_sound(noteC)
    
precache_sound(noteD)
    
precache_sound(noteE)
    
precache_sound(noteF)
    
precache_sound(noteG)
    
precache_sound(noteA)
    
precache_sound(noteB)
    
precache_sound(noteC2)
}
public 
P_ENABLE(id)
{
    new 
menu menu_create("/rPiano Menu;""menu_handler")
    
menu_additem(menu"C""1"0)
    
menu_additem(menu"D""2"0)
    
menu_additem(menu"E""3"0)
    
menu_additem(menu"F""4"0)
    
menu_additem(menu"G""5"0)
    
menu_additem(menu"A""6"0)
    
menu_additem(menu"B""7"0)
    
menu_additem(menu"C2""8"0)
    
menu_setprop(menuMPROP_EXITMEXIT_ALL)
    
menu_display(idmenu0)
}
public 
menu_handler(idmenuitem)
{
    if(
item == MENU_EXIT)
    {
        
menu_destroy(menu);
        return 
PLUGIN_HANDLED
    
}
    new 
data[10], iName[64];
    new 
accesscallback;
    
menu_item_getinfo(menuitemaccessdata8iName63callback);
    new 
key str_to_num(data);
    switch(
key)
    {
        case 
1:
        {
         
emit_sound(idCHAN_STATICnoteC1.0ATTN_NORM0PITCH_NORM)
         
menu_display(idmenu)
        }
        case 
2:
        {
        
emit_sound(idCHAN_STATICnoteD1.0ATTN_NORM0PITCH_NORM)
        
menu_display(idmenu)
        }
        case 
3:
        {
        
emit_sound(idCHAN_STATICnoteE1.0ATTN_NORM0PITCH_NORM)
        
menu_display(idmenu)
        }
        case 
4:
        {
        
emit_sound(idCHAN_STATICnoteF1.0ATTN_NORM0PITCH_NORM)
        
menu_display(idmenu)
        }
        case 
5:
        {
        
emit_sound(idCHAN_STATICnoteG1.0ATTN_NORM0PITCH_NORM)
        
menu_display(idmenu)
        }
        case 
6:
        {
        
emit_sound(idCHAN_STATICnoteA1.0ATTN_NORM0PITCH_NORM)
        
menu_display(idmenu)
        }
        case 
7:
        {
        
emit_sound(idCHAN_STATICnoteB1.0ATTN_NORM0PITCH_NORM)
        
menu_display(idmenu)
        }
        case 
8:
        {
        
emit_sound(idCHAN_STATICnoteC21.0ATTN_NORM0PITCH_NORM)
        
menu_display(idmenu1)
        }
    }


Last edited by Grovliom; 04-13-2020 at 14:21.
Grovliom is offline
georgik57
Veteran Member
Join Date: Oct 2008
Location: 🎧Music World
Old 04-12-2020 , 11:35   Re: How to register if numpad keys are pressed?
Reply With Quote #6

make a video if you want i wanna see what you can play with it xD
__________________
georgik57 is offline
Send a message via MSN to georgik57 Send a message via Yahoo to georgik57 Send a message via Skype™ to georgik57
Grovliom
Member
Join Date: Mar 2020
Location: somewhere in Serbia
Old 04-12-2020 , 15:56   Re: How to register if numpad keys are pressed?
Reply With Quote #7

Quote:
Originally Posted by georgik57 View Post
make a video if you want i wanna see what you can play with it xD
already did but i didnt play anything good.. i know how to play piano, but i was tired to play anything XD
Grovliom is offline
Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 05:26.


Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Theme made by Freecode