Jump to content
Parkho

Bonus your pilot skill

Recommended Posts

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

Share this post


Link to post
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?

Share this post


Link to post
Share on other sites

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

Share this post


Link to post
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?

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

Share this post


Link to post
Share on other sites

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

Share this post


Link to post
Share on other sites

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?

Share this post


Link to post
Share on other sites

The logical operator for not is just !

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

Share this post


Link to post
Share on other sites

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

}

Share this post


Link to post
Share on other sites

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

Share this post


Link to post
Share on other sites

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?

Share this post


Link to post
Share on other sites

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

Share this post


Link to post
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);

Share this post


Link to post
Share on other sites

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

Share this post


Link to post
Share on other sites

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???

Share this post


Link to post
Share on other sites

Yes, we have a custom acars and before every flight a pilot has to klick yes or no, if his flight was on IVAO. I had coded a script that check this in the admin menu, if his flight was online (IVAO Tracker).

thx for your help parkho.

Share this post


Link to post
Share on other sites

is that possible to use that and change to penalize pilots also with landing rates over -450 , like -600 rejecting the flight and returning s pilot accident minor ,mid an severe?

or accepting the flight and returning as pilot accident minor , mid , severe?

Share this post


Link to post
Share on other sites

Hi ... can someone share an example? (data base, and the module)

and then I found a lot of mistakes and the site stopped working, well that made a copy

Share this post


Link to post
Share on other sites

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

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
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. :-(

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
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...