Advertisement
SkayBr

Untitled

Apr 21st, 2022
12
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.14 KB | None | 0 0
  1. <summary>
  2. * Gets the color combination for the given vehicle model ID.
  3. * </summary>
  4. *
  5. * <param name="modelID">
  6. * The ID of the vehicle model.
  7. * </param>
  8. *
  9. * <param name="color1">
  10. * The first color.
  11. * </param>
  12. *
  13. * <param name="color2">
  14. * The second color.
  15. * </param>
  16. */
  17.  
  18. GetVehicleColor(modelID, &color1, &color2)
  19. {
  20. if (modelID < 400 || modelID > 611)
  21. {
  22. return false;
  23. }
  24.  
  25. new arrayIndex = modelID - 400;
  26. new maxColorIndex = -1;
  27. Count(colorIndex, MAX_VEHICLE_COLORS)
  28. {
  29. if (vehicleColors[arrayIndex][colorIndex][0] == -1 || vehicleColors[arrayIndex][colorIndex][1] == -1)
  30. {
  31. break;
  32. }
  33. maxColorIndex = colorIndex;
  34. }
  35.  
  36. if (maxColorIndex < 0)
  37. {
  38. return false;
  39. }
  40.  
  41. new randomColorIndex = random(maxColorIndex + 1);// random returns a value between 0 and max (Excluding the max value) -> maxColorIndex + 1 will return a value between 0 and maxColorIndex
  42.  
  43. color1 = vehicleColors[arrayIndex][randomColorIndex][0];
  44. color2 = vehicleColors[arrayIndex][randomColorIndex][1];
  45.  
  46. return true;
  47. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement