LostProphet

VehicleLiverys

Oct 10th, 2013
92
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.74 KB | None | 0 0
  1. // Add this to its own class called "VehicleLivery.cs"
  2. public enum VehicleLivery
  3. {
  4.     One = 0,
  5.     Two = 1,
  6.     Three = 2,
  7.     Four = 3,
  8.     Random = -1
  9. }
  10.  
  11. // Then add this in its own class called "VehicleExtensions.cs"
  12. public static class VehicleExtensions
  13. {
  14.     /// <summary>
  15.     /// Gets the current livery of the vehicle.
  16.     /// Normal liverys returns 0-3.
  17.     /// No liverys returns -1.
  18.     /// Non existent vehicle returns -2.
  19.     /// </summary>
  20.     /// <param name="vehicle"></param>
  21.     /// <returns>The livery of the vehicle.</returns>
  22.     public static int GetLivery(this Vehicle vehicle)
  23.     {
  24.         if (Game.Exists(vehicle))
  25.         {
  26.             GTA.Native.Pointer vehicleLivery = typeof(int);
  27.             GTA.Native.Function.Call("GET_CAR_LIVERY", vehicle, vehicleLivery);
  28.  
  29.             return (int)vehicleLivery.Value;
  30.         }
  31.  
  32.         return -2;
  33.     }
  34.  
  35.     /// <summary>
  36.     /// Sets the vehicle's livery.
  37.     /// </summary>
  38.     /// <param name="vehicle"></param>
  39.     /// <param name="livery"></param>
  40.     public static void SetLivery(this Vehicle vehicle, VehicleLivery livery)
  41.     {
  42.         GTA.Native.Function.Call("SET_CAR_LIVERY", vehicle, (int)livery);
  43.     }
  44. }
  45.  
  46. // Then instead of using it like this:
  47. GTA.Native.Pointer vehicleLivery = typeof(int);
  48. GTA.Native.Function.Call("GET_CAR_LIVERY", Game.LocalPlayer.Character.CurrentVehicle, vehicleLivery);
  49. int livery = (int)vehicleLivery.Value;
  50. // You would do:
  51. int livery = Game.LocalPlayer.Character.CurrentVehicle.GetLivery();
  52.  
  53. // And instead of:
  54. GTA.Native.Function.Call("SET_CAR_LIVERY", Game.LocalPlayer.Character.CurrentVehicle, 0); //or other values...
  55. // You would use:
  56. Game.LocalPlayer.Character.CurrentVehicle.SetLivery(VehicleLivery.Random);
Add Comment
Please, Sign In to add comment