Quantcast
Jump to content
Search In
  • More options...
Find results that contain...
Find results in...
    1. Welcome to GTAForums!

    1. Red Dead Redemption 2

      1. Gameplay
      2. Missions
      3. Help & Support
    2. Red Dead Online

      1. Gameplay
      2. Find Lobbies & Outlaws
      3. Help & Support
    1. Crews & Posses

      1. Recruitment
    2. Events

    1. GTA Online

      1. Arena War
      2. After Hours
      3. Find Lobbies & Players
      4. Guides & Strategies
      5. Vehicles
      6. Content Creator
      7. Help & Support
    2. Grand Theft Auto Series

    3. GTA Next

    4. GTA V

      1. PC
      2. Guides & Strategies
      3. Help & Support
    5. GTA IV

      1. Episodes from Liberty City
      2. Multiplayer
      3. Guides & Strategies
      4. Help & Support
      5. GTA Mods
    6. GTA Chinatown Wars

    7. GTA Vice City Stories

    8. GTA Liberty City Stories

    9. GTA San Andreas

      1. Guides & Strategies
      2. Help & Support
      3. GTA Mods
    10. GTA Vice City

      1. Guides & Strategies
      2. Help & Support
      3. GTA Mods
    11. GTA III

      1. Guides & Strategies
      2. Help & Support
      3. GTA Mods
    12. Top Down Games

      1. GTA Advance
      2. GTA 2
      3. GTA
    13. Wiki

      1. Merchandising
    1. GTA Modding

      1. GTA V
      2. GTA IV
      3. GTA III, VC & SA
      4. Tutorials
    2. Mod Showroom

      1. Scripts & Plugins
      2. Maps
      3. Total Conversions
      4. Vehicles
      5. Textures
      6. Characters
      7. Tools
      8. Other
      9. Workshop
    3. Featured Mods

      1. DYOM
      2. OpenIV
      3. GTA: Underground
      4. GTA: Liberty City
      5. GTA: State of Liberty
    1. Red Dead Redemption

    2. Rockstar Games

    1. Off-Topic

      1. General Chat
      2. Gaming
      3. Technology
      4. Programming
      5. Movies & TV
      6. Music
      7. Sports
      8. Vehicles
    2. Expression

      1. Graphics / Visual Arts
      2. GFX Requests & Tutorials
      3. Writers' Discussion
      4. Debates & Discussion
    1. News

    2. Forum Support

    3. Site Suggestions

YossiBz

Neon c#

Recommended Posts

YossiBz

i try to do neon to vehicle this is my function:

private void DrawLight(Vehicle v,Vector3 Offset,Single Radius)        {            Vector3 pos = FZ(v.GetOffsetPosition(Offset));            Light light = new Light();            light.Color = ColorIndex.Blue;            light.Position = pos;            light.Range = Radius;            light.Intensity = 40;            light.Enabled = true;        }private Vector3 FZ(Vector3 Position)        {            float Ground = World.GetGroundZ(Position + Z1000) + ZOffset;            if (Position.Z < Ground)                Position.Z = Ground;            return Position;        }

and this is on drawing

Vehicle v = Player.Character.CurrentVehicle;                DrawLight(v, Offset1, 3.0F);                DrawLight(v, Offset2, 3.0F);                DrawLight(v, Offset3, 1.5F);                DrawLight(v, Offset4, 1.5F);

its show the light but it spreads the light on ground

Edited by YossiBz

Share this post


Link to post
Share on other sites
Jitnaught

These lights aren't attached to anything, and cannot be attached to anything. You will have to keep setting the positions of the lights in a timer

Share this post


Link to post
Share on other sites
YossiBz

These lights aren't attached to anything, and cannot be attached to anything. You will have to keep setting the positions of the lights in a timer

you can give me example?

Share this post


Link to post
Share on other sites
leftas

Really ?

        GTA.Timer timer = new GTA.Timer(); // global        Light light = new Light(); // global        public Main()        {            this.Interval = 10;            timer.Interval = 10;            timer.Tick += timer_Tick;            timer.Start();        }        void timer_Tick(object sender, EventArgs e)        {                        if(light != null && light.Enabled)            {                Vector3 pos = FZ(v.GetOffsetPosition(Offset));                light.Position = pos;            }        }

Best wishes,

Paul.

Share this post


Link to post
Share on other sites
YossiBz

Really ?

        GTA.Timer timer = new GTA.Timer(); // global        Light light = new Light(); // global        public Main()        {            this.Interval = 10;            timer.Interval = 10;            timer.Tick += timer_Tick;            timer.Start();        }        void timer_Tick(object sender, EventArgs e)        {                        if(light != null && light.Enabled)            {                Vector3 pos = FZ(v.GetOffsetPosition(Offset));                light.Position = pos;            }        }

Best wishes,

Paul.

its give me error when i add Light light = new Light();:

Error in constructor of script 'Seller.Seller':                      System.Exception: Unable to determine the owning Script for this object!                         at GTA.ScriptThread.LoadScriptNow()
Edited by YossiBz

Share this post


Link to post
Share on other sites
Jitnaught
        public Main()        {            this.Interval = 10;        }

"this.Interval = 10;" is useless because it is never used :)

 

its give me error when i add Light light = new Light();:

Error in constructor of script 'Seller.Seller':                      System.Exception: Unable to determine the owning Script for this object!                         at GTA.ScriptThread.LoadScriptNow()

Are you sure it is "Light light = new Light();" that is causing the error?

Share this post


Link to post
Share on other sites
YossiBz

 

        public Main()        {            this.Interval = 10;        }

"this.Interval = 10;" is useless because it is never used :)

 

its give me error when i add Light light = new Light();:

Error in constructor of script 'Seller.Seller':                      System.Exception: Unable to determine the owning Script for this object!                         at GTA.ScriptThread.LoadScriptNow()

Are you sure it is "Light light = new Light();" that is causing the error?

 

Yes i try to put just this and its give me the error

Share this post


Link to post
Share on other sites
Jitnaught

Yes i try to put just this and its give me the error

And when you remove that line of code the script works again?

Share this post


Link to post
Share on other sites
NTAuthority

... what if constructors are called prior to the script hook being initialized fully? Try invoking the code on the first Tick.

Share this post


Link to post
Share on other sites
YossiBz

 

Yes i try to put just this and its give me the error

And when you remove that line of code the script works again?

Yes

... what if constructors are called prior to the script hook being initialized fully? Try invoking the code on the first Tick.

i dont have a tick in my program

Edited by YossiBz

Share this post


Link to post
Share on other sites
Jitnaught

Try doing what NTAuthority said.

Share this post


Link to post
Share on other sites
leftas

LetsPlayOrDy,

I haven't used c# in a while. So I everything wrote in VS and used my old project and just accidentally copied that :)

 

YossiBz,

Can you show you ctor ?

 

Best regards,

Paul.

Share this post


Link to post
Share on other sites
YossiBz

LetsPlayOrDy,

I haven't used c# in a while. So I everything wrote in VS and used my old project and just accidentally copied that :)

 

YossiBz,

Can you show you ctor ?

 

Best regards,

Paul.

what its ctor?

Try doing what NTAuthority said.

i try

Share this post


Link to post
Share on other sites
Jitnaught

 

LetsPlayOrDy,

I haven't used c# in a while. So I everything wrote in VS and used my old project and just accidentally copied that :)

 

YossiBz,

Can you show you ctor ?

 

Best regards,

Paul.

what its ctor?

"a constructor (abbreviation: ctor) in a class is a special type of subroutine called to create an object. It prepares the new object for use, often accepting arguments that the constructor uses to set required member variables."

Example:

public class MyClass{    private int a;    private string b;     // Constructor (ctor)    public MyClass() : this(42, "string")     {    }     // Overloading a constructor    public MyClass(int a, string b)    {        this.a = a;        this.b = b;    }}

Share this post


Link to post
Share on other sites
leftas

Constructor - in this case, public Main ()

 

 

Best wishes,

Paul.

Share this post


Link to post
Share on other sites
YossiBz

 

 

LetsPlayOrDy,

I haven't used c# in a while. So I everything wrote in VS and used my old project and just accidentally copied that :)

 

YossiBz,

Can you show you ctor ?

 

Best regards,

Paul.

what its ctor?

"a constructor (abbreviation: ctor) in a class is a special type of subroutine called to create an object. It prepares the new object for use, often accepting arguments that the constructor uses to set required member variables."

Example:

public class MyClass{    private int a;    private string b;     // Constructor (ctor)    public MyClass() : this(42, "string")     {    }     // Overloading a constructor    public MyClass(int a, string b)    {        this.a = a;        this.b = b;    }}

 

Constructor - in this case, public Main ()

 

 

Best wishes,

Paul.

    {private bool Menu;        Light light = new Light();        private bool Neon;        private SelectionMenu g_SelectionM;        private GTA.Font Font;        private Size res = Game.Resolution;        private int NormalPrice = 50000;        private int BoatPrice = 75000;        private int BikePrice = 25000;        private int PlanePrice = 125000;        public Vector3 Offset1 = new Vector3(-0.5f, 0f, -1f);        public float ZOffset = 0.25f;        public Vector3 Z1000 = new Vector3(0f, 0f, 5f);        public Seller()        {            CheckIniExists();            base.BindKey(Keys.F3, new KeyPressDelegate(this.ToggleMenu));            base.BindKey(Keys.F5, new KeyPressDelegate(this.ToggleNeon));            base.BindKey(Keys.NumPad2, new KeyPressDelegate(this.GoDown));            base.BindKey(Keys.NumPad5, new KeyPressDelegate(this.DoTask));            base.BindKey(Keys.NumPad8, new KeyPressDelegate(this.GoUp));            this.Font = new GTA.Font("Pricedown", 15f, FontScaling.Pixel);            base.PerFrameDrawing += new GraphicsEventHandler(Seller_PerFrameDrawing);            base.Interval = 0x9c4;            base.Tick += new EventHandler(this.Lights_Tick);        }
Edited by YossiBz

Share this post


Link to post
Share on other sites
Jitnaught

Why did you use "0x9c4" instead of just "2500"? :lol:

Share this post


Link to post
Share on other sites
YossiBz

Why did you use "0x9c4" instead of just "2500"? :lol:

Does it matter?

Share this post


Link to post
Share on other sites
Jitnaught

No, I just thought it was a bit unusual lol :)

Share this post


Link to post
Share on other sites
YossiBz

No, I just thought it was a bit unusual lol :)

ok :lol: you know how to solve the problem?

Share this post


Link to post
Share on other sites
leftas

Do you do any blocking tasks in checkiniexists ?

 

Best wishes,

Paul.

Share this post


Link to post
Share on other sites
YossiBz

Do you do any blocking tasks in checkiniexists ?

 

Best wishes,

Paul.

yes if the ini not exist its make one with the options

Share this post


Link to post
Share on other sites
NTAuthority

Why did you use "0x9c4" instead of just "2500"? :lol:

probably from some CIL decompiler :p

Share this post


Link to post
Share on other sites
leftas

Try to move that function, somewhere else, like NTAUTHORITY said: to tick. For example.

 

Best regards,

Paul.

Edited by leftas

Share this post


Link to post
Share on other sites
YossiBz

Try to move that function, somewhere else, like NTAUTHORITY said: to tick. For example.

 

Best regards,

Paul.

i try to add the timer and dont work the same error

Share this post


Link to post
Share on other sites
leftas

Then move lights, to intiliaze in timer or ctor... but that's strange.

 

Best regards,

Paul.

Edited by leftas

Share this post


Link to post
Share on other sites
YossiBz

Then move lights, to intiliaze in timer or ctor... but that's strange.

 

Best regards,

Paul.

how this is what i have in function:

using System;using System.Collections.Generic;using System.Linq;using System.Text;using GTA;using GTA.Forms;using GTA.Native;using System.Windows.Forms;using System.Drawing;using System.IO;namespace Seller{    public class Seller : Script    {        private bool Menu;        private bool Neon;        private SelectionMenu g_SelectionM;        private GTA.Font Font;        private Size res = Game.Resolution;        private int NormalPrice = 50000;        private int BoatPrice = 75000;        private int BikePrice = 25000;        private int PlanePrice = 125000;        public Vector3 Offset1 = new Vector3(-0.5f, 0f, -1f);        public float ZOffset = 0.25f;        public Vector3 Z1000 = new Vector3(0f, 0f, 5f);        private Model[] lamps = new Model[] {             "BM_NYtrafflite_11", "BM_NYtraflite10", "BM_NYtraflite2b", "BM_NYtraflite3a", "BM_NYtraflite3b", "BM_NYtraflite3c", "BM_NYtraflite6c", "BM_NYtraflite6c2", "BM_NYtraflite6d", "BM_NYtraflite6d2", "BM_NYtraflite8", "BM_NYlamp1", "BM_NYlamp1_italy", "BM_NYlamp10", "BM_NYlamp110b", "BM_NYlamp12",             "BM_NYlamp1a", "BM_NYlamp1b", "BM_NYlamp1c", "BM_NYlamp2a", "BM_NYlamp2b", "BM_NYlamp3", "BM_NYlamp4", "BM_NYlamp5", "BM_NYlamp6", "BM_NYlamp6a", "BM_NYlamp6c", "BM_NYlamp7", "BM_NYlamp7_b", "BM_NYlamp7_c", "BM_NYlamp8a", "BM_NYlamp9",             "cj_nylamp1", "cj_nylamp2", "cj_nylamp2b"         };        public Seller()        {            CheckIniExists();            base.BindKey(Keys.F3, new KeyPressDelegate(this.ToggleMenu));            base.BindKey(Keys.F5, new KeyPressDelegate(this.ToggleNeon));            base.BindKey(Keys.NumPad2, new KeyPressDelegate(this.GoDown));            base.BindKey(Keys.NumPad5, new KeyPressDelegate(this.DoTask));            base.BindKey(Keys.NumPad8, new KeyPressDelegate(this.GoUp));            this.Font = new GTA.Font("Pricedown", 15f, FontScaling.Pixel);            base.PerFrameDrawing += new GraphicsEventHandler(Seller_PerFrameDrawing);            Interval = 2500;            Tick += new EventHandler(this.TrafficLights_Tick);        }        public void TrafficLights_Tick(object sender, EventArgs e)        {            GTA.Object[] allObjects = World.GetAllObjects();            foreach (GTA.Object obj2 in allObjects)            {                foreach (Model model in this.lamps)                {                    if (base.Exists((GTA.Object) obj2) && (obj2.Model == model))                    {                        obj2.FreezePosition = true;                    }                }            }            Light light = new Light();            GTA.Timer timer = new GTA.Timer();            Vehicle v = Player.Character.CurrentVehicle;            if (light != null && light.Enabled)            {                Vector3 pos = FixZ(v.GetOffsetPosition(Offset1));                light.Position = pos;            }        }        private void ToggleMenu()        {            this.Menu = !this.Menu;            if (!this.Menu)            {                this.g_SelectionM = SelectionMenu.CarInfo;            }        }        private void ToggleNeon()        {            this.Neon = !this.Neon;            if (Neon)            {                msg("Neon on", 4);            }        }        private void GoDown()        {            while (base.isKeyPressed(Keys.NumPad2))            {                base.Wait(100);                if (this.Menu)                {                    if (this.g_SelectionM < SelectionMenu.ColorCar)                    {                        this.g_SelectionM += 1;                    }                    else                    {                        this.g_SelectionM = SelectionMenu.CarInfo;                    }                }            }        }        private void DoTask()        {            while (isKeyPressed(Keys.NumPad5))            {                Wait(100);                string car = "";                string price = "";                if (this.Menu)                {                    switch (this.g_SelectionM)                    {                        case SelectionMenu.CarInfo:                            if (!Player.Character.isInVehicle())                            {                                msg("You must be in vehicle", 3);                            }                            else                            {                                if (Player.Character.CurrentVehicle.Model.isBoat)                                {                                    msg("Name: " + Player.Character.CurrentVehicle.Name.ToString() + " Health: " + Player.Character.CurrentVehicle.Health.ToString() + " Price: " + BoatPrice, 3);                                }                                else if (Player.Character.CurrentVehicle.Model.isBike)                                {                                    msg("Name: " + Player.Character.CurrentVehicle.Name.ToString() + " Health: " + Player.Character.CurrentVehicle.Health.ToString() + " Price: " + BikePrice, 3);                                }                                else if (Player.Character.CurrentVehicle.Model.isHelicopter)                                {                                    msg("Name: " + Player.Character.CurrentVehicle.Name.ToString() + " Health: " + Player.Character.CurrentVehicle.Health.ToString() + " Price: " + PlanePrice, 3);                                }                                else if (Player.Character.CurrentVehicle.Model.isPlane)                                {                                    msg("Name: " + Player.Character.CurrentVehicle.Name.ToString() + " Health: " + Player.Character.CurrentVehicle.Health.ToString() + " Price: " + PlanePrice, 3);                                }                                else if (Player.Character.CurrentVehicle.Model.isCar)                                {                                    msg("Name: " + Player.Character.CurrentVehicle.Name.ToString() + " Health: " + Player.Character.CurrentVehicle.Health.ToString() + " Price: " + NormalPrice, 3);                                }                            }                            return;                        case SelectionMenu.BuyCar:                            if (Settings.GetValueString("Vehicle") != "")                            {                                msg("You have a vehicle", 3);                            }                            else                            {                                if (!Player.Character.isInVehicle())                                {                                    msg("You must be in vehicle", 3);                                }                                else                                {                                    if (Player.Character.CurrentVehicle.Model.isBoat)                                    {                                        if (Player.Money >= BoatPrice)                                        {                                            msg("You buy a " + Player.Character.CurrentVehicle.Name.ToString(), 3);                                            Player.Money -= BoatPrice;                                            car = Player.Character.CurrentVehicle.Name.ToString();                                            price = "37500";                                        }                                        else                                        {                                            msg("You dont have money to buy " + Player.Character.CurrentVehicle.Name.ToString(), 3);                                        }                                    }                                    else if (Player.Character.CurrentVehicle.Model.isBike)                                    {                                        if (Player.Money >= BikePrice)                                        {                                            msg("You buy a " + Player.Character.CurrentVehicle.Name.ToString(), 3);                                            Player.Money -= BikePrice;                                            car = Player.Character.CurrentVehicle.Name.ToString();                                            price = "12500";                                        }                                        else                                        {                                            msg("You dont have money to buy " + Player.Character.CurrentVehicle.Name.ToString(), 3);                                        }                                    }                                    else if (Player.Character.CurrentVehicle.Model.isHelicopter)                                    {                                        if (Player.Money >= PlanePrice)                                        {                                            msg("You buy a " + Player.Character.CurrentVehicle.Name.ToString(), 3);                                            Player.Money -= PlanePrice;                                            car = Player.Character.CurrentVehicle.Name.ToString();                                            price = "62500";                                        }                                        else                                        {                                            msg("You dont have money to buy " + Player.Character.CurrentVehicle.Name.ToString(), 3);                                        }                                    }                                    else if (Player.Character.CurrentVehicle.Model.isPlane)                                    {                                        if (Player.Money >= PlanePrice)                                        {                                            msg("You buy a " + Player.Character.CurrentVehicle.Name.ToString(), 3);                                            Player.Money -= PlanePrice;                                            car = Player.Character.CurrentVehicle.Name.ToString();                                            price = "62500";                                        }                                        else                                        {                                            msg("You dont have money to buy " + Player.Character.CurrentVehicle.Name.ToString(), 3);                                        }                                    }                                    else if (Player.Character.CurrentVehicle.Model.isCar)                                    {                                        if (Player.Money >= NormalPrice)                                        {                                            msg("You buy a " + Player.Character.CurrentVehicle.Name.ToString(), 3);                                            Player.Money -= NormalPrice;                                            car = Player.Character.CurrentVehicle.Name.ToString();                                            price = "25000";                                        }                                        else                                        {                                            msg("You dont have money to buy " + Player.Character.CurrentVehicle.Name.ToString(), 3);                                        }                                    }                                    Settings.SetValue("Vehicle", car);                                    Settings.SetValue("Price", price);                                    Settings.Save();                                }                            }                            return;                        case SelectionMenu.SellCar:                            if (Settings.GetValueString("Vehicle") == "")                            {                                msg("You dont have a vehicle", 3);                            }                            else                            {                                msg("You sell " + Settings.GetValueString("Vehicle"), 3);                                Player.Money += Settings.GetValueInteger("Price",25000);                                Settings.SetValue("Vehicle", "");                                Settings.SetValue("Price", "");                            }                            return;                        case SelectionMenu.CallCar:                            if (Settings.GetValueString("Vehicle") == "")                            {                                msg("You dont have a vehicle", 3);                            }                            else                            {                                string cars = Settings.GetValueString("Vehicle");                                if (!Player.Character.isInVehicle())                                {                                    Spawn(cars);                                }                                else                                {                                    msg("your in vehicle", 3);                                }                            }                            return;                        case SelectionMenu.ColorCar:                            GTA.Forms.ColorDialog cd = new GTA.Forms.ColorDialog();                            cd.AllowScrollbars = false;                            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;                                        Player.Money -= 1000;                                        Settings.SetValue("Color", cd.SelectedColorGTA.Index);                                        Settings.Save();                                    }                                    cd.Close();                                }                            }                            return;                    }                }            }        }        private void GoUp()        {            while (base.isKeyPressed(Keys.NumPad8))            {                base.Wait(100);                if (this.Menu)                {                    if (this.g_SelectionM > SelectionMenu.CarInfo)                    {                        this.g_SelectionM -= 1;                    }                    else                    {                        this.g_SelectionM = SelectionMenu.ColorCar;                    }                }            }        }        private void Seller_PerFrameDrawing(object sender, GraphicsEventArgs e)        {            float x = (float)(this.res.Width * 0.017);            float num2 = (float)(this.res.Width * 0.15);            float num3 = (float)(this.res.Width * 0.25);            float num4 = (float)(this.res.Width * 0.17);            float num5 = (float)(this.res.Width * 0.3);            if (Neon)            {                if (!Player.Character.isSittingInVehicle()) return;                Vehicle v = Player.Character.CurrentVehicle;                if (v == null) return;                DrawLight(v, 1.5F);            }            if (this.Menu)            {                e.Graphics.DrawText("Car System", x, 12f, Color.White, this.Font);                e.Graphics.DrawText("__________", x, 12f, Color.White, this.Font);                e.Graphics.DrawText("Car Info", x, 32f, Color.White, this.Font);                e.Graphics.DrawText("Buy Car", x, 52f, Color.White, this.Font);                e.Graphics.DrawText("Sell Car", x, 72f, Color.White, this.Font);                e.Graphics.DrawText("Call Car", x, 92f, Color.White, this.Font);                e.Graphics.DrawText("Car Color", x, 112f, Color.White, this.Font);                switch (this.g_SelectionM)                {                    case SelectionMenu.CarInfo:                        e.Graphics.DrawText("Car Info", x, 32f, Color.YellowGreen, this.Font);                        break;                    case SelectionMenu.BuyCar:                        e.Graphics.DrawText("Buy Car", x, 52f, Color.YellowGreen, this.Font);                        break;                    case SelectionMenu.SellCar:                        e.Graphics.DrawText("Sell Car", x, 72f, Color.YellowGreen, this.Font);                        break;                    case SelectionMenu.CallCar:                        e.Graphics.DrawText("Call Car", x, 92f, Color.YellowGreen, this.Font);                        break;                    case SelectionMenu.ColorCar:                        e.Graphics.DrawText("Car Color", x, 112f, Color.YellowGreen, this.Font);                        break;                }            }        }        public void msg(string message, int seconds)        {            Function.Call("PRINT_STRING_WITH_LITERAL_STRING_NOW", new Parameter[] { "STRING", message, seconds * 0x3e8, 1 });        }        public void CheckIniExists()        {            if (!File.Exists("scripts/Seller.ini"))            {                File.Create("scripts/Seller.ini");                Settings.SetValue("Vehicle", "");                Settings.SetValue("Price", "");                Settings.SetValue("Color", "");                Settings.Save();                Wait(100);            }        }        private void DrawLight(Vehicle v,Single Radius)        {            Light light = new Light();            Vector3 pos = FixZ(v.GetOffsetPosition(Offset1));            light.Color = Color.Cyan;            light.Position = pos;            light.Range = Radius;            light.Intensity = 10;            light.Enabled = true;            if (!Neon)            {                light.Disable();            }        }        private Vector3 FixZ(Vector3 Position)        {            float G = World.GetGroundZ(Position + Z1000) + ZOffset;            if (Position.Z < G)                Position.Z = G;            return Position;        }        public void Spawn(string car)        {            Vehicle veh = World.CreateVehicle(car, Player.Character.Position.Around(5f));            ColorIndex color = (ColorIndex)Settings.GetValueInteger("Color",1);            veh.Color = color;            veh.NoLongerNeeded();            Player.Character.WarpIntoVehicle(veh, VehicleSeat.Driver);            msg("Your car " + car + " is called", 3);        }        private enum SelectionMenu        {            CarInfo,            BuyCar,            SellCar,            CallCar,            ColorCar        }    }}

Share this post


Link to post
Share on other sites
leftas

Sorry, went to sleep after my last post.

So you doing memory leak in tick, thanks to GC, your light and timer variables are deleted.

Do a Initialize variable, in which tick would look if everything initialize if not then initialize

bool firstRun;Light light;GTA.Timer timer = new GTA.Timer();public Seller(){   timer.Interval = 10;   timer.Tick += timer_Tick;   timer.Start();}public void timer_Tick(object sender, EventArgs e){    if(firstRun)    {       CheckIniExists();       light = new Light();                 }    Vehicle v = Player.Character.CurrentVehicle;    if (light != null && light.Enabled)    {        light.Position = FixZ(v.GetOffsetPosition(Offset1));    }}private void DrawLight(Vehicle v,Single Radius){          light.Color = Color.Cyan;     light.Position = FixZ(v.GetOffsetPosition(Offset1));;     light.Range = Radius;     light.Intensity = 10;     light.Enabled = true;     if (!Neon)     {        light.Disable();     }}

Okay, why in your DrawLight, you initialize same variable ?

 

Tip: Try to use less global variables. And sometimes when you don't need anything more(if you do all your checks in function like FixZ, then you don't need another variable :)

 

 

Best regards,

Paul.

Share this post


Link to post
Share on other sites
YossiBz

nvm i check this now and i edit my post

still error

the timer give me error

Edited by YossiBz

Share this post


Link to post
Share on other sites
leftas

You can intiliaze it in ctor :)

 

Best wishes,

Paul.

Share this post


Link to post
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

×

Important Information

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