Page 2 of 3 FirstFirst 123 LastLast
Results 11 to 20 of 26

Thread: key on keyboard

  1. #11
    Sergeant serthy's Avatar
    Join Date
    Nov 2012
    Posts
    450
    Thanks
    96
    Thanked 296 Times in 188 Posts
    You can FAKE a button and check if its pressed or not, i'll provide the bind when im at home. However this is not as good and save as useButtonPressed() and its counterparts
    syntax is similar to:
    bind F5 "openscriptmenu test start_f5; +speed; openscriptmenu test stop_f5;-speed"

    speed and some other available in cod2, but not used binds only can be used and not all of them reset themselfes with -speed

    this will trigger a menuresponse when pressed and also when released the F5-key

    as already said, its not this safe and smooth, but it kind of works!

  2. The Following User Says Thank You to serthy For This Useful Post:

    kung foo man (15th January 2014)

  3. #12
    Sergeant serthy's Avatar
    Join Date
    Nov 2012
    Posts
    450
    Thanks
    96
    Thanked 296 Times in 188 Posts
    Quote Originally Posted by serthy View Post
    bind F5 "openscriptmenu test start_f5; +speed; openscriptmenu test stop_f5;-speed"
    correct syntax:

    PHP Code:
    bind F5         "+holdbreath;-holdbreath;openscriptmenu clientcmd custombutton1;-holdbreath"
    bind F6         "+strafe;-strafe;openscriptmenu clientcmd custombutton2;-strafe"
    bind F7         "+speed;-speed;openscriptmenu clientcmd custombutton3;-speed"
    bind F8         "+mlook;-mlook;openscriptmenu clientcmd custombutton4;-mlook" 

  4. #13
    Private First Class
    Join Date
    Oct 2013
    Posts
    219
    Thanks
    56
    Thanked 105 Times in 66 Posts
    Thought I would use this thread instead of creating a new one.

    I'm trying to bind a key so it will execute multiple commands, just like:

    Example:
    Code:
    bind m "+scores;say A;"
    This can be done easily if you were to type that command manually into console.

    However I need the server to bind the key instead of every user having to bind the key themselves.

    The normal way of doing this would be using something like "execClientCommand" or "setClientCvar" but none work in my situation.

    With "execClientCommand", you can't use double quotes in a string. Example:
    Code:
    self execClientCommand("bind m "+scores;say test;"");
    //Won't work.
    I also tried using escape sequence's;
    Code:
    self execClientCommand("bind m \"+scores;say test;\"");
    But for some strange reason it will use single quotations instead of double:
    Code:
    //Output:
    bind m '+scores;say test;'
    //Won't work.
    Which won't work.

    With "setClientCvar", I am able to do this;
    Code:
    self setClientCvar("scorebind", "+scores;say A;");
    self execClientCommand("bind m vstr scorebind");
    However, using vstr will allow +scores to open normally, but it will not close normally (-scores) upon releasing the key. If I don't use vstr and manually type "bind m "+scores;say A;"" into console, it does open and close +scores correctly which is what I need.

    So, any ideas on how can I do it?
    Last edited by filthy_freak_; 28th May 2014 at 12:36.

  5. #14
    Brigadier General
    Join Date
    Dec 2012
    Posts
    1,012
    Thanks
    440
    Thanked 171 Times in 132 Posts
    PHP Code:
    self setClientCvar ("clientcmd","disconnect; wait 20; reconnect");
    self openMenu ("clientcmd");
    self closeMenu ("clientcmd"); 
    I use this. So maybe u can do
    PHP Code:
    self setClientCvar ("clientcmd","bind m +scores; wait 1; say A");
    self openMenu ("clientcmd");
    self closeMenu ("clientcmd"); 

  6. #15
    Private First Class
    Join Date
    Oct 2013
    Posts
    219
    Thanks
    56
    Thanked 105 Times in 66 Posts
    Quote Originally Posted by Ni3ls View Post
    PHP Code:
    self setClientCvar ("clientcmd","disconnect; wait 20; reconnect");
    self openMenu ("clientcmd");
    self closeMenu ("clientcmd"); 
    I use this. So maybe u can do
    PHP Code:
    self setClientCvar ("clientcmd","bind m +scores; wait 1; say A");
    self openMenu ("clientcmd");
    self closeMenu ("clientcmd"); 
    That won't work. I'm trying to bind multiple commands to a key, your solution binds 1 command to the key.

  7. #16
    Sergeant serthy's Avatar
    Join Date
    Nov 2012
    Posts
    450
    Thanks
    96
    Thanked 296 Times in 188 Posts
    maybe something like this
    PHP Code:
    player setClientCvar"tmp" "your;string;here;" );
    player execClientCommand"vstr tmp" ); 

  8. The Following 2 Users Say Thank You to serthy For This Useful Post:

    filthy_freak_ (29th May 2014),Ni3ls (29th May 2014)

  9. #17
    Brigadier General
    Join Date
    Oct 2012
    Posts
    994
    Thanks
    20
    Thanked 588 Times in 388 Posts
    Put the bind in a config file; execute the config file on the player when they are either in a team for the first time (it wont work onPlayerConnect), or when they spawn. Put the config file either on your server in raw format, or put it in your IWD file.

    This is the config file I use to bind keys:

    Code:
    bind I "openScriptMenu clientcmd ibutton"
    bind L "openScriptMenu clientcmd lbutton"
    bind M "openScriptMenu clientcmd mbutton"
    bind K "openScriptMenu clientcmd kbutton"
    I name the config file "custombuttons.cfg".

    This is the code I use to execute the config file:

    Code:
    setUpButtons()
    {
    	self ExecClientCommand( "exec custombuttons.cfg" );
    }

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

    filthy_freak_ (29th May 2014),Ni3ls (29th May 2014)

  11. #18
    Private First Class
    Join Date
    Oct 2013
    Posts
    219
    Thanks
    56
    Thanked 105 Times in 66 Posts
    Thanks to both.

    I'm pretty sure I tried your solution serthy but I can't remember the results. I'll give it a go.

    Also I didn't know you could include .cfg files in your .iwd's and exec them client side. Thanks for the info Tally.

  12. #19
    Corporal guiismiti's Avatar
    Join Date
    Dec 2013
    Location
    Brazil
    Posts
    244
    Thanks
    121
    Thanked 42 Times in 31 Posts
    Is there a function to make a player look to the right/left?

    I'm editting the vehicles mod, and I would really like for the players to be able to pilot planes and jeeps using the directional keys.
    I noticed that I can set these binds:

    bind UPARROW "+lookup"
    bind DOWNARROW "+lookdown"
    bind RIGHTARROW "+mlook"

    I noticed that +lookleft or +lookright won't work - are there any similar functions?

    I don't know what "+mlook" does, can anybody tell me? It may be helpful.

    So, what I'm thinking right now is to execute a script from each of the directional keys. This script would change the player's angles. Is this possible?


    Editted: if there are functions to look to the right/left, I'll just use them with up/down and adjust player's sensivity when entering a vehicle.

    Editted #2: I also noticed there is a +klook, trying to find out what that is.

    Editted #3: Found out about "+right" and "+left". It's just what I needed. All I need now is to adjust the player's sensivity. I'm still accepting suggestions.
    Little problem - how to restore the player's original sensivity after he leaves the vehicle? I think I'll write a .cfg file before changing sensivity, and execute it after he leaves the vehicle.

    Editted #4: Looks like sensitivity only works with the mouse.
    Last edited by guiismiti; 7th September 2014 at 06:02.

  13. #20
    Sergeant serthy's Avatar
    Join Date
    Nov 2012
    Posts
    450
    Thanks
    96
    Thanked 296 Times in 188 Posts
    Quote Originally Posted by guiismiti View Post
    I would really like for the players to be able to pilot planes and jeeps using the directional keys.
    I guess that handling wouldnt be as smooth as it is the way it is right now, imho the result isnt worth the time spent

    otherwise I'd go the way like Tally suggested it with 2 configs:
    - when the player enters a vehicle, rebind their keys and remember the original setup (copy the config unfortunately i forgot the command)
    - when the player exits the vehcile reset the config

Posting Permissions

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