Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // Add this to its own class called "VehicleLivery.cs"
- public enum VehicleLivery
- {
- One = 0,
- Two = 1,
- Three = 2,
- Four = 3,
- Random = -1
- }
- // Then add this in its own class called "VehicleExtensions.cs"
- public static class VehicleExtensions
- {
- /// <summary>
- /// Gets the current livery of the vehicle.
- /// Normal liverys returns 0-3.
- /// No liverys returns -1.
- /// Non existent vehicle returns -2.
- /// </summary>
- /// <param name="vehicle"></param>
- /// <returns>The livery of the vehicle.</returns>
- public static int GetLivery(this Vehicle vehicle)
- {
- if (Game.Exists(vehicle))
- {
- GTA.Native.Pointer vehicleLivery = typeof(int);
- GTA.Native.Function.Call("GET_CAR_LIVERY", vehicle, vehicleLivery);
- return (int)vehicleLivery.Value;
- }
- return -2;
- }
- /// <summary>
- /// Sets the vehicle's livery.
- /// </summary>
- /// <param name="vehicle"></param>
- /// <param name="livery"></param>
- public static void SetLivery(this Vehicle vehicle, VehicleLivery livery)
- {
- GTA.Native.Function.Call("SET_CAR_LIVERY", vehicle, (int)livery);
- }
- }
- // Then instead of using it like this:
- GTA.Native.Pointer vehicleLivery = typeof(int);
- GTA.Native.Function.Call("GET_CAR_LIVERY", Game.LocalPlayer.Character.CurrentVehicle, vehicleLivery);
- int livery = (int)vehicleLivery.Value;
- // You would do:
- int livery = Game.LocalPlayer.Character.CurrentVehicle.GetLivery();
- // And instead of:
- GTA.Native.Function.Call("SET_CAR_LIVERY", Game.LocalPlayer.Character.CurrentVehicle, 0); //or other values...
- // You would use:
- Game.LocalPlayer.Character.CurrentVehicle.SetLivery(VehicleLivery.Random);
Add Comment
Please, Sign In to add comment