PDA

View Full Version : Iron Sights Help.. Very Odd


befumo
07-17-2007, 09:59 PM
http://www.hl2world.com/wiki/index.php/Ironsights:_Multiplayer

I followed this tutorial and its not giving me "ironsight_toggle"..

I got 0 errors, and even 0 warnings. But it wont give me the option to bind ironsight_toggle.. Help. :confused:

Nial
07-18-2007, 11:13 AM
I'm confused by your use of the word 'bind'? I assume you want to bind the ironsight_toggle function to a key? Where are you trying to bind it, at the moment? ironsight_toggle is declared as a CON_COMMAND within that tutorials code. Have you tried calling it from the console? Does that work?

We need a little more information, if you want us to help you.

befumo
07-18-2007, 01:13 PM
Sorry for the poor wording, there is no such command as ironsight_toggle .. so i cant bind a key to it. The CON_COMMAND line is in one of the files i remember seeing it .. i forget what file but its in there.

But theres no such command as "ironsight_toggle".

Nial
07-18-2007, 02:51 PM
Right now, ironsight_toggle is being created as a CON_COMMAND meaning: the code within it can be executed from the HL2 console. To bind certain keys to ironsight_toggle, check out the kb_keys.lst file in the scripts folder of your MOD directory. You'd add something like:


"ironsight_toggle" "#Ironsight_Toggle"


This will allow you to then define a key to toggle ironsights via the standard HL2 control definition panel.

How to define custom keys for use within your code

Just as a future reference, here's a little mini-tutorial to help people define keys that can be detected via code. For no reason other than being bored out of my mind:

Open in_button.h and add the following:

#define IN_IRONSIGHT_TOGGLE (1 << 26) // Replace 26 with the next available number in the header list


Open in_main.cpp
//Below
static kbutton_t in_grenade2;

//Add
static kbutton_t in_ironsight_toggle;

Further down in_main:
// After
void IN_Grenade2Down(void) { KeyDown( &in_grenade2 ); }

//Add
void IN_Ironsight_Toggle_Up(void) { KeyUp( &in_ironsight_toggle ); }
void IN_Ironsight_Toggle_Down(void) { KeyDown( &in_ironsight_toggle ); }

Again, further down in_main:
// After
CalcButtonBits( bits, IN_GRENADE2, s_ClearInputState, &in_grenade2, bResetState );

// Add
CalcButtonBits( bits, IN_IRONSIGHT_TOGGLE, s_ClearInputState, &in_ironsight_toggle, bResetState );

Further down in_main.cpp:

// After
static ConCommand startgrenade2( "+grenade2", IN_Grenade2Down );

// Add
static ConCommand endpickup( "-ironsight_toggle", IN_Ironsight_Toggle_Down );
static ConCommand startpickup( "+ironsight_toggle", IN_Ironsight_Toggle_Up );

To check if your ironsight_toggle button has been pressed:
if ( m_afButtonPressed & IN_IRONSIGHT_TOGGLE ) {

// pressed

}

befumo
07-18-2007, 04:09 PM
Didnt work. :S I mean copy and paste, found all the files and still no such command..

ProZak
07-18-2007, 06:40 PM
You sure the updated DLL files got copied to your mod's bin folder?

befumo
07-18-2007, 07:26 PM
Yes theres no reason it wouldnt, it has been compiling for the other projects I have worked on..

Below is a link to the files i was told to edit, there are both .h and .txt formats so you can view them. Seems like i did everything proper in the tutorial.

http://befumo.profusehost.net/ironsights/

cin8
07-18-2007, 11:29 PM
most of the important code for ironsighting is in baseviewmodel_shared.cpp. if you're not seeing the ironsight_toggle console command in the console, then there's definitely something not right. make sure the dates of the dlls in you mod's bin folder are correct. i have a sneaky suspicion that the dlls are not getting copied over for some reason.

befumo
07-19-2007, 12:48 AM
Well well, according to Windows the last time i modified the client.dll was July 17... hmm now i have to figure out how to fix this. Rebuild i assume.

befumo
07-19-2007, 01:10 AM
Unbelievable. I updated the .dlls and theres still no such command as ironsight_toggles. My god.

Ark
07-19-2007, 04:33 AM
Have you looked at the tutorial by t3chn0r on Razvanadrian site about adding a new key ?
http://www.freewebs.com/razvanadrian/tutorial5.htm

ProZak
07-19-2007, 05:52 AM
Search for the command in your baseviewmodel_shared.cpp.

If it's there, try a full rebuild as you suggested yourself. :)

Marine
07-19-2007, 09:26 AM
You need to make sure you ADDED the CON_COMMAND( "ironsight_toggle" ) -- look in the tutorial.

cin8
07-19-2007, 10:55 AM
under your client and server project's properties, go to Custom Build Step->General and make sure the directory names correlate with where your mod is located. i always change the base path to an environment variable that i have setup for my mod's location. that way, i can keep project settings the same between multiple machines. it's nice if you're working in a group.

something like this:
command line:
if exist "$(MY_MOD_LOC)\bin\client.dll" attrib -r "$(MY_MOD_LOC)\bin\client.dll"
copy "$(TargetDir)"client.dll "$(MY_MOD_LOC)\bin"
outputs:
$(MY_MOD_LOC)\bin\client.dll

befumo
07-19-2007, 05:23 PM
Arg, its not updating the .dlls, so i have to rebuild. Still doesnt work, do you think its possible it could be creating new dlls but not actually making them what i put in the files when i compile?

Edit: Also i couldnt find the settings you were talking about cin8, in project properties it mentions nothing of any paths of the files.

mastersmith98
07-25-2007, 12:04 AM
did you make sure that the dll's are going to the right folder? is it in debug mode or release?

if all else fails what I would do is just start a new mod, then just slowly re do the ironsight tutorial till you get it to work.