Jump to content

Recommended Posts

  • Moderators
Posted

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
Posted

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?

  • Moderators
Posted

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.

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

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?

  • 4 months later...
Posted

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

}

  • Members
Posted

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

Posted

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?

Posted

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

  • Moderators
Posted

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

Posted

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.

  • 4 weeks later...
Posted

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?

  • 1 year later...
Posted (edited)

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
  • Moderators
Posted
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.

Posted

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

  • Moderators
Posted
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.

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