Bonus your pilot skill

First off add a column into your phpvms_pilots in your DB as “bonus” the type must be “float” and set default az “0”. Then open the following:

Admin/modules/PIREPadmin/PIREPAdmin.php go down to line 298 and find the function called : approve_pirep_post(). Now go to the end of it and add the following:

After this:

# Call the event
CodonEvent::Dispatch('pirep_accepted', 'PIREPAdmin', $pirep_details);

Add this:

# Give Bonus to good pilots
$pilotbonus = "500";
$userinfo = PilotData::getPilotData($pirep_details->pilotid);
if($pirep_details->landingrate > -50 OR $pirep_details->flighttime > 8)
{
 $totalpay = $pilotbonus + $userinfo->totalpay ;
 $bonus = $pilotbonus +$userinfo->bonus;
 $fields = array (
	 'totalpay' => $totalpay,
	 'bonus' => $bonus,
	 );
 PilotData::updateProfile($userinfo->pilotid, $fields);
}

then go to your profile_main.tpl and after this:

<li><strong>Total Money: </strong><?php echo FinanceData::FormatMoney($userinfo->totalpay) ?></li>

Add this:

<li><strong>Total Bonus: </strong><?php echo FinanceData::FormatMoney($userinfo->bonus) ?></li>

Now when you recieve pireps and hit the accept button, your pilots get bonus on low landing rate or long haul. Off course you can adjust the variables to your desire as follows:

$pilot bonus = "500" // This is set to 500 and can be changed.
landing rate is set to -50 ft/m.
flight time is set to 8 hours.

Enjoy.

Hi Parkho,

Awesome idea, but I added everything as specified above and my VP of Ops did a flight he had a landing rate of 240+ and it still credited him the $250 bonus. I kept all the settings the same as what you have listed above with the < 50 and 8. His flight was only 1.2 hours long. I set the bonus to 250

Any ideas?

I have something similar to this on my site… I’m pretty sure the calculation must be changed from < 50 to > -50 for it to work

Please delete this post. Duplicated the above one by mistake

Hi Parkho,

Awesome idea, but I added everything as specified above and my VP of Ops did a flight he had a landing rate of 240+ and it still credited him the $250 bonus. I kept all the settings the same as what you have listed above with the < 50 and 8. His flight was only 1.2 hours long. I set the bonus to 250

Any ideas?

I have tested it and it works fine, maybe mseiwald is right and you’re gonna have to change the <50 to >-50.

Ok, thanks will give it a try and see what happens.

Thanks for the info

I have tested it and it works fine, maybe mseiwald is right and you’re gonna have to change the <50 to >-50.

will give it a try

Thanks guys for the help mseiwald’s idea worked perfectly.

Thanks for this code!

We also use it, but we have a problem. In our Fleet is a helicopter with the aircraft id 5, this ‘aircraft’ is not allowed to gain bonus. We use this code:

$pilotbonus = “50”;

$userinfo = PilotData::getPilotData($pirep_details->pilotid);

if($pirep_details->landingrate > -80 AND $pirep_details->aircraft != 5)

{

$totalpay = $pilotbonus + $userinfo->totalpay ;

$bonus = $pilotbonus +$userinfo->bonus;

$fields = array (

‘totalpay’ => $totalpay,

‘bonus’ => $bonus,

);

PilotData::updateProfile($userinfo->pilotid, $fields);

But still the helicopter pilots earn bonus, what is wrong?

The logical operator for not is just !

Try if($pirep_details->landingrate > -80 AND $pirep_details->aircraft ! 5)

OK thx, I will try it

Is it possible to give bonus to a pilot, if the pireplog contains a string like “IVAO”?

I had coded something, but every pilot get the IVAO bonus money after accepting the Pirep, also the offline pilots. This was my code:

$pilotbonus = “50”;

$userinfo = PilotData::getPilotData($pirep_details->pilotid);

if($pirep_details->log!=str_replace(“IVAO”,“”,$string))

{

$totalpay = $pilotbonus + $userinfo->totalpay ;

$bonus = $pilotbonus +$userinfo->bonus;

$fields = array (

‘totalpay’ => $totalpay,

‘bonus’ => $bonus,

);

PilotData::updateProfile($userinfo->pilotid, $fields);

}

Try this

$pilotbonus = "50";
$userinfo = PilotData::getPilotData($pirep_details->pilotid);
$FindIvao = strpos($pirep_details->log,IVAO)
if($FindIvao === true)
{
	 $totalpay = $pilotbonus + $userinfo->totalpay ;
	 $bonus = $pilotbonus +$userinfo->bonus;
	 $fields = array (
			 'totalpay' => $totalpay,
			 'bonus' => $bonus,
			 );
	 PilotData::updateProfile($userinfo->pilotid, $fields);
}

Hi, thx for the help, but it dosen’t work, no pilot get’s a bonus. Also I have added “;” after $FindIvao = strpos($pirep_details->log,IVAO), cause without I get an error.

Perhaps “$pirep_details->log” is the wrong variable?

Yes sorry i forgot to add it

In with class do you add this ?

I just added it after the pilotbonus option.

But I think it’s the right variable. So I don’t know whats the problem.

Hi, is ‘IVAO’ part of your flight log? Meaning do you see that word in your flight log when you open it?

Hi,

yes for sure, this is a part of the log:

[17:46] - IVAO Online Flight

and this is the class for the pirep_details, i am sure the logfile is in there:

public static function getReportDetails($pirepid)

{

$sql = 'SELECT p.*, s.*, s.id AS scheduleid, p.route, p.route_details,

u.pilotid, u.firstname, u.lastname, u.email, u.rank,

dep.name as depname, dep.lat AS deplat, dep.lng AS deplng,

arr.name as arrname, arr.lat AS arrlat, arr.lng AS arrlng,

p.code, p.flightnum, p.depicao, p.arricao, p.price AS price,

a.id as aircraftid, a.name as aircraft, a.registration, p.flighttime,

p.distance, UNIX_TIMESTAMP(p.submitdate) as submitdate, p.accepted, p.log

FROM '.TABLE_PREFIX.'pilots u, '.TABLE_PREFIX.'pireps p

LEFT JOIN '.TABLE_PREFIX.'airports AS dep ON dep.icao = p.depicao

LEFT JOIN '.TABLE_PREFIX.'airports AS arr ON arr.icao = p.arricao

LEFT JOIN '.TABLE_PREFIX.'aircraft a ON a.id = p.aircraft

LEFT JOIN '.TABLE_PREFIX.'schedules s ON s.code = p.code AND s.flightnum = p.flightnum

WHERE p.pilotid=u.pilotid AND p.pirepid='.$pirepid;

$row = DB::get_row($sql);

$row->rawdata = unserialize($row->rawdata);

Try this:

public static function get_ivao_log($id)
{
$sql = "SELECT * FROM phpvms_pireps WHERE pirepid = '$id'";
$result = DB::get_row($sql);
$log = explode('*', $result->log);
foreach($log as $line)
 {
       if (strpos($line, "IVAO") !== false)
         {
            $temp = $line;
            break;
         }
 }
 $temp = explode(' ', $temp);
 $title = $temp[1];
 return $title;
}

And to call it:

YourCommonFile::get_ivao_log($pirep->pirepid);

You could assign this to a variable like:

$ivao = YourCommonFile::get_ivao_log($pirep->pirepid);

And say it like :

if($ivao == "IVAO")
{
 $pilotbonus = "500";
 $userinfo = PilotData::getPilotData($pirep_details->pilotid);
 if($pirep_details->landingrate > -50 OR $pirep_details->flighttime > 8)
	 {
	 $totalpay = $pilotbonus + $userinfo->totalpay ;
	 $bonus = $pilotbonus +$userinfo->bonus;
	 $fields = array (
			 'totalpay' => $totalpay,
			 'bonus' => $bonus,
			 );
	 PilotData::updateProfile($userinfo->pilotid, $fields);
	 }
}

can i ask a question?? because our VA is an Aproved Airline in the IVAO network, this bonus is when a pilot create a PIREP in IVAO gets the bonus???