//Focus on the car used by the script owner
rcar $car=get scriptowner car
float $rpm
float $throttle
float $upthrottle = 0
float $unthrottle = 0
float $clutch
float $diff
float $finalthrottle
int $gear
float $speed
//rcarmodel $cam = get generic model 24 of $car
//set $cam scriptcontrolled 1
int $idle = 000
while 1
{
	$rpm = get $car rpm
	$throttle = get $car throttle
	$clutch = get $car clutch
	$diff=($idle/1.0*$rpm)
	$gear = get $car gear
	$speed = get $car tachovelocity
	$speed = $speed*3.60
	float $maxtorque = get $car maxtorque factor
	float $indice_moteur = get system "car0.engine.inertia"
	//1.9D
	if $indice_moteur == 0.230
	{
		$idle = 800
	}
	//2.0Hdi
	if $indice_moteur == 0.245
	{
		$idle = 725
	}
	//1.6HDi
	if $indice_moteur == 0.195 
	{
		$idle = 825
	}
	//Essence
	if $indice_moteur == 0.130 
	{
		$idle = 725
	}
	if $rpm < $idle
	{
		if $upthrottle < (1.00-$throttle)
		{
			$upthrottle+=0.05*$diff
		}
	}
	if $rpm > $idle
	{
		if $upthrottle > 0.0
		{
			$upthrottle-=0.125*$diff
		}
	}
	if $rpm > 1.001*$idle
	{
		$upthrottle = 0
	}
	if $finalthrottle <= 1.00
	{
		$finalthrottle = $throttle + $upthrottle
	}
	if $clutch > 0.05
	{
		$finalthrottle = ($throttle + $upthrottle)*(1.00/$maxtorque)
	}
	if $clutch <= 0.05
	{
		$finalthrottle = ($throttle + $upthrottle)*(1.00)
	}
	if $rpm < 650
	{
		$finalthrottle = $throttle
	}
	if $gear == 1
	{
		//set $cam position float[3]{0,0,0.0}
	}
	else
	{
		//set $cam position float[3]{0,-10,0.0}
	}
	if is key 70 pressed and $speed < 5
	{
		//Key F to stop engine
		send "stop engine" to console
	}
	if $finalthrottle > 1.00
	{
		$finalthrottle = 1.00
	}
	set $car throttle $finalthrottle
	interrupt
}