General explanation of HL1 coding :help! Created 18 years ago2006-02-22 12:31:04 UTC by SickMothaFucker SickMothaFucker

Created 18 years ago2006-02-22 12:31:04 UTC by SickMothaFucker SickMothaFucker

Posted 18 years ago2006-02-22 12:31:04 UTC Post #164480
Hello,

I am new to the HL coding. I've just finished some maps but now I have to deal with the hardest part - coding. My aim is to create timer and after each map finished to log out in a text document this time (time till object picked, time till the end of the game).

So, please tell me how to start and what would be best. I have the HL1 SDK, AMX mod program...and I will donwload whatever it takes to make it :) But I don't know what to do now? How to start coding. How to compile, where...and so long. Just tell me a simple "todo" or tutorials... thank you!

Or if you've already worked on something like log output this would be great.

Thank you all in advance.... :lol:
Posted 18 years ago2006-02-22 13:43:30 UTC Post #164508
Well first off this is the Source mapping forums ;) So next time post in the HL1 forums...

Second off I no nothing of coding but felt it was necessary to mention you posted in the wrong place...

Hope someone can help...
Habboi HabboiSticky White Love Glue
Posted 18 years ago2006-02-23 02:53:05 UTC Post #164588
Hi ho, hi ho, to the HL1 Forum this goes!

Google's your best bet for this: I know there's a site with a good few HL coding tutorials, I just can't remember the link.
AJ AJGlorious Overlord
Posted 18 years ago2006-02-23 07:05:54 UTC Post #164612
Try to PM captain p or another one with coding experience like seventh
he just posted in forums, where can he get better help than that.

and here you go sickmothafucker...uhm...yea.. > http://www.planethalflife.com/hlprogramming/
Posted 18 years ago2006-02-23 09:19:54 UTC Post #164617
Check Wavelength. It has a nice section about programming in general and a coding section for both HL and HL2 (and some other games too).

Log output is easy. You're dealing with file streams here, and specifically file output streams. This program should do exactly that: outputting something to a file:

[quote]#include <fstream>

using namespace std;

int main()
{
ofstream out;
out.open("outputlog.txt");

out << "Say hellon";
for(int i = 0; i < 10; i++)
out << i;
out.close();

return 1;
}[/quote]

Easy, ah? You include <fstream> so you get access to some file in- and output stuff, then you create an ofstream object, then you call it's open function and provide a filename (can be done while creating the object, too) and then it's just pouring text into it. Close the file for good measure when you're done and that's it.
Posted 18 years ago2006-02-23 16:27:55 UTC Post #164684
And you're best bet for the timer would be to use SetThink();
Search trought the sdk for it.
ChickenFist ChickenFist<Witty Title>
Posted 18 years ago2006-02-24 12:05:59 UTC Post #164809
Hello guys! Thank you verry much! I'll get in a few days MS Visual Studio C++ and start coding. It doesn't seem so hard any way I have some experience in paskal,java and php.

Saco thanks for the link is verry usefull!

Captain P, I will do that but how can I assign a object to act as a code trigger or somth. Like , can I code in to the shotgun for example start counting from start of the game, when picked up stop counting time and write that in to a file.txt ? And some time after, another event will happen and I want it to be logged in the same file, will it be overwritten, or can I use tables ?

thanks
Posted 18 years ago2006-02-24 15:19:36 UTC Post #164874
Those things require some understanding of the HL game code. I'd say, do some research, try to get familiar with it.
What I'd do is find out what class(es) manage the game, and store a time variabele in them (or just do ugly and use a global var, it's easier after all and how important is maintainability in your case? ;)). Then make the shotgun code print that variabele out to a file when picked up.

As for overwriting, you can do several things while writing to files. One is to start at the end of the file, another is to erase it while opening (which you probably don't want), and so on. Invest some time and you'll get familiar with it.
You must be logged in to post a response.