While working on the mod, I decided that we would need to create custom command
s. Unfamiliar with the actual source I had to explore and learn it for myself. This proved to be tought. A word of advice
, leave the cl_dll alone until you are familiar with it, because you won't be able to easily add commands there.
The place to look for adding you commands would be in the mp.dll, in the client.cpp file
to be more specific. To add you command go to the function
ClientCommand()--the line that says "void ClientCommand( edict_t *pEntity )".
down to about line #384. After the "else if", but before the last "else" put in this code:
else if (FStrEq(pcmd, "mycommand"))
DO STUFF HERE
My understanding isnt great but I assume that the FStrEq
function compares a player's command (pcmd) with one of the came commands (the second parameter) and returns a TRUE if the two are the same. The bracketed stuff is how the command is gonna reacted when it is called.
This basically adds the code for the command, the next part is optional for if you want the user to be able to change the command's binding in the Half-Life's Controls section in the Configuration
In your mod directory add a folder
called "gfx" (if you don't already have one"), in that folder add another called "shell," it is in this directory
where you will place 2 files which will add the control to the game's control menu.
This write-up assumes that you have SDK version 2.0, is not, get it or your mod will not work with the newer version of HL. Now in the "SDK" folder, open the "shell" and find the files "kb_act.lst" and "kb_def.lst" and move them to the shell folder in your mod directory.
Open the "kb_act.lst" file, this basically defines the description that will be used to identify the command in the Controls menu. Go to the end, or beginning, of the file and add this line: "mycommand" "Description"
where mycommand is your command's name as it appears in the source code, and the Description is the very basic description of the command. Next open the "kb_def.lst" file, this sets the default bindings for the game's commands. At the beginning of the file add this line: "key" "command"
where key is the key you want the command to be bound to by defaul, and command is the command's name as it appears in the source code.
This is just a primitive summary
of how to add a command, I will hopefully add more write-ups that deal with Half-Life's source code as I figure it out.