Akira_Yiin

plateTest|PAWN

May 30th, 2015
334
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.83 KB | None | 0 0
  1. PlateToInt(Chars[], Numbers) {
  2. new parts;
  3. for (new x = 0; x < 3; x++) Chars[x] -= 'A';
  4.  
  5. parts = (Chars[0] * 26 * 26) + (Chars[1] * 26) + Chars[2];
  6.  
  7. Numbers <<= 15;
  8. parts |= Numbers;
  9.  
  10. return parts;
  11. }
  12.  
  13. IntToPlate(In, chars[], size = sizeof chars) {
  14. if(size < 7) return;
  15.  
  16. new parts[2];
  17.  
  18. parts[1] = In >> 15;
  19. parts[0] = In & 32767;
  20.  
  21. chars[2] = parts[0] % 26 + 'A'; parts[0] /= 26;
  22. chars[1] = parts[0] % 26 + 'A'; parts[0] /= 26;
  23. chars[0] = parts[0] % 26 + 'A';
  24.  
  25. new numbers[4];
  26.  
  27. numbers[0] = parts[1] / 100 + '0';
  28. numbers[1] = (parts[1] % 100) / 10 + '0';
  29. numbers[2] = parts[1] % 10 + '0';
  30.  
  31. strcat(chars, numbers, size);
  32. }
  33.  
  34. main() {
  35. new chr[3] = { 'Z', 'Z', 'Z' };
  36. new num = 999;
  37.  
  38. new lel = PlateToInt(chr, num);
  39.  
  40. printf("%i", lel);
  41.  
  42. new lol[7];
  43. IntToPlate(lel, lol);
  44.  
  45. print(lol);
  46. }
Advertisement
Add Comment
Please, Sign In to add comment