adding new buttons
Moderator: InsideQC Admins
5 posts
• Page 1 of 1
adding new buttons
hi!
I'm implementing a chasecam into my mod, and I was wondering how I would go about doing this:
- Allowing the player to switch from 1st person to 3rd person view, at a press of a (customizable) keyboard button e.g. F1.
I know that in quakeC, when working with the jump code for example, you would use self.button2 , but I have a feeling that the button field types (button0, button1, button2) available are hard coded. Is there any way to assign custom keyboard buttons to specific player actions (without the needing to use impulses)? Should I perhaps need to make use of cvar or cvar_set?
Thnx again!
P.S. Not sure if this was asked before, but I did browse the forums.
EDIT: A few minutes later...
Ok, so I now have this code in my client.qc:
I'm hoping that this will work. I have binded the key F1 to invoke the impulse command 100, which activates the chase cam. I have placed this code in the ClientConnect() function, mainly becuase I want it to be set-up everytime the client connects to the game (server). I'm gonna do some more work on it now...
I'm implementing a chasecam into my mod, and I was wondering how I would go about doing this:
- Allowing the player to switch from 1st person to 3rd person view, at a press of a (customizable) keyboard button e.g. F1.
I know that in quakeC, when working with the jump code for example, you would use self.button2 , but I have a feeling that the button field types (button0, button1, button2) available are hard coded. Is there any way to assign custom keyboard buttons to specific player actions (without the needing to use impulses)? Should I perhaps need to make use of cvar or cvar_set?
Thnx again!
P.S. Not sure if this was asked before, but I did browse the forums.
EDIT: A few minutes later...
Ok, so I now have this code in my client.qc:
- Code: Select all
// Called when a new player connects to a server or starts a new level. Informs other players that a new player has entered the game. Needed for single player?
void ClientConnect () =
{
//bind the ccam button
cvar_set("bind F1", "impulse 100"); //calls impulse 100, which activates the chasecam, everytime the player presses F1
}
I'm hoping that this will work. I have binded the key F1 to invoke the impulse command 100, which activates the chase cam. I have placed this code in the ClientConnect() function, mainly becuase I want it to be set-up everytime the client connects to the game (server). I'm gonna do some more work on it now...
....noodle...
- Zylyx_
- Posts: 111
- Joined: Wed Dec 05, 2007 6:52 pm
- Location: scotland, uk
What if the person already has F1 bound to something else? They might have their key settings just the way they like, and become a little upset...
I'd be of the opinion that keybindings belong to the player, and not to the mod developer.
I'd suggest using a cvar; Quake has 8 provided (scratch1-scratch4 which are not saved over a session, saved1-saved4 which are) for just this kind of thing.
I'd be of the opinion that keybindings belong to the player, and not to the mod developer.
I'd suggest using a cvar; Quake has 8 provided (scratch1-scratch4 which are not saved over a session, saved1-saved4 which are) for just this kind of thing.
We had the power, we had the space, we had a sense of time and place
We knew the words, we knew the score, we knew what we were fighting for
We knew the words, we knew the score, we knew what we were fighting for
-

mh - Posts: 2292
- Joined: Sat Jan 12, 2008 1:38 am
Why not simply put this into an autoexec.cfg?
bind F1 "impulse 100"
bind F1 "impulse 100"
Improve Quaddicted, send me a pull request: https://github.com/SpiritQuaddicted/Quaddicted-reviews
- Spirit
- Posts: 1031
- Joined: Sat Nov 20, 2004 9:00 pm
cvar_set doesn't execute generic console commands like bind, it only sets cvars. To send console commands to the clients use stuffcmd. For console commands to be executed on the server use localcmd.
Note any stuffcmds or prints done in ClientConnect will usually not reach the client because at that point they haven't really connected yet. Typically how I do it is set up a timer from ClientConnect and when it runs out then I do whatever stuffcmd is required then clear the timer so it doesn't occur again.
However, as pointed out autoexec.cfg, when possible, is a much cleaner solution.
Edit: also mh's point about key bindings belonging to the player I agree with 100%, I typically use this for aliases.
Note any stuffcmds or prints done in ClientConnect will usually not reach the client because at that point they haven't really connected yet. Typically how I do it is set up a timer from ClientConnect and when it runs out then I do whatever stuffcmd is required then clear the timer so it doesn't occur again.
However, as pointed out autoexec.cfg, when possible, is a much cleaner solution.
Edit: also mh's point about key bindings belonging to the player I agree with 100%, I typically use this for aliases.
Last edited by FrikaC on Tue Jan 06, 2009 9:38 pm, edited 1 time in total.
- FrikaC
- Site Admin
- Posts: 1026
- Joined: Fri Oct 08, 2004 11:19 pm
5 posts
• Page 1 of 1
Who is online
Users browsing this forum: No registered users and 1 guest