using GTA;
using GTA.Math;
using System;
using GTA.Native;
using System.IO;
using System.Windows.Forms;

public class StuntPlaneSmoke : Script
{
    bool smokeOn = false;
    Ped player;
    Vehicle veh;
    int smokeType = 1; 
    
    
    float smokesize = 0.4f;

    float R = 0.0f;
    
    float G = 0.0f;
    
    float B = 250.0f;
    
    float N = 25.0f;
    
    float H = 255.0f;
        
    float L = 0.0f;
    
    public StuntPlaneSmoke()
    {
        Tick += OnTick;
        KeyDown += OnKeyDown;
    }

    private void OnTick(object sender, EventArgs e)
    {
        float size = smokesize;  

        if (smokeOn == true)
        {
            if (Function.Call<bool>(Hash._0x8702416E512EC454, "scr_carsteal4"))
            {
                Function.Call(Hash._0x6C38AF3693A69A91, "scr_carsteal4");
                if (smokeType == 1)
                    Function.Call<int>(Hash.START_PARTICLE_FX_NON_LOOPED_ON_ENTITY, "scr_carsteal4_wheel_burnout", veh, -0.15f, -3.4f, 0.2f, 0, 0, 0, size, 0, 1, 0);
                if (smokeType == 2)
                    Function.Call<int>(Hash.START_PARTICLE_FX_NON_LOOPED_ON_ENTITY, "scr_carsteal4_wheel_burnout", veh, -0.15f, -5.0f, 0.3f, 0, 0, 0, size, 0, 1, 0); 
                if (smokeType == 3)
                    Function.Call<int>(Hash.START_PARTICLE_FX_NON_LOOPED_ON_ENTITY, "scr_carsteal4_wheel_burnout", veh, -0.15f, 1.0f, -0.3f, 0, 0, 0, size, 0, 1, 0); 
                if (smokeType == 4)
                    Function.Call<int>(Hash.START_PARTICLE_FX_NON_LOOPED_ON_ENTITY, "scr_carsteal4_wheel_burnout", veh, -4.0f, -0.5f, 0.3f, 0, 0, 0, size - 0.2, 0, 1, 0);
                
                
                if (smokeType == 5)
                    Function.Call<int>(Hash.START_PARTICLE_FX_NON_LOOPED_ON_ENTITY, "scr_carsteal4_wheel_burnout", veh, -4.0f, -0.5f, 0.3f, 0, 0, 0, size - 0.2, 0, 1, 0); 
                
                    
                    
                
                
                
                
                 
                
                Function.Call(Hash._0x26143A59EF48B262, R ,  G ,  B);  
            }
            else
            {
                Function.Call(Hash._0xB80D8756B4668AB6, "scr_carsteal4");
            }

            if (Function.Call<bool>(Hash._0x8702416E512EC454, "scr_carsteal4"))
            {
                Function.Call(Hash._0x6C38AF3693A69A91, "scr_carsteal4");
                if (smokeType == 4)
                    Function.Call<int>(Hash.START_PARTICLE_FX_NON_LOOPED_ON_ENTITY, "scr_carsteal4_wheel_burnout", veh, 4.0f, -0.5f, 0.3f, 0, 0, 0, size - 0.2, 0, 1, 0);
                Function.Call(Hash._0x26143A59EF48B262, R ,  G ,  B);  
                
                
                 
                if (smokeType == 5)
                    Function.Call<int>(Hash.START_PARTICLE_FX_NON_LOOPED_ON_ENTITY, "scr_carsteal4_wheel_burnout", veh, 4.0f, -0.5f, 0.3f, 0, 0, 0, size - 0.2, 0, 1, 0);
                Function.Call(Hash._0x26143A59EF48B262, R ,  G ,  B);  

            }
            else
            {
                Function.Call(Hash._0xB80D8756B4668AB6, "scr_carsteal4");
            }

        }
    }
    void OnKeyDown(object sender, KeyEventArgs e)
    {
        player = Game.Player.Character;

        if (player.IsInVehicle())
        {
            veh = player.CurrentVehicle;

           if (R > H)
        {
            
            R = 255.0f;
        }
            
            if (G > H)
        {
            
            G = 255.0f;
        }
            
            if (B > H)
        {
            
            B = 255.0f;
        }
            
            if (R < L)
        {
            
            R = 0.0f;
        }
            
            if (G < L)
        {
            
            G = 0.0f;
        }
            
            if (B < L)
        {
            
            B = 0.0f;
        }
                switch (e.KeyCode)
                {
                    case Keys.X: 
                        smokeOn = !smokeOn;
                        break;
                                      
                    case Keys.F9: 
                        smokeType = 1;
                        break;
                    case Keys.F10: 
                        smokeType = 2;
                        break;
                    case Keys.F11: 
                        smokeType = 3;
                        break;
                    case Keys.F12: 
                        smokeType = 4;
                        break;
                    //case Keys.F8: 
                      //  smokeType = 5;
                        //break;  
                    case Keys.U:
                        
                            R = R + N;
                        break;
                    
                    case Keys.J:
                        
                            R = R - N;
                        break;
                    
                    case Keys.I:
                        
                            G = G + N;
                        break;
                    
                    case Keys.K:
                        
                            G = G - N;
                        break;
                    
                    case Keys.O:
                       
                            B = B + N;
                        break;
                    
                    case Keys.L:
                        
                            B = B - N;
                        break;
                }
		
		
           
        }

        if (!player.IsInVehicle())
        {
            smokeOn = false;
        }

        

    }
    
}