DeathPhantom Posted January 4, 2003 Share Posted January 4, 2003 i was compiling a mod i ma worknig on to test it and this erro popped up, i am anewb and of course i not know wat this means. if (!Q_stricmp (model, "jango_fett/default")) client->pers.newplayerclass = PCLASS_GUY; msg = "HI\n"; msg = "hi\n"; had an error that said undeclared idetifier how can i fix this wat does it mean? thx:confused: Link to comment Share on other sites More sharing options...
razorace Posted January 4, 2003 Share Posted January 4, 2003 msg is undefined. It is probably missing it's "defination". Please read a C++ tutorial for more information. Link to comment Share on other sites More sharing options...
DeathPhantom Posted January 4, 2003 Author Share Posted January 4, 2003 wat is the command to print message on the screen? Link to comment Share on other sites More sharing options...
DeathPhantom Posted January 5, 2003 Author Share Posted January 5, 2003 how do i add definition? Link to comment Share on other sites More sharing options...
Tchouky Posted January 5, 2003 Share Posted January 5, 2003 char * msg; at the begining of your function. to print it use : Com_Printf() for bg files, G_Printf() for the g_* files and CG_Printf() for cg_* files. Link to comment Share on other sites More sharing options...
Commodus Posted January 5, 2003 Share Posted January 5, 2003 You can use Com_printf() in g_ files as well... it works in g_cmds for me anyway. Link to comment Share on other sites More sharing options...
DeathPhantom Posted January 5, 2003 Author Share Posted January 5, 2003 thx for all ur help Link to comment Share on other sites More sharing options...
DeathPhantom Posted January 5, 2003 Author Share Posted January 5, 2003 i am working in g_client.c file, i tried using g_printf() but i not know if i did it right can uplz give me an example? Link to comment Share on other sites More sharing options...
razorace Posted January 5, 2003 Share Posted January 5, 2003 This is my simple code for debug messaging for MotF. //Dodge Debug if ( motf_debugdodge.integer == 1) { G_Printf( "%i: Client:%i PreDodge Health:%i Dodge:%i Damage:%i\n", level.time, targ->s.number, targ->health, client->ps.stats[sTAT_DODGE], damage ); G_Printf( "Dodged:%i Remaining Damage:%i PostDodge Health:%i\n", dsave, take, deadometer ); } Link to comment Share on other sites More sharing options...
Wudan Posted January 6, 2003 Share Posted January 6, 2003 Very nice very clean. Must be why MOTF is a pretty big success. Link to comment Share on other sites More sharing options...
razorace Posted January 6, 2003 Share Posted January 6, 2003 If by "clean" you mean "sloppy", and by "pretty big success" you mean "no servers", then yes! BTW, that code is just an example. It wouldn't compile unless you got it in a correct place and with a cvar for the if statement. Anyway, since you want to print a string, you'd probably have to use %s (string varible) instead of an %i (integer varible). %i = Integer %s = String %f = Float Another Example.... Yes, I know it uses Com_Printf, but it uses the same syntax. This was an experiment to see what if Com_Printf would print to all the clients (It doesn't). Both G_Printf and Com_Printf seem to only print to the server. if ( motf_debugdodge.integer == 2 ) { Com_Printf( "Client %i was hit in the %s.\n", self->s.number, hitLocName[hitLoc] ); } Link to comment Share on other sites More sharing options...
Wudan Posted January 6, 2003 Share Posted January 6, 2003 Well, I don't play as much as I should, but MOTF is still a pretty damn good concept, you should still keep with it. Are you still planning on releasing the source as teh original plans indicated, or do you cherish you 1337ness enuff to hide it away? Link to comment Share on other sites More sharing options...
razorace Posted January 6, 2003 Share Posted January 6, 2003 Well, the plan changed. There's simply too much cut & paste modding to allow us to release the source without every mod in the universe changing a small setting and then releasing it as their "own" mod. However, we'll release the code to anyone that we feel is worth of the code. (Such as people with legit mods that don't directly compete with MotF). Link to comment Share on other sites More sharing options...
recombinant Posted January 6, 2003 Share Posted January 6, 2003 Originally posted by DeathPhantom i am working in g_client.c file, i tried using g_printf() but i not know if i did it right can uplz give me an example? please note from Razorace's example that C is case sensitive, so g_printf(...) is NOT the same thing as G_Printf(...) and will give you compile-time errors. As was suggested earlier, it's worth your while to acquire (and read) a book on C. There are many to choose from. Just go to Amazon and search for "C Programming" (or visit your local bookstore), Amazon also has used books so you could save some money that way... Have Fun! Link to comment Share on other sites More sharing options...
DeathPhantom Posted January 9, 2003 Author Share Posted January 9, 2003 as a metter of fact id ohave abooki had a glance it in about my error but i oculdn't find anything, i loked on the net but they where talknig about other commands. i heard that jk2 is programmed in c, i am confused because i can't tell the differencce between c and c++, cause i use visual c++ 6. adn the book i use is c++ in 21 days Link to comment Share on other sites More sharing options...
razorace Posted January 9, 2003 Share Posted January 9, 2003 Jk2 code is coded in C++. If C++ was an OS, it would be Windows 95 and C would be Windows 3.1. There are some major differences between C and C++, but it should be fairly easy to learn the C after C++. Link to comment Share on other sites More sharing options...
recombinant Posted January 9, 2003 Share Posted January 9, 2003 Originally posted by razorace Jk2 code is coded in C++. Ummm... I think you meant to say "Jk2 code is coded in C" or better yet, "Jk2 MP is coded in C," not C++. If it was in C++ the source would consist of .cpp files, not .c files, and you would see classes all over the place instead of structs. Basically, C++ is the Object Oriented successor to C, and supports OOP features such as Encapsulation, Inheritance, and Polymorphism, which C does not. Q3/JK2 simulates classes by creating structs with publicly exposed variables (as public properties) and function pointers (as public methods), but it's not C++. If you'd like to see what JK2 would look like written in C++, check out the Elite Force Single Player source. I suspect that the Single Player version of JK2 is based on this code and is also written in C++, but we'll have to wait and see for that, I guess... Link to comment Share on other sites More sharing options...
razorace Posted January 10, 2003 Share Posted January 10, 2003 Well, I could be wrong. I don't have much experience with the differences between C and C++. I've only learned stuff in C++. It's not like C++ hasn't been around a while. BTW, I think you just melted out half the brains in the room with that explaination. I'd lay off the big words in the newbie threads. We don't want to scare them off. Link to comment Share on other sites More sharing options...
recombinant Posted January 10, 2003 Share Posted January 10, 2003 BTW, I think you just melted out half the brains in the room with that explaination. I'd lay off the big words in the newbie threads. We don't want to scare them off. LOL. You could be right about the brain melting.... sorry about that - I'll try to control myself. Anyway, programmers have to learn this stuff at some point. [melt] But you are absolutely right in your comparison of C vs. C++. C++ is like C on steroids. [/melt] The problem with learning C++ first is that there are language extensions that are not available in C, and a reference like the one he's got will cover a lot of unnecessary topics in the long run. He will still need to get a reference book such as Kernighan & Ritchie ("K&R") book, which is the definitive standard manual on C (since they wrote C in the first place), but it's a tad dry. There are some other very good C references out there, however. I'd recommend going to a bookstore and finding a book written by someone whose writing style you like, and if it's too expensive to purchase new, look for a used copy on Amazon or eBay. Have Fun! Link to comment Share on other sites More sharing options...
Wudan Posted January 10, 2003 Share Posted January 10, 2003 Well, C is like C++, except for the minor fact that it is not C++. I don't think his explanation would kill anyone who cares to code JK2. The syntax is similar, but there's Object Orientated junk in C++ that won't work in C. Yeah Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.