Jump to content

You're browsing the 2004-2023 VATSIM Forums archive. All content is preserved in a read-only fashion.
For the latest forum posts, please visit https://forum.vatsim.net.

Need to find something? Use the Google search below.
PLEASE READ - Webmaster Support Forum
This forum will be retired in the near future. Please direct all queries to our dedicated GitHub support page https://github.com/vatsimnetwork/developer-info/discussions 
Here you can find documentation on our services and we are continuing to migrate pertinent information into the Wiki pages https://github.com/vatsimnetwork/developer-info/wiki

Pilot Rating ID


Syam Haque 1161585
 Share

Recommended Posts

Syam Haque 1161585
Posted
Posted

What do the pilot rating IDs that are given in the SSO correspond to? For now we get information such as 0, 1...up to 11. Is there a list for this?

VATSIM Middle East

Syam Haque - 1161585

Link to comment
Share on other sites

Anthony Lawrence
Posted
Posted
What do the pilot rating IDs that are given in the SSO correspond to? For now we get information such as 0, 1...up to 11. Is there a list for this?

 

The integer you have returned is a bitmask of the pilot ratings the user has achieved (as they're non-linear).

 

define("P_RATING_1", 1);
define("P_RATING_2", 2);
define("P_RATING_3", 4);
define("P_RATING_4", 8);
// And so on.

$userRating = 3; // User has P1 and P2 rating.
$userRating = 6; // User has P2 (2) and P3 rating (4).

if($userRating & P_RATING_1){
   print "User has P1 rating.";
}

if($userRating & P_RATING_2){
  print "User has P2 rating.";
}

// And so on.

 

From an educational perspective, this is what'd look like if we used binary values:

 

define("P_RATING_1", "0b0001"); //1
define("P_RATING_2", "0b0010"); //2
define("P_RATING_3", "0b0100"); //4
define("P_RATING_4", "0b1000"); //8
// And so on.

 

Thus, whenever there is a 1 in the respective bit (out of the 8 bits used) then that member has that rating. In your example, an 11 would represent a P4, P2 and P1.

0
Link to comment
Share on other sites

Syam Haque 1161585
Posted
Posted

Awesome, thanks Anthony!

VATSIM Middle East

Syam Haque - 1161585

Link to comment
Share on other sites

  • 4 weeks later...
Joseph Donat
Posted
Posted

Here are a few ways, that, while not ideal, will work.

 

The first, would be to have an array with all if the ratings and their [Mod - Happy Thoughts]igned values (P1 - > 1, P2->2, P3 - > 4, P4 - > 8 etc..), then to take the numerical value, and subtract from it the largest number in that array that it is greater than or equal to, and continue until it is equal to 0 (If it's already 0, then just echo P0, and if it decreases to 0, then don't). For example, if someone's rating is 11, you subtract 8, giving the P4, and reducing it to 3, subtract 2, giving P2 and reducing it to 1, and then 1, giving P1.

 

The other, is to convert the number to Base 2, put it into an array, flip it, and then for i in range (0,len(A)) , if A = 0, user does not have Pi rating, and if A = 1, user has Pi rating. For example, 11 in binary is 1011, then we flip this and put it into an array giving [1,1,0,1]. A[1]=1,so user has P1. A[2] =1, so user has a P2. A[3] = 0, so user does NOT have a P3, and A[4] = 1,so user has a P4.

 

The last one is more algebraic, below is some pseudocode (Not at all following ANY conventions)

n = pilot rating id

if n = 0

Echo "P0"

Else

For n >= 1

i = floor(log2(n)) +1

Echo "i"

n = n - 2^(i-1)

Joseph Donat
Deputy Division Director, VATSIM Middle East & North Africa  
vACC Director, VATSIM Kuwait & Iraq
##  [email protected] 
##
 http://vatsim.me/    
     

1185353147_Signature(1).png.e6818c4256541cb309a1888bad7c9d33.png

 

 

 

Link to comment
Share on other sites

 Share