mavrik65@Posted: Tue Aug 05, 2008 6:54 pm :
okay basicly what I am trying to do is call a function ( called
idPlayer::OffsetChainsawView(); ) found in player.cpp from WeaponChainsaw.cpp I have attempted this:

WeaponChainsaw.cpp
Code:
owner->WeaponFireFeedback( &weaponDef->dict );

idPlayer::OffsetChainsawView();
   
if ( tr.fraction >= 1.0f ) {
      if ( impactEffect ) {
         impactEffect->Stop ( );
         impactEffect = NULL;
      }
      impactMaterial = -1;
      PlayLoopSound( LOOP_NONE );
      return;
   } e.c.t


but it kept coming up with the same error:

1>.\game\weapon\WeaponChainsaw.cpp(197) : error C2660: 'idPlayer::OffsetChainsawView' : function does not take 0 arguments

sorry for sounding like a noob but what are arguments? and is it possible to call an id::player function from a weapon object?



der_ton@Posted: Tue Aug 05, 2008 8:11 pm :
You're trying to write C++ code there without knowing much about that language. If you're serious about tinkering with the SDK I'd recommend to read a book or online guide about C++ and object oriented programming.

But maybe you don't want to really learn C++ but just want to quickly try something out. I'll try to roughly answer your question, omitting alot of finer details.
Arguments are the parameters given to a function call, listed in parentheses. For example PlayLoopSound( LOOP_NONE ) is a function call where LOOP_NONE is the argument, the only one in this case. If you call a function, you have to give it the right number and type of arguments it needs to have. You can look that up in the function's definition or in the header file, or your Visual Studio might give you a hint while you are editing.

Another problem is that when you call the OffsetChainsawView function of an object that is an instance of the idPlayer class, you have to write that in a different way than you did. You need to specify an instance of the idPlayer class, not the idPlayer class itself. And you don't use the :: but you use a . or a -> (like "owner->WeaponFireFeedback( &weaponDef->dict )" ).
If "owner" is an instance of idPlayer or one of its subclasses (I don't know if it is), you could write owner->OffsetChainsawView( valid list of arguments here).



mavrik65@Posted: Wed Aug 06, 2008 9:00 am :
I understand now I put the arguments in before (without knowing they were called arguments) but it didn't work because I had written it wrong (like you said). I had tried to learn c++ before but it was really boring ( I had tried to read a c++ beginners book but I later find out I learn faster from a hands on approach), so I went from darkbasic to .def coding to doom scripting and then to c++. I then had some success with c++ so I continued to use it.

thanks for the help der ton :D



Infernal=WFR@Posted: Mon Sep 22, 2008 1:13 pm :
I'm sorry, but saying it's boring is the first sign of troubled times ahead. I really do suggest you get a good book on C++. There are many facets and legacies from C in the language that need to be explained. Just trying them out may not always be as intuitive as you think. This will come to play if you ever feel like extending the game's internal data. We implemented some of our own container objects with iterators when we found the namespace disallowing std.