Jump to content

Bonus your pilot skill


Parkho

Recommended Posts

  • Moderators

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. :D

  • Like 3
Link to comment
Share on other sites

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?

Link to comment
Share on other sites

  • Moderators

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.

Link to comment
Share on other sites

  • 2 weeks later...
  • 2 years later...

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?

Link to comment
Share on other sites

  • 4 months later...

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);

}

Link to comment
Share on other sites

  • Members

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);
}

Link to comment
Share on other sites

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);

Link to comment
Share on other sites

  • Moderators

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);
	 }
}

Link to comment
Share on other sites

  • 4 weeks later...
  • 1 month later...
  • 1 year later...

oooh no :-(

 

first time i think its working but now i see i have the same problem as ATAvCEO.

the tip from meiswald ( changed from < 50 to > -50 for it to work ) doesn not work.

 

i teste all kind of "<50 <-50 >50 and <-50" nothing.

my pilotes gets everytime after a flight the bonus.

maybe its not working with FSacars and Xacars??

here my code:

 # Give Bonus to good pilots
        $pilotbonus = "10";
        $userinfo = PilotData::getPilotData($pirep_details->pilotid);
        if($pirep_details->landingrate > -50 OR $pirep_details->flighttime > 3)

        $totalpay = $pilotbonus + $userinfo->totalpay ;
        $bonus = $pilotbonus +$userinfo->bonus;
        $fields = array (
                'totalpay' => $totalpay,
                'bonus' => $bonus,
         );
         PilotData::updateProfile($userinfo->pilotid, $fields);
        }

Edited by Melli
Link to comment
Share on other sites

  • Moderators
10 hours ago, Melli said:

oooh no :-(

 

first time i think its working but now i see i have the same problem as ATAvCEO.

the tip from meiswald ( changed from < 50 to > -50 for it to work ) doesn not work.

 

i teste all kind of "<50 <-50 >50 and <-50" nothing.

my pilotes gets everytime after a flight the bonus.

maybe its not working with FSacars and Xacars??

here my code:

 # Give Bonus to good pilots
        $pilotbonus = "10";
        $userinfo = PilotData::getPilotData($pirep_details->pilotid);
        if($pirep_details->landingrate > -50 OR $pirep_details->flighttime > 3)

        $totalpay = $pilotbonus + $userinfo->totalpay ;
        $bonus = $pilotbonus +$userinfo->bonus;
        $fields = array (
                'totalpay' => $totalpay,
                'bonus' => $bonus,
         );
         PilotData::updateProfile($userinfo->pilotid, $fields);
        }

I know for sure XACARS doesn't provide landing rate data and this code is working base on that. However, I'm not sure about FSACARS.

Link to comment
Share on other sites

thx parkho, same code i tested...not working in my VA.

 

you right, xacars dont log landingrates, i only testet, because im getting on each pirep a bonus.in my case, it doesnt matter is a landingrate inside the log or not...

every pirep a count a bonus, also from FSacars. :-(

Link to comment
Share on other sites

  • Moderators
45 minutes ago, Melli said:

thx parkho, same code i tested...not working in my VA.

 

you right, xacars dont log landingrates, i only testet, because im getting on each pirep a bonus.in my case, it doesnt matter is a landingrate inside the log or not...

every pirep a count a bonus, also from FSacars. :-(

Look into your PIREPS table for landing rate column and make sure its records are negative numbers. If they are positive numbers then the code doesn't work.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...