Results 1 to 10 of 10

Thread: Functions by pressing buttons

  1. #1
    Lieutenant Loveboy's Avatar
    Join Date
    Nov 2012
    Posts
    546
    Thanks
    229
    Thanked 72 Times in 46 Posts

    Functions by pressing buttons

    Hey Guys,
    I want to make new Killstreaks on my Mod, but I only can do by pressing F or Bash calling scripts.
    I want to have more buttons, is there possible to use the keys 3,4,5,6,7...?

  2. #2
    Private First Class YuriJurek's Avatar
    Join Date
    Jun 2013
    Posts
    219
    Thanks
    152
    Thanked 88 Times in 47 Posts
    Just like I posted in this thread: http://killtube.org/showthread.php?1702-key-on-keyboard

    Quote Originally Posted by YuriJurek View Post
    The answer is you can't, you could of course use libcod which has build in these functions but there's an easier way.

    1. Create a menu file and do something like
    PHP Code:
    bind k "openscriptmenu keys key_K" 
    2. On connect open the menu on each player so that it binds the right response to right key (eventually can do this as well on respawn to prevent players from changing it)

    3. In menus.gsc make a new response like
    PHP Code:
    if(menu == "-1" && response == "key_K"
    Then... execute your script.

    Code untested, there might be an obvious to fix mistake but you should be able to fix it if any occurs.
    You can use any keys, like instead of k you can use your 1, 2, 3, 4 numbers, but bare in mind that you should keep the response like "key_1" instead of just "1" so that it doesn't interfere with anything else.

    PS. Remmember about binding those keys every respawn so that the player will not unbind them, it's much better then making a new loop to open that menu file.

    Hehe, just bougth a new PC, so I'am gonna start to play on your Modern Weapons 1.2
    Last edited by YuriJurek; 20th December 2013 at 11:40.

  3. The Following User Says Thank You to YuriJurek For This Useful Post:

    Loveboy (20th December 2013)

  4. #3
    Lieutenant Loveboy's Avatar
    Join Date
    Nov 2012
    Posts
    546
    Thanks
    229
    Thanked 72 Times in 46 Posts
    Can you do an example for the menu? What should be there?

  5. #4
    Private First Class YuriJurek's Avatar
    Join Date
    Jun 2013
    Posts
    219
    Thanks
    152
    Thanked 88 Times in 47 Posts
    Yeah, I'll post one when I'am back home, just give me an hour please.

  6. #5
    Brigadier General
    Join Date
    Oct 2012
    Posts
    998
    Thanks
    20
    Thanked 590 Times in 390 Posts
    Quote Originally Posted by Loveboy View Post
    Can you do an example for the menu? What should be there?
    It's the clientcmd menu, renamed to keys.menu. I personally think it is a waste of resources to have 2 menus which do the same thing, so I would change the key binding to this instead:

    Code:
    bind k "openscriptmenu clientcmd key_K"
    And use the clientcmd.menu to force the key binding.

  7. #6
    Private First Class YuriJurek's Avatar
    Join Date
    Jun 2013
    Posts
    219
    Thanks
    152
    Thanked 88 Times in 47 Posts
    PHP Code:
    #include "ui_mp/menudef.h" 


        
    menuDef  
        

            
    name                "clientcmd" 
            
    rect                 0 0 1 1 
            visible                0 
            fullscreen             0 

            onOpen  
            
    {  
                
    exec "vstr clientcmd";
                
    bind k "openscriptmenu clientcmd key_K"
                
    close clientcmd
            }  
        } 

    Yeah agree with Tally.

  8. #7
    Lieutenant Loveboy's Avatar
    Join Date
    Nov 2012
    Posts
    546
    Thanks
    229
    Thanked 72 Times in 46 Posts
    Ok, I will try it, and thanks!

    Ah and I can do here more keys? As example K,L,M,N...?
    Last edited by Loveboy; 20th December 2013 at 11:52.

  9. #8
    Brigadier General
    Join Date
    Oct 2012
    Posts
    998
    Thanks
    20
    Thanked 590 Times in 390 Posts
    Quote Originally Posted by Loveboy View Post
    Ok, I will try it, and thanks!

    Ah and I can do here more keys? As example K,L,M,N...?
    Yes, you can. But, make sure you don't go crazy with it, and remember not to use keys which most players use to control the avatar. I would hate to have a mod re-bind those keys to some mod function. I tend to use keys which aren't used in the game, such as L, K, J, I, O, P. These are right over on the right-hand side of the keyboard, and are not used very much by gamers.

  10. The Following 2 Users Say Thank You to Tally For This Useful Post:

    kung foo man (21st December 2013),Loveboy (20th December 2013)

  11. #9
    Lieutenant Loveboy's Avatar
    Join Date
    Nov 2012
    Posts
    546
    Thanks
    229
    Thanked 72 Times in 46 Posts
    Should it work it so?

    Code:
    #include "ui_mp/menudef.h" 
    
    { 
        menuDef  
        { 
            name                "clientcmd" 
            rect                 0 0 1 1 
            visible                0 
            fullscreen             0 
    
            onOpen  
            {  
                exec "vstr clientcmd";
                bind k "openscriptmenu clientcmd key_K"
                bind l "openscriptmenu clientcmd key_L"
                bind m "openscriptmenu clientcmd key_M"
                bind n "openscriptmenu clientcmd key_N"
                close clientcmd; 
            }  
        } 
    }
    And the menu name should be clientcmd.menu?

    Edit: I will be crazy. My friend and me don't understand it, can you please upload here all things what there should be in (the menu file, _menus.gsc ..), better then ask here 1000 things?
    Last edited by Loveboy; 20th December 2013 at 12:09.

  12. #10
    Private First Class YuriJurek's Avatar
    Join Date
    Jun 2013
    Posts
    219
    Thanks
    152
    Thanked 88 Times in 47 Posts
    Sorry for long response I was just unaware you didn't get an answer, so here you go:

    Create a menu just like you said clientcmd.menu and put the stuff you got in it.

    Then somewhere in your gametype script preferably on connect and on spawn so that it binds the keys if someone removes them:

    PHP Code:
    self closeMenu();
    self closeInGameMenu();
                
    self openMenu(game["clientcmd"]); 
    And again don't forget to precache your menu somewhere in your init gametype function like:

    PHP Code:
    game["clientcmd"] = "clientcmd";
    precacheMenu(game["clientcmd"]); 
    Finally add if(menu == "-1" && response == "key_K") in your menu gsc file and your actual thread to the script.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •