This won't work.  If the KeyValue function is called again after the defaultctf
key comes through, then the cvar will be reset to zero and the actual value
will be lost.  What you need to do is have a flag:

int fResetDefaultCTF = false;
void CFubar::KeyValue (..etc..)
{
    if (!fResetDefaultCTF)
    {
         // defaultctf cvar has not been reset
         CVAR_SET_FLOAT("oz_defaultctf", 0);
         fResetDefaultCTF = true;
    }

    // blah...
    // normal code to check keyvalues including defaultctf keyvalue
}

Then the cvar will only be reset once.  You need to reset the flag back to
false after all the keyvalues have been sent, a good place to do this is the
Spawn function of the same entity.  (Spawn is always called _after_ all the
keyvalues have been sent to the KeyValue function.)

--- Varlock <[EMAIL PROTECTED]> wrote:
>     I'm not sure if I totally understand your problem, but what I get is
> that you want to read in this "defaultctf" keyvalue from the worldspawn
> entity, and if it's not there then just set the corresponding variable (in
> this case, a cvar) to zero. I don't follow what you say after that, but I
> don't see why a solution along these lines (semi-pseudocode here) won't
> work:
> 
> Entity :: KeyValues( blah )
> {
>     CVAR_SET_FLOAT( "oz_defaultctf", 0 );
> 
>     if( keyvalue is "defaultctf" )
>     {
>         CVAR_SET_FLOAT( "oz_defaultctf", value );
>     }
> }
> 
>     If this is correct, the oz_defaultctf cvar will be 0 unless it detects
> the defaultctf keyvalue in which case it sets the cvar to be the value read
> from worldspawn. I didn't really understand what the rest of your original
> message was about, so maybe I'm way off track.
> 
> - Varlock
> 
> ----- Original Message -----
> From: "Dave R. Meyers" <[EMAIL PROTECTED]>
> To: <[EMAIL PROTECTED]>
> Sent: Sunday, December 30, 2001 1:38 AM
> Subject: Re: [hlcoders] world.cpp Keyvalues
> 
> 
> > Also in regards to my last post, I have worked out an interim solution,
> but
> > I do not like it.
> >
> >  if ( !strncmp( ( char * )STRING( gpGlobals->mapname ), "oz_ctf", 6 ) == 0
> > && !strncmp( ( char * )STRING( gpGlobals->mapname ), "op4ctf_", 7 ) == 0)
> >  CVAR_SET_STRING( "oz_defaultctf", "0" );
> >
> > this seems to work great, but the problem is, I want to use some maps,
> that
> > do not have those as prefixes, and I do not want to add every map name to
> > the list.
> >
> > Dave R. Meyers
> > aka Starbreaker
> > www.starbraker.com
> > Lead Coder Oz Deathmatch
> >
> > _______________________________________________
> > To unsubscribe, edit your list preferences, or view the list archives,
> please visit:
> > http://list.valvesoftware.com/mailman/listinfo/hlcoders
> >
> 
> _______________________________________________
> To unsubscribe, edit your list preferences, or view the list archives, please
> visit:
> http://list.valvesoftware.com/mailman/listinfo/hlcoders
> 


__________________________________________________
Do You Yahoo!?
Send your FREE holiday greetings online!
http://greetings.yahoo.com
_______________________________________________
To unsubscribe, edit your list preferences, or view the list archives, please visit:
http://list.valvesoftware.com/mailman/listinfo/hlcoders

Reply via email to