Hey,
I guess this is a stupid question, but I was wondering at what point/file in the source code, wolfenstein is loaded (at which point the player is at the main menu), because I want to add something there.
I hope this explains enough.
Hey,
I guess this is a stupid question, but I was wondering at what point/file in the source code, wolfenstein is loaded (at which point the player is at the main menu), because I want to add something there.
I hope this explains enough.
You should search for this function in main files:
int vmMain( int command, int arg0, int arg1, int arg2, int arg3, int arg4, int arg5, int arg6, int arg7, int arg8, int arg9, int arg10, int arg11 )
Everything what you see in game, write in console, move your mouse…etc, is handled in that “engine API function”.
But if you thought about engine, then search for this function in WindowsOS side in engine code.
int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow )
Hi Rutger,
What is it that you’re trying to add ? Maybe we can get more specific, like going to (ui.mp.x86_project/ui_main)_UI_Init for example
Let’s say I want to echo something to the console, or e.g. check if a file exists, the moment the main menu is loaded.
Okay, I tried adding CG_Printf(“Hi”); to CG_Init in the cg_main.c file, located in the cgame folder. Compiled it, and placed it in the etmain folder of my wolfenstein folder (ofcourse I made a backup :P). But the text is not printed. What am I doing wrong?
CGame(client game) is only loaded when you load a map, untill then(when you’re in the main menu) CGame is not loaded and therefor won’t show you your message.
If you want to do stuff in the menu you should be using the UI library.
Thanks for helping me out. Is there btw also a way to see when punkbuster is initialized? Because when wolfenstein starts, some seconds later you can see in the console some punkbuster messages, meaning it’s initialized.
Try this
int pb_cl;
pb_cl = (int)trap_Cvar_VariableValue( "cl_punkbuster" ); // This gets clients punkbuster cvar value [0|1]
if( !pb_cl ) { // If punkbuster cvar value is 0
trap_Print( "^1Punkbuster is not enabled
" ); // Then print into console "Punkbuster is not enabled"
}
means newline, it will just print a newline at the end of the line, so that the next text output will be a line below the “^1Punkbuster is not enabled” stuff ;).
Yeah it has to be inside the quotes. Sorry, I misunderstood your question then :P.
I never programmed, but I guess if you had a “else” value you can make it print “PB enabled”?
Yes.
if( something ) {
then do this
} else { If it isn't something
then do this
}
[QUOTE=Indloon;402439]Try this
int pb_cl;
pb_cl = (int)trap_Cvar_VariableValue( "cl_punkbuster" ); // This gets clients punkbuster cvar value [0|1]
if( !pb_cl ) { // If punkbuster cvar value is 0
trap_Print( "^1Punkbuster is not enabled
" ); // Then print into console "Punkbuster is not enabled"
}
[/QUOTE]
Thanks, but what I mean is, I want to know when Punkbuster is initialized, and not enabled. When you start up Wolfenstein, after like 5 seconds, a message is displayed by the Punkbuster Client, that it is enabled. And I want to perform a certain action, after that initialization.
Is there any way to maybe catch console messages, so I could see when this message has been printed, and perform my action after that?
[QUOTE=Rutger;402462]
Is there any way to maybe catch console messages, so I could see when this message has been printed, and perform my action after that?[/QUOTE]
By engine functions, no.
However, you can get text from console by using Windows API functions.
Please read about it here: http://jmp.kapsi.fi/etqw/console/
It works for Q3 too.
E: This gave me great idea to check if TZAC is enabled ^^
Thanks :).
Though, in the function SendMessage, to get the text of the console, I must specify the amount of lines ((WPARAM) sizeof(console)), but I only want the last line. How can I achieve this?
I’m sorry, I’m a real noob at C++ xD.
And when I use WM_GETTEXTLENGTH, to get the length of all the text in the console_text, it crashes.
[QUOTE=Rutger;402468]Thanks :).
Though, in the function SendMessage, to get the text of the console, I must specify the amount of lines ((WPARAM) sizeof(console)), but I only want the last line. How can I achieve this?
I’m sorry, I’m a real noob at C++ xD.
And when I use WM_GETTEXTLENGTH, to get the length of all the text in the console_text, it crashes.[/QUOTE]
Well I have been always duck at text parsing in programming, never learned it fully.
But you should find two last "
" characters, so you can locate last line, because console output looks like this:
....
Banhammer
Banhammer
Bannhamer
Banhammer
But as I said previously I’m very beginner at text parsing, so You should ask it here: http://stackoverflow.com
You should use this instead of WM_GETTEXTLENGHT this:
(WPARAM) sizeof(console)
Yeah but I have to specify the size of console myself. MAX_CONSOLE_LEN, is not defined anywhere. And if I choose to give console a size of 255, it will never get to the end of the console. So I’ll have to get the console text length with the WM_GETTEXTLENGTH, but if I try to create a variable after that, I get an error because of the code style, variables have to be created in the top of the void.