Jump to content

c# Vehicle color from file


Recommended Posts

i try to set color to vehicle and its save on the file

but i want to spawn the vehicle its change color

here my script:

                            GTA.Forms.ColorDialog cd = new GTA.Forms.ColorDialog();                            cd.AllowScrollbars = true;                            Vehicle veh = Game.LocalPlayer.Character.CurrentVehicle;                            if (veh != null)                            {                                if (Settings.GetValueString("Vehicle") == veh.Name.ToString())                                {                                    cd.SelectedColorGTA = veh.Color;                                    if (cd.ShowDialog() == DialogResult.OK)                                    {                                        veh.Color = cd.SelectedColorGTA;                                        Settings.SetValue("Color", Convert.ToInt32(cd.SelectedColorRGB.Name,16));                                    }                                    cd.Close();                                }                            }

example:its save the color like this:

Color=fffc6d00
Link to comment
https://gtaforums.com/topic/763876-c-vehicle-color-from-file/
Share on other sites

I'm guessing what you're asking is how to get the Color from the Settings file? If so, change

Settings.SetValue("Color", Convert.ToInt32(cd.SelectedColorRGB.Name,16));

in your code to

Settings.SetValue("Color", cd.SelectedColorRGB.Name);

then put this code in when you get the Color

Color color = Color.FromName(Settings.GetValueString("Color"));
Edited by LetsPlayOrDy
Link to comment
https://gtaforums.com/topic/763876-c-vehicle-color-from-file/#findComment-1066881506
Share on other sites

 

I'm guessing what you're asking is how to get the Color from the Settings file? If so, change

Settings.SetValue("Color", Convert.ToInt32(cd.SelectedColorRGB.Name,16));

in your code to

Settings.SetValue("Color", cd.SelectedColorRGB.Name);

then put this code in when you get the Color

Color color = Color.FromName(Settings.GetValueString("Color"));

thank you very much :)

but how i write in the code

Vehicle veh = World.CreateVehicle(car, Player.Character.Position.Around(5f));            Color color = Color.FromName(Settings.GetValueString("Color"));            veh.Color = color;            veh.NoLongerNeeded();            Player.Character.WarpIntoVehicle(veh, VehicleSeat.Driver);            

its give me error

 

Error 1 Cannot implicitly convert type 'System.Drawing.Color' to 'GTA.ColorIndex' C:\Users\Yossi\documents\visual studio 2010\Projects\Seller\Seller\Seller.cs 316 25 Seller

Edited by YossiBz
Link to comment
https://gtaforums.com/topic/763876-c-vehicle-color-from-file/#findComment-1066883272
Share on other sites

but how i write in the code

Vehicle veh = World.CreateVehicle(car, Player.Character.Position.Around(5f));            Color color = Color.FromName(Settings.GetValueString("Color"));            veh.Color = color;            veh.NoLongerNeeded();            Player.Character.WarpIntoVehicle(veh, VehicleSeat.Driver);            

its give me error

 

Error 1 Cannot implicitly convert type 'System.Drawing.Color' to 'GTA.ColorIndex' C:\Users\Yossi\documents\visual studio 2010\Projects\Seller\Seller\Seller.cs 316 25 Seller

 

If you want me to reply to you, make another reply instead of editing your last post and PMing me.

 

If you want to do that, you will have to save the ColorIndex instead of the System.Drawing.Color. Like so

​Settings.SetValue("Color", (int)cd.SelectedColorGTA); //setColorIndex color = (ColorIndex)Settings.GetValueInteger("Color"); //get
Link to comment
https://gtaforums.com/topic/763876-c-vehicle-color-from-file/#findComment-1066888048
Share on other sites

 

but how i write in the code

Vehicle veh = World.CreateVehicle(car, Player.Character.Position.Around(5f));            Color color = Color.FromName(Settings.GetValueString("Color"));            veh.Color = color;            veh.NoLongerNeeded();            Player.Character.WarpIntoVehicle(veh, VehicleSeat.Driver);            

its give me error

 

Error 1 Cannot implicitly convert type 'System.Drawing.Color' to 'GTA.ColorIndex' C:\Users\Yossi\documents\visual studio 2010\Projects\Seller\Seller\Seller.cs 316 25 Seller

 

If you want me to reply to you, make another reply instead of editing your last post and PMing me.

 

If you want to do that, you will have to save the ColorIndex instead of the System.Drawing.Color. Like so

​Settings.SetValue("Color", (int)cd.SelectedColorGTA); //setColorIndex color = (ColorIndex)Settings.GetValueInteger("Color"); //get

its give me error:

Error	1	Cannot convert type 'GTA.ColorIndex' to 'int'	C:\Users\Yossi\documents\visual studio 2010\Projects\Seller\Seller\Seller.cs	232	68	Seller
Link to comment
https://gtaforums.com/topic/763876-c-vehicle-color-from-file/#findComment-1066894368
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • 0 User Currently Viewing
    0 members, 0 Anonymous, 0 Guests

×
×
  • Create New...

Important Information

By using GTAForums.com, you agree to our Terms of Use and Privacy Policy.