[page=The Tutorial]
This tutorial explains how to add headlights to the Jeep. It requires basic understanding of C++
The actual code is very simple
First open vehicle_jeep.h. Find:
bool HeadlightIsOn( void ) { return m_bHeadlightIsOn; }
void HeadlightTurnOn( void ) { m_bHeadlightIsOn = true; }
void HeadlightTurnOff( void ) { m_bHeadlightIsOn = false; }
and replace them with
bool HeadlightIsOn( void ) { return m_bHeadlightIsOn; }
void HeadlightTurnOn( void );
void HeadlightTurnOff( void );
Now for vehicle_jeep.cpp. Go to void CPropJeep::Precache( void ) and add these
PrecachescriptSound( "Airboat_headlight_on" );
PrecachescriptSound( "Airboat_headlight_off" );
Then in void CPropJeep::DriveVehicle( ... ) uncomment
/* if ( ucmd->impulse == 100 )
{
if (HeadlightIsOn())
{
HeadlightTurnOff();
}
else
{
HeadlightTurnOn();
}
}*/
At the end of the file add:
//-----------------------------------------------------------------------------
// Purpose:
//-----------------------------------------------------------------------------
void CPropJeep::HeadlightTurnOn( void )
{
EmitSound( "Airboat_headlight_on" );
m_bHeadlightIsOn = true;
}
//-----------------------------------------------------------------------------
// Purpose:
//-----------------------------------------------------------------------------
void CPropJeep::HeadlightTurnOff( void )
{
EmitSound( "Airboat_headlight_off" );
m_bHeadlightIsOn = false;
}
Next in void CPropJeep::ExitVehicle( int nRole ) replace
HeadlightTurnOff();
with
if (HeadlightIsOn())
{
HeadlightTurnOff();
}
And we're done! All we needed to do was uncomment some code and add a sound to play.
or is that the airboat?
i think that was the airboat !
the
PrecachescriptSound( "Airboat_headlight_on" );
PrecachescriptSound( "Airboat_headlight_off" );
should be notice the capitals.
PrecacheScriptSound( "Airboat_headlight_on" );
PrecacheScriptSound( "Airboat_headlight_off" );
ughh i dont undestand where should i find that vehicle_jeep.h. ?? 0.o
For anyone passing by and seeing scrambled code, here you go (in order of appearance):
bool HeadlightIsOn( void ) { return m_bHeadlightIsOn; }
void HeadlightTurnOn( void ) { m_bHeadlightIsOn = true; }
void HeadlightTurnOff( void ) { m_bHeadlightIsOn = false; }
-----
bool HeadlightIsOn( void ) { return m_bHeadlightIsOn; }
void HeadlightTurnOn( void );
void HeadlightTurnOff( void );
-----
PrecacheScriptSound( "Airboat_headlight_on" );
PrecacheScriptSound( "Airboat_headlight_off" );
-----
/*if ( ucmd->impulse == 100 )
{
if ( HeadlightIsOn() )
{
HeadlightTurnOff();
}
else
{
HeadlightTurnOn();
}
}*/
-----
//-----------------------------------------------------------------------------
// Purpose:
//-----------------------------------------------------------------------------
void CPropJeep::HeadlightTurnOn( void )
{
EmitSound( "Airboat_headlight_on" );
m_bHeadlightIsOn = true;
}
//-----------------------------------------------------------------------------
// Purpose:
//-----------------------------------------------------------------------------
void CPropJeep::HeadlightTurnOff( void )
{
EmitSound( "Airboat_headlight_off" );
m_bHeadlightIsOn = false;
}
-----
HeadlightTurnOff();
-----
if ( HeadlightIsOn() )
{
HeadlightTurnOff();
}
This comment is currently awaiting admin approval, join now to view.