Jump to content

Pilots Currently In flight


Oxymoron290

Recommended Posts

Hey Guys! So we were doing some development at woava.net tonight and came up with this little puppy. Thought you guys would like it.

It checks weather the selected user is in a flight or not, if the user is in a flight it displays the current status of a flight, (parked, pushing back, taking off, etc...), Their departure to arrival in the format of DEPICAO -> ARRICO, (ex, kdfw -> klax), and the precentage currently based on distance from the flight. You can also base it on time using the variables

<?php
$acars->deptime;
$acars->timeremaining;
//and
$acars->arrtime;
?>

Anyways, enjoy!

<?php
/** ==================VVVV Checking Current logged in user VVVV================== **/
$acarsdata = ACARSData::GetACARSData();



if($acarsdata != null || !empty($acarsdata)){
foreach($acarsdata as $acars){
if($acars->pilotid == Auth::$userinfo->pilotid){
echo '<br />You are currently in a flight!';
echo '<br />Status: '.$acars->phasedetail;
//echo '<br />Departure: '.$acars->depicao.' ';//.$acars->depname;
//echo '<br />Arrival: '.$acars->arricao.' ';//.$acars->arrname;
echo '<br />'.$acars->depicao .' -> '. $acars->arricao;
$totalDistance = OperationsData::getAirportDistance($acars->depicao, $acars->arricao);
$remainingDistance = $acars->distremain;
$precent = ($remainingDistance/$totalDistance)*100; // Counts down precentage. 100%, 99%, 98%, etc...
$precent = abs($precent-100); // Counts up precentage. 0%, 1%, 2%, etc...
echo '<br />Precentage: ' . round($precent) . '%';

}else{
echo '<br />You are NOT currently in a flight!';
}

}
}else{
echo '<br />You are NOT currently in a flight!';
}
/** ==================^^^^ Checking Current logged in user ^^^^================== **/

/** ===================================VVVV Pilot Public Profile dot tee pee elle VVVV============================= **/
$acarsdata = ACARSData::GetACARSData();


if($acarsdata != null || !empty($acarsdata)){
foreach($acarsdata as $acars){
if($acars->pilotid == $pilot->pilotid){
echo '<br />Pilot is currently in a flight!';
echo '<br />Status: '.$acars->phasedetail;
//echo '<br />Departure: '.$acars->depicao.' ';//.$acars->depname;
//echo '<br />Arrival: '.$acars->arricao.' ';//.$acars->arrname;
echo '<br />'.$acars->depicao .' -> '. $acars->arricao;
$totalDistance = OperationsData::getAirportDistance($acars->depicao, $acars->arricao);
$remainingDistance = $acars->distremain;
$precent = ($remainingDistance/$totalDistance)*100; // Counts down precentage. 100%, 99%, 98%, etc...
$precent = abs($precent-100); // Counts up precentage. 0%, 1%, 2%, etc...
echo '<br />Precentage: ' . round($precent) . '%';

}else{
echo '<br />Pilot is NOT currently in a flight!';
}
}else{
echo '<br />Pilot is NOT currently in a flight!';
}
/** ===================================^^^^ Pilot Public Profile dot tee pee elle ^^^^============================= **/

?>

Any improvements? comments? questions? feel free to ask!

P.S. This goes on the pilot_public_profile.tpl

<?php

$usersOnline = StatsData::UsersOnline();
$check = false;

if($usersOnline != null || !empty($usersOnline)){
foreach($usersOnline as $user){
if($user->pilotid == $pilot->pilotid){
$check = true;
}else{
$check = false;
}
if($check){
break;
}
}
if($check){
echo 'Pilot is currently Online';
}else{
echo 'Pilot is currently Offline';
}
}else{
echo 'Pilot is currently Offline';
}
?>

Edit: Had to add in the if($acarsdata != null || !empty($acarsdata)) to prevent errors when there are no flights in progress.

Edited by Oxymoron290
  • Like 3
Link to comment
Share on other sites

echo '<br />Precentage: ' . round($precent) . '%';

}else{

echo '<br />Pilot is NOT currently in a flight!';

}

}else{

echo '<br />Pilot is NOT currently in a flight!';

}

/** ===================================^^^^ Pilot Public Profile dot tee pee elle ^^^^============================= **/

?>

needs to be like

echo '<br />Precentage: ' . round($precent) . '%';

}else{

echo '<br />Pilot is NOT currently in a flight!';

}

}

}

/** ===================================^^^^ Pilot Public Profile dot tee pee elle ^^^^============================= **/

?>

becau it gives me errors

thanks

Link to comment
Share on other sites

  • 2 weeks later...
  • 2 weeks later...
  • 1 year later...
  • 3 weeks later...

Where does this go?

<?php
/** ==================VVVV Checking Current logged in user VVVV================== **/
$acarsdata = ACARSData::GetACARSData();

if($acarsdata != null || !empty($acarsdata)){
foreach($acarsdata as $acars){
if($acars->pilotid == Auth::$userinfo->pilotid){
echo '<br />You are currently in a flight!';
echo '<br />Status: '.$acars->phasedetail;
//echo '<br />Departure: '.$acars->depicao.' ';//.$acars->depname;
//echo '<br />Arrival: '.$acars->arricao.' ';//.$acars->arrname;
echo '<br />'.$acars->depicao .' -> '. $acars->arricao;
$totalDistance = OperationsData::getAirportDistance($acars->depicao, $acars->arricao);
$remainingDistance = $acars->distremain;
$precent = ($remainingDistance/$totalDistance)*100; // Counts down precentage. 100%, 99%, 98%, etc...
$precent = abs($precent-100); // Counts up precentage. 0%, 1%, 2%, etc...
echo '<br />Precentage: ' . round($precent) . '%';
}else{
echo '<br />You are NOT currently in a flight!';
}
}
}else{
echo '<br />You are NOT currently in a flight!';
}
/** ==================^^^^ Checking Current logged in user ^^^^================== **/
/** ===================================VVVV Pilot Public Profile dot tee pee elle VVVV============================= **/
$acarsdata = ACARSData::GetACARSData();

if($acarsdata != null || !empty($acarsdata)){
foreach($acarsdata as $acars){
if($acars->pilotid == $pilot->pilotid){
echo '<br />Pilot is currently in a flight!';
echo '<br />Status: '.$acars->phasedetail;
//echo '<br />Departure: '.$acars->depicao.' ';//.$acars->depname;
//echo '<br />Arrival: '.$acars->arricao.' ';//.$acars->arrname;
echo '<br />'.$acars->depicao .' -> '. $acars->arricao;
$totalDistance = OperationsData::getAirportDistance($acars->depicao, $acars->arricao);
$remainingDistance = $acars->distremain;
$precent = ($remainingDistance/$totalDistance)*100; // Counts down precentage. 100%, 99%, 98%, etc...
$precent = abs($precent-100); // Counts up precentage. 0%, 1%, 2%, etc...
echo '<br />Precentage: ' . round($precent) . '%';
}else{
echo '<br />Pilot is NOT currently in a flight!';
}
}else{
echo '<br />Pilot is NOT currently in a flight!';
}
/** ===================================^^^^ Pilot Public Profile dot tee pee elle ^^^^============================= **/
?>

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