Jump to content

[Q] Lights


stef538

Recommended Posts

Hey guys,

I tried to make lights on my vehicle, but everytime when i accelerate the lights starts to flicker :/ Do you guys have an idea why ? and is it possible to maybe attach this to the vehicle.. ? anyway this is the code i used :

                    this.myLight3.Enabled = true;                    this.myLight4.Enabled = true;                    this.myLight5.Enabled = true;                    this.myLight6.Enabled = true;                    Vector3 offset5 = new Vector3(1f, -1.50f, -0.6f);                    Vector3 offsetPosition5 = base.Player.Character.CurrentVehicle.GetOffsetPosition(offset5);                    Vector3 offset6 = new Vector3(-1f, -1.50f, -0.6f);                    Vector3 offsetPosition6 = base.Player.Character.CurrentVehicle.GetOffsetPosition(offset6);                    Vector3 offset3 = new Vector3(1f, 1.17f, -0.6f);                    Vector3 offsetPosition = base.Player.Character.CurrentVehicle.GetOffsetPosition(offset3);                    Vector3 offset4 = new Vector3(-1f, 1.17f, -0.6f);                    Vector3 vector3 = base.Player.Character.CurrentVehicle.GetOffsetPosition(offset4);                    this.myLight3.Position = offsetPosition;                    this.myLight4.Position = vector3;                    this.myLight5.Position = offsetPosition5;                    this.myLight6.Position = offsetPosition6;                    myLight3.Color = Color.LightYellow;                    myLight4.Color = Color.LightYellow;                    myLight5.Color = Color.LightYellow;                    myLight6.Color = Color.LightYellow;                    Function.Call("DRAW_LIGHT_WITH_RANGE", myLight3.Position.X, myLight3.Position.Y, myLight3.Position.Z, 255, 255, 255, 0f, 0.6);                    Function.Call("DRAW_LIGHT_WITH_RANGE", myLight4.Position.X, myLight4.Position.Y, myLight4.Position.Z, 255, 255, 255, 0f, 0.6);                    Function.Call("DRAW_LIGHT_WITH_RANGE", myLight5.Position.X, myLight5.Position.Y, myLight5.Position.Z, 255, 255, 255, 0f, 0.6);                    Function.Call("DRAW_LIGHT_WITH_RANGE", myLight6.Position.X, myLight6.Position.Y, myLight6.Position.Z, 255, 255, 255, 0f, 0.6);
Link to comment
Share on other sites

LordOfTheBongs

u dont need to call the draw native if u created a Light object from the scripthookdotnet... just enable it and then u just need to update it's position... like this...

namespace LightExample{    using System;    using System.Windows.Forms;    using GTA;     public class Main : Script    {        private Light light;         public Main()        {            light = new Light();            BindKey(Keys.T, delegate            {                light.Enabled = !light.Enabled;                 if (light.Enabled)                {                    Tick += UpdateLightTick;                }                else                {                    Tick -= UpdateLightTick;                }            });        }         private void UpdateLightTick(object sender, EventArgs e)        {            light.Position = Game.LocalPlayer.Character.GetOffsetPosition(Vector3.WorldUp * 3);        }    }}

see if the light flickers this way... it should be somewhere above the player's head at all times after u turn the light on with T key

 

btw u should actually look at the code in the scripthookdotnet so u know what ur doing... then u would know the Light class hooks a perframedrawevent to draw the light with the native ur trying to use

Edited by LordOfTheBongs
Link to comment
Share on other sites

I do have it in a PerFrameDrawing Event. Anyway, i will test your code now ;) thanks!

 

It doesn't flicker!! thank you very much!!!

Edited by stef538
Link to comment
Share on other sites

LordOfTheBongs

I do have it in a PerFrameDrawing Event. Anyway, i will test your code now ;) thanks!

 

 

i wasnt talking about where u are calling the code, im telling u it is already being done for u. Go look at the light class in the scripthookdotnet and look how it works. Then u will see your code is not necessary

Link to comment
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
  • 1 User Currently Viewing
    0 members, 0 Anonymous, 1 Guest

×
×
  • Create New...

Important Information

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