public override void OnUpdaterTick()
        {
            if (Program.GameImplementation == null)
                return;
            if (Program.GameController == null)
                return;
            if (!Program.GameController.IsGameRunning)
                return;
            if (!Program.GameController.IsInGame)
                return;
            CSGOImplementation csgo = ((CSGOImplementation)Program.GameImplementation);

            IntPtr handle = Program.GameImplementation.GameController.Process.Handle;
            
            //Get addresses
            if (!updatedOffsets)
            {
                FindOffsets();
            }
            entityListAddress = dllClientAddress + GameOffsets.CL_ENTITY_LIST;
            localAddress = WinAPI.ReadInt32(handle, dllClientAddress + GameOffsets.CL_LOCAL_BASE_ENTITY);
            radarAddress = WinAPI.ReadInt32(handle, dllClientAddress + GameOffsets.CL_RADAR_BASE);
            radarAddress = WinAPI.ReadInt32(handle, radarAddress + GameOffsets.CL_RADAR_OFFSET); //B658BEC
            scoreBoardAddress = WinAPI.ReadInt32(handle, dllClientAddress + GameOffsets.CL_SCRBRD_BASE);
            enginePointer = WinAPI.ReadInt32(handle, dllEngineAddress + GameOffsets.EN_ENGINE_POINTER);
            csgo.SignOnState = (SignOnState)WinAPI.ReadInt32(handle, enginePointer + GameOffsets.EN_SIGNONSTATE);

            if (csgo.SignOnState < SignOnState.SIGNONSTATE_PRESPAWN || csgo.SignOnState > SignOnState.SIGNONSTATE_FULL)
                return;

            //General
            csgo.ScreenSize = new SharpDX.Size2(Program.GameController.WindowArea.Width, Program.GameController.WindowArea.Height);

            int targetIndex = WinAPI.ReadInt32(handle, localAddress + GameOffsets.CL_LOCAL_CROSSHAIR_TARGET);
            Matrix4x4 viewMatrix = Matrix4x4.ReadMatrix(handle, dllClientAddress + GameOffsets.CL_LOCAL_VIEWMATRIX);
            bool c4Planted = false;


            //Refresh players
            if (Environment.TickCount - newPlayers >= 1000)
            {
                newPlayers = Environment.TickCount;
                csgo.Players = null;
                csgo.Entities = null;
            }

            //Read scrbrd-data
            byte[] scrbrdData = WinAPI.ReadMemory(handle, scoreBoardAddress, 0x1C38);

            if (csgo.ScrBrdArmor == null)
                csgo.ScrBrdArmor = new int[MAX_PLAYERS];
            if (csgo.ScrBrdAssists == null)
                csgo.ScrBrdAssists = new int[MAX_PLAYERS];
            if (csgo.ScrBrdDeaths == null)
                csgo.ScrBrdDeaths = new int[MAX_PLAYERS];
            if (csgo.ScrBrdHealth == null)
                csgo.ScrBrdHealth = new int[MAX_PLAYERS];
            if (csgo.ScrBrdKills == null)
                csgo.ScrBrdKills = new int[MAX_PLAYERS];
            if (csgo.ScrBrdScore == null)
                csgo.ScrBrdScore = new int[MAX_PLAYERS];
            if (csgo.ScrBrdRanks == null)
                csgo.ScrBrdRanks = new int[MAX_PLAYERS];
            if (csgo.ScrBrdWins == null)
                csgo.ScrBrdWins = new int[MAX_PLAYERS];

            for (int i = 0; i < MAX_PLAYERS; i++)
            {
                csgo.ScrBrdArmor[i] = BitConverter.ToInt32(scrbrdData, GameOffsets.CL_SCRBRD_ARMOR + 4 * i);
                csgo.ScrBrdAssists[i] = BitConverter.ToInt32(scrbrdData, GameOffsets.CL_SCRBRD_ASSISTS + 4 * i);
                csgo.ScrBrdDeaths[i] = BitConverter.ToInt32(scrbrdData, GameOffsets.CL_SCRBRD_DEATHS + 4 * i);
                csgo.ScrBrdHealth[i] = BitConverter.ToInt32(scrbrdData, GameOffsets.CL_SCRBRD_HEALTH + 4 * i);
                csgo.ScrBrdKills[i] = BitConverter.ToInt32(scrbrdData, GameOffsets.CL_SCRBRD_KILLS + 4 * i);
                csgo.ScrBrdScore[i] = BitConverter.ToInt32(scrbrdData, GameOffsets.CL_SCRBRD_SCORE + 4 * i);
                csgo.ScrBrdRanks[i] = BitConverter.ToInt32(scrbrdData, GameOffsets.CL_SCRBRD_RANKING + 4 * i);
                csgo.ScrBrdWins[i] = BitConverter.ToInt32(scrbrdData, GameOffsets.CL_SCRBRD_WINS + 4 * i);
            }

            //Read players & entities
            if (csgo.Players == null)
                csgo.Players = new Player[MAX_PLAYERS];
            if (csgo.Entities == null)
                csgo.Entities = new Entity[MAX_ENTITIES - MAX_PLAYERS];

            int maxIndex = 2048;// = WinAPI.ReadInt32(handle, entityListAddress + 0x4);
            //maxIndex -= entityListAddress;
            //maxIndex /= GameOffsets.CL_ENTITY_SIZE;
            byte[] entityList = WinAPI.ReadMemory(handle, entityListAddress, maxIndex * GameOffsets.CL_ENTITY_SIZE);
            for (int i = 0; i < maxIndex; i++)
            {
                try
                {
                    int address = BitConverter.ToInt32(entityList, GameOffsets.CL_ENTITY_SIZE * i);
                    if (address != 0)
                        if (i < 64)
                        {
                            if (csgo.Players[i] == null)
                                csgo.Players[i] = new Player(address, radarAddress + GameOffsets.CL_RADAR_SIZE * i, i + 1);
                            else
                                csgo.Players[i].Update(address, radarAddress + GameOffsets.CL_RADAR_SIZE * i, i + 1);
                        }
                        else
                        {
                            if (csgo.Entities[i - csgo.Players.Length] == null)
                                csgo.Entities[i - csgo.Players.Length] = new Entity(address, radarAddress, i);
                            else
                                csgo.Entities[i - csgo.Players.Length].Update(address, radarAddress, i);

                            //if (!entityClasses.ContainsKey(csgo.Entities[i - csgo.Players.Length].ClassIDInt))
                            //    entityClasses.Add(csgo.Entities[i - csgo.Players.Length].ClassIDInt, csgo.Entities[i - csgo.Players.Length].Name);

                            if (!csgo.Entities[i - csgo.Players.Length].IsValid())
                                csgo.Entities[i - csgo.Players.Length] = null;
                            else
                                if (csgo.Entities[i - csgo.Players.Length].ClassID == ClassID.PlantedC4)
                                    c4Planted = true;
                        }
                } catch { }
            }

            //Get weaponID
            long weaponHandle = WinAPI.ReadInt32(handle, localAddress + GameOffsets.CL_LOCAL_ACTIVE_WEAPON);
            long weaponIDFirst = weaponHandle & 0xFFF;
            long weaponBase = WinAPI.ReadInt32(handle, entityListAddress + ((weaponIDFirst - 1) * 0x10));
            int weaponID = WinAPI.ReadInt32(handle, weaponBase + GameOffsets.CL_LOCAL_WEAPON_ID);
            float accuracyPenality = WinAPI.ReadFloat(handle, weaponBase + GameOffsets.CL_LOCAL_WEAPON_ACCURACYPENALITY);
            //int weaponShotsFired = WinAPI.ReadInt32(handle, localPlayer + GameOffsets.CL_LOCAL_WEAPON_SHOTS_FIRED);

            //Debug.WriteLine(accuracyPenality);
            ZoomLevel zoom = (ZoomLevel)WinAPI.ReadMemory(handle, weaponBase + GameOffsets.CL_LOCAL_WEAPON_ZOOM, 1)[0];
            bool isReloading = WinAPI.ReadMemory(handle, weaponBase + GameOffsets.CL_LOCAL_WEAPON_RELOAD, 1)[0] == 1;

            //Get clips
            long clip1 = WinAPI.ReadInt32(handle, dllClientAddress + GameOffsets.CL_RADAR_BASE);
            long clip2 = WinAPI.ReadInt32(handle, clip1 + GameOffsets.CL_WEAPON_OFFSET);
            int weaponClip1 = WinAPI.ReadInt32(handle, clip2 + GameOffsets.CL_WEAPON_AMMO_PRIM);
            int weaponClip2 = WinAPI.ReadInt32(handle, clip2 + GameOffsets.CL_WEAPON_AMMO_SEC);

            //Angles
            csgo.ViewAngles = ReadAngle(handle, enginePointer + GameOffsets.EN_VIEWANGLE_X);
            csgo.ViewOffset = ReadAngle(handle, localAddress + GameOffsets.CL_LOCAL_VIEWOFFSET);

            //overwrite data
            csgo.LocalPlayer = FindLocalPlayer(csgo.Players, localAddress);
            if (targetIndex > 0 && targetIndex <= 64)
                csgo.TargetPlayer = csgo.Players[targetIndex - 1];
            else
                csgo.TargetPlayer = null;
            csgo.TargetIndex = targetIndex;
            if (csgo.C4Planted != c4Planted)
            {
                csgo.C4Planted = c4Planted;
                csgo.C4PlantTime = Environment.TickCount;
            }
            csgo.AccuracyPenality = accuracyPenality;
            csgo.C4Timer = WinAPI.ReadFloat(handle, dllClientAddress + GameOffsets.CL_NETVAR_MPC4TIMER);
            csgo.ServerMap = WinAPI.ReadString(handle, dllClientAddress + GameOffsets.CL_SRV_BASE + GameOffsets.CL_SRV_MAP, 32, Encoding.ASCII);
            csgo.ServerIP = WinAPI.ReadString(handle, dllClientAddress + GameOffsets.CL_SRV_BASE + GameOffsets.CL_SRV_IP, 32, Encoding.ASCII);
            csgo.ServerName = WinAPI.ReadString(handle, dllClientAddress + GameOffsets.CL_SRV_BASE + GameOffsets.CL_SRV_Name, 32, Encoding.ASCII);
            csgo.IsReloading = isReloading;
            csgo.IsShooting = WinAPI.ReadMemory(handle, dllClientAddress + GameOffsets.CL_LOCAL_BUTTONS_ATTACK, 1)[0] == 5;
            csgo.ViewMatrix = viewMatrix;
            csgo.WeaponClip1 = weaponClip1;
            csgo.WeaponClip2 = weaponClip2;
            csgo.WeaponFireRate = WeaponHandler.Instance.GetWeaponFireRate(weaponID);
            csgo.WeaponName = WeaponHandler.Instance.GetWeaponName(weaponID);
            csgo.WeaponType = WeaponHandler.Instance.GetWeaponType(weaponID);
            csgo.FlashMaxAlpha = WinAPI.ReadFloat(handle, localAddress + GameOffsets.CL_LOCAL_FLASH_MAX_ALPHA);
            csgo.FlashMaxDuration = WinAPI.ReadFloat(handle, localAddress + GameOffsets.CL_LOCAL_FLASH_MAX_DURATION);
            //csgo.WeaponShotsFired = weaponShotsFired;
            csgo.ZoomLevel = zoom;

            csgo.FirstPersonSpectator = false;
            csgo.Spectators.Clear();
            if (csgo.LocalPlayer != null)
            {
                foreach (Player player in csgo.Players)
                {
                    if (player == null)
                        continue;
                    if (player.SpectatorTarget == csgo.LocalPlayer.Index)
                    {
                        csgo.Spectators.Add(player);
                        if (player.SpectatorView == Data.Enums.SpectatorView.Ego)
                            csgo.FirstPersonSpectator = true;
                    }
                }
            }

            if (csgo.LocalPlayer == null)
                return;

            if (csgo.GetValue<YesNo>("miscBunnyHopEnabled") == YesNo.Yes)
            {
                if (WinAPI.GetKeyDown(System.Windows.Forms.Keys.Space))
                {
                    int addrJmp = dllClientAddress + GameOffsets.CL_LOCAL_BUTTONS_JUMP;

                    //Test stuff
                    if (csgo.LocalPlayer.State == PlayerState.Jump)// && WinAPI.GetKeyDown(System.Windows.Forms.Keys.Up))
                    {
                        byte[] buffer = BitConverter.GetBytes(4);
                        WinAPI.WriteMemory(handle, addrJmp, buffer, buffer.Length);
                    }
                    else if (csgo.LocalPlayer.State == PlayerState.Stand)
                    {
                        byte[] buffer2 = BitConverter.GetBytes(5);
                        WinAPI.WriteMemory(handle, addrJmp, buffer2, buffer2.Length);
                    }
                }
            }
            if (csgo.GetValue<YesNo>("miscAutoPistolEnabled") == YesNo.Yes)
            {
                if (WinAPI.GetKeyDown(System.Windows.Forms.Keys.LButton) && csgo.WeaponType == WeaponType.Pistol)
                {
                    IntPtr bytesWritten = IntPtr.Zero;
                    int addrJmp = dllClientAddress + GameOffsets.CL_LOCAL_BUTTONS_ATTACK;
                    int val = WinAPI.ReadInt32(handle, addrJmp);
                    if (val == 0)
                    {
                        WinAPI.WriteMemory(handle, addrJmp, BitConverter.GetBytes(1), 4);
                    }
                    else
                    {
                        WinAPI.WriteMemory(handle, addrJmp, BitConverter.GetBytes(0), 4);
                    }
                }
            }

            //Glow-stuff
            int glowAddr = WinAPI.ReadInt32(handle, dllClientAddress + GameOffsets.CL_GLOWMANAGER);
            int objectCount = WinAPI.ReadInt32(handle, dllClientAddress + GameOffsets.CL_GLOWMANAGER + 4);
            GlowObjectDefinition[] glowObjects = new GlowObjectDefinition[objectCount];
            byte[] glowObjectData = WinAPI.ReadMemory(handle, glowAddr, GlowObjectDefinition.GetSize() * objectCount);

            for (int i = 0; i < glowObjects.Length; i++)
            {
                byte[] subData = new byte[GlowObjectDefinition.GetSize()];
                Array.Copy(glowObjectData, GlowObjectDefinition.GetSize() * i, subData, 0, GlowObjectDefinition.GetSize());

                glowObjects[i] = WinAPI.GetStructure<GlowObjectDefinition>(subData);
            }
            csgo.GlowObjects = glowObjects;
            tick++;
        }
 public void WriteGlowObject(GlowObjectDefinition def, int index)
 {
     byte[] data = def.GetBytes();
     byte[] writeData = new byte[GlowObjectDefinition.GetSize() - 14];
     Array.Copy(data, 4, writeData, 0, writeData.Length);
     int glowAddr = WinAPI.ReadInt32(scanner.Process.Handle, dllClientAddress + GameOffsets.CL_GLOWMANAGER);            
     WinAPI.WriteMemory(scanner.Process.Handle, glowAddr + GlowObjectDefinition.GetSize() * index + 4, writeData, writeData.Length);
 }