View previous topic :: View next topic |
Author |
Message |
Zylyx_
Joined: 05 Dec 2007 Posts: 111 Location: scotland, uk
|
Posted: Thu Jan 01, 2009 6:26 pm Post subject: 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:
Code: | // 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... |
|
Back to top |
|
 |
mh

Joined: 12 Jan 2008 Posts: 910
|
Posted: Thu Jan 01, 2009 9:10 pm Post subject: |
|
|
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. _________________ DirectQ Engine - New release 1.8.666a, 9th August 2010
MHQuake Blog (General)
Direct3D 8 Quake Engines |
|
Back to top |
|
 |
Spirit

Joined: 20 Nov 2004 Posts: 476
|
Posted: Fri Jan 02, 2009 9:52 am Post subject: |
|
|
Why not simply put this into an autoexec.cfg?
bind F1 "impulse 100" _________________ Quake Maps |
|
Back to top |
|
 |
FrikaC Site Admin

Joined: 08 Oct 2004 Posts: 947
|
Posted: Fri Jan 02, 2009 5:10 pm Post subject: |
|
|
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.
Last edited by FrikaC on Tue Jan 06, 2009 9:38 pm; edited 1 time in total |
|
Back to top |
|
 |
Zylyx_
Joined: 05 Dec 2007 Posts: 111 Location: scotland, uk
|
Posted: Fri Jan 02, 2009 10:53 pm Post subject: |
|
|
cool, thnx for the info. I'll try that and a few other things over the weekend, hopefully. _________________ ....noodle... |
|
Back to top |
|
 |
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
Powered by phpBB © 2004 phpBB Group
|