public override void Draw(SizeF offset) { CallCollection thisCol = new CallCollection(); float x = (Position.X) / width; float y = (Position.Y) / height; thisCol.Call(Hash.SET_TEXT_FONT, (int)Font); thisCol.Call(Hash.SET_TEXT_SCALE, 1.0f, Scale); thisCol.Call(Hash.SET_TEXT_COLOUR, Color.R, Color.G, Color.B, Color.A); if (DropShadow) { thisCol.Call(Hash.SET_TEXT_DROP_SHADOW); } if (Outline) { thisCol.Call(Hash.SET_TEXT_OUTLINE); } switch (TextAlignment) { case Alignment.Centered: thisCol.Call(Hash.SET_TEXT_CENTRE, true); break; case Alignment.Right: thisCol.Call(Hash.SET_TEXT_RIGHT_JUSTIFY, true); thisCol.Call(Hash.SET_TEXT_WRAP, 0, x); break; } if (WordWrap != new Size(0, 0)) { float xsize = (Position.X + WordWrap.Width) / width; thisCol.Call(Hash.SET_TEXT_WRAP, x, xsize); } thisCol.Call(Hash.BEGIN_TEXT_COMMAND_DISPLAY_TEXT, "jamyfafi"); //AddLongString(Caption); const int maxStringLength = 99; int count = Caption.Length; for (int i = 0; i < count; i += maxStringLength) { thisCol.Call((Hash)0x6C188BE134E074AA, Caption.Substring(i, System.Math.Min(maxStringLength, Caption.Length - i))); } thisCol.Call(Hash.END_TEXT_COMMAND_DISPLAY_TEXT, x, y); thisCol.Execute(); }
public void Matching_should_return_the_calls_matching_the_specified_expression_when_call_has_return_value() { var foo = new FakeObject(typeof(IFoo)); ((IFoo)foo.Object).Bar("foo"); ((IFoo)foo.Object).Bar("bar"); ((IFoo)foo.Object).Baz(); ((IFoo)foo.Object).Bar("foobar"); var collection = new CallCollection <IFoo>(foo); var matchingCalls = collection.Matching(x => x.Baz()); Assert.That(matchingCalls.Count(), Is.EqualTo(1)); }
private static void OnTick(object sender, EventArgs e) { if (!Main.IsConnected() || !Main.IsOnServer()) { return; } SyncPed[] myBubble; CallCollection nametagCollection = new CallCollection(); lock (StreamerThread.StreamedInPlayers) { myBubble = StreamerThread.StreamedInPlayers.Take(50).ToArray(); } for (var i = myBubble.Length - 1; i >= 0; i--) { myBubble[i]?.DrawNametag(nametagCollection); } nametagCollection.Execute(); }
private static void OnTick(object sender, EventArgs e) { if (Main.IsConnected()) { CallCollection thisCol = new CallCollection(); //thisCol.Call((Hash) 0xB96B00E976BE977F, 0.0); //_SET_WAVES_INTENSITY thisCol.Call(Hash.SET_RANDOM_TRAINS, 0); thisCol.Call(Hash.CAN_CREATE_RANDOM_COPS, false); thisCol.Call(Hash.SET_NUMBER_OF_PARKED_VEHICLES, -1); thisCol.Call(Hash.SET_PARKED_VEHICLE_DENSITY_MULTIPLIER_THIS_FRAME, 0f); if (Main.RemoveGameEntities) { thisCol.Call(Hash.SET_PED_POPULATION_BUDGET, 0); thisCol.Call(Hash.SET_VEHICLE_POPULATION_BUDGET, 0); thisCol.Call(Hash.SUPPRESS_SHOCKING_EVENTS_NEXT_FRAME); thisCol.Call(Hash.SUPPRESS_AGITATION_EVENTS_NEXT_FRAME); thisCol.Call(Hash.SET_FAR_DRAW_VEHICLES, false); thisCol.Call((Hash)0xF796359A959DF65D, false); // _DISPLAY_DISTANT_VEHICLES thisCol.Call(Hash.SET_ALL_LOW_PRIORITY_VEHICLE_GENERATORS_ACTIVE, false); thisCol.Call(Hash.SET_RANDOM_VEHICLE_DENSITY_MULTIPLIER_THIS_FRAME, 0f); thisCol.Call(Hash.SET_VEHICLE_DENSITY_MULTIPLIER_THIS_FRAME, 0f); thisCol.Call(Hash.SET_PED_DENSITY_MULTIPLIER_THIS_FRAME, 0f); thisCol.Call(Hash.SET_SCENARIO_PED_DENSITY_MULTIPLIER_THIS_FRAME, 0f, 0f); } //Function.Call(Hash.SET_CAN_ATTACK_FRIENDLY, PlayerChar, true, true); //Function.Call(Hash.SET_PED_CAN_BE_TARGETTED, PlayerChar, true); thisCol.Call((Hash)0xD2B315B6689D537D, Game.Player, false); //Some secret ingredient //Function.Call(Hash.SET_POLICE_IGNORE_PLAYER, playerChar, true); //Function.Call(Hash.SET_RANDOM_EVENT_FLAG, 0); //Function.Call(Hash.SET_MISSION_FLAG, Game.Player.Character, 0); ////Function.Call(Hash._RESET_LOCALPLAYER_STATE); //Function.Call(Hash.SET_RANDOM_EVENT_FLAG, 0); thisCol.Call(Hash.DESTROY_MOBILE_PHONE); thisCol.Call((Hash)0x015C49A93E3E086E, true); //_DISABLE_PHONE_THIS_FRAME thisCol.Call(Hash.DISPLAY_CASH, false); thisCol.Call(Hash.SET_AUTO_GIVE_PARACHUTE_WHEN_ENTER_PLANE, Game.Player, false); thisCol.Call(Hash.HIDE_HELP_TEXT_THIS_FRAME); thisCol.Call((Hash)0x5DB660B38DD98A31, Game.Player, 0f); //SET_PLAYER_HEALTH_RECHARGE_MULTIPLIER thisCol.Call(Hash.SET_PLAYER_WANTED_LEVEL, Game.Player, 0, false); thisCol.Call(Hash.SET_PLAYER_WANTED_LEVEL_NOW, Game.Player, false); thisCol.Call(Hash.SET_MAX_WANTED_LEVEL, 0); if (Function.Call <bool>(Hash.IS_STUNT_JUMP_IN_PROGRESS)) { thisCol.Call(Hash.CANCEL_STUNT_JUMP); } thisCol.Execute(); if (!Main.RemoveGameEntities) { return; } if (DateTime.Now.Subtract(LastDateTime).TotalMilliseconds >= 500) { var playerChar = Game.Player.Character; LastDateTime = DateTime.Now; foreach (var entity in World.GetAllPeds()) { if (!Main.NetEntityHandler.ContainsLocalHandle(entity.Handle) && entity != playerChar) { entity.MarkAsNoLongerNeeded(); entity.Kill(); //"Some special peds like Epsilon guys or seashark minigame will refuse to despawn if you don't kill them first." - Guad entity.Delete(); } } foreach (var entity in World.GetAllVehicles()) { var veh = Main.NetEntityHandler.NetToStreamedItem(entity.Handle, useGameHandle: true) as RemoteVehicle; if (veh == null) { entity.MarkAsNoLongerNeeded(); entity.Delete(); } } } } }
private static void OnTick(object sender, EventArgs e) { CallCollection thisCol = new CallCollection(); thisCol.Call(Hash.DISABLE_CONTROL_ACTION, 0, Control.FrontendSocialClub, true); thisCol.Call(Hash.DISABLE_CONTROL_ACTION, 0, Control.FrontendSocialClubSecondary, true); thisCol.Call(Hash.DISABLE_CONTROL_ACTION, 0, Control.EnterCheatCode, true); thisCol.Call(Hash.DISABLE_CONTROL_ACTION, 0, Control.SpecialAbility, true); thisCol.Call(Hash.DISABLE_CONTROL_ACTION, 0, Control.SpecialAbilityPC, true); thisCol.Call(Hash.DISABLE_CONTROL_ACTION, 0, Control.SpecialAbilitySecondary, true); thisCol.Call(Hash.DISABLE_CONTROL_ACTION, 0, Control.CharacterWheel, true); thisCol.Call(Hash.DISABLE_CONTROL_ACTION, 0, Control.Phone, true); thisCol.Call(Hash.DISABLE_CONTROL_ACTION, 0, Control.Duck, true); /*Game.DisableControlThisFrame(0, Control.FrontendSocialClub); * Game.DisableControlThisFrame(0, Control.FrontendSocialClubSecondary); * Game.DisableControlThisFrame(0, Control.EnterCheatCode); * * Game.DisableControlThisFrame(0, Control.SpecialAbility); * Game.DisableControlThisFrame(0, Control.SpecialAbilityPC); * Game.DisableControlThisFrame(0, Control.SpecialAbilitySecondary); * Game.DisableControlThisFrame(0, Control.CharacterWheel); * Game.DisableControlThisFrame(0, Control.Phone); * Game.DisableControlThisFrame(0, Control.Duck);*/ if (Main.IsConnected()) { thisCol.Call(Hash.DISABLE_CONTROL_ACTION, 0, Control.FrontendPause, true); thisCol.Call(Hash.DISABLE_CONTROL_ACTION, 0, Control.FrontendPauseAlternate, true); /*Game.DisableControlThisFrame(0, Control.FrontendPause); * Game.DisableControlThisFrame(0, Control.FrontendPauseAlternate);*/ } var playerChar = Game.Player.Character; if (playerChar.IsJumping) { //Game.DisableControlThisFrame(0, Control.MeleeAttack1); //Game.DisableControlThisFrame(0, Control.MeleeAttackLight); thisCol.Call(Hash.DISABLE_CONTROL_ACTION, 0, Control.MeleeAttackLight, true); } if (playerChar.IsRagdoll) { /*Game.DisableControlThisFrame(0, Control.Attack); * Game.DisableControlThisFrame(0, Control.Attack2);*/ thisCol.Call(Hash.DISABLE_CONTROL_ACTION, 0, Control.Attack, true); thisCol.Call(Hash.DISABLE_CONTROL_ACTION, 0, Control.Attack2, true); } if (Game.IsControlPressed(Control.Aim) && !playerChar.IsInVehicle() && playerChar.Weapons.Current.Hash != WeaponHash.Unarmed) { thisCol.Call(Hash.DISABLE_CONTROL_ACTION, 0, Control.Jump, true); //Game.DisableControlThisFrame(0, Control.Jump); } //CRASH WORKAROUND: DISABLE PARACHUTE RUINER2 if (playerChar.IsInVehicle()) { if (playerChar.CurrentVehicle.IsInAir && playerChar.CurrentVehicle.Model.Hash == 941494461) { thisCol.Call(Hash.DISABLE_ALL_CONTROL_ACTIONS, 0); //Game.DisableAllControlsThisFrame(0); } } if (Function.Call <int>(Hash.GET_PED_PARACHUTE_STATE, playerChar) == 2) { thisCol.Call(Hash.DISABLE_CONTROL_ACTION, 0, Control.Aim, true); thisCol.Call(Hash.DISABLE_CONTROL_ACTION, 0, Control.Attack, true); /*Game.DisableControlThisFrame(0, Control.Aim); * Game.DisableControlThisFrame(0, Control.Attack);*/ } //thisCol.Execute(); }
//bool enteringSeat = _seatEnterStart != 0 && Util.Util.TickCount - _seatEnterStart < 500; //if ((enteringSeat || Character.IsSubtaskActive(67) || IsBeingControlledByScript || Character.IsExitingLeavingCar())) //{ // if (!Main.ToggleNametagDraw) DrawNametag(); // return; //} //if (!Main.ToggleNametagDraw) DrawNametag(); internal void DrawNametag(CallCollection thisCollection) { if (!Main.UIVisible || Main._mainWarning.Visible) { return; } if ((NametagSettings & 1) != 0) { return; } // CallCollection thisCollection = new CallCollection(); // && IsSpectating || (Flag & (int)EntityFlag.PlayerSpectating) != 0 || if (!StreamedIn || ModelHash == 0 || string.IsNullOrEmpty(Name)) { return; } if (Character != null && Character.Exists()) { var playerChar = Game.Player.Character; var isInRange = Character.IsInRangeOfEx(playerChar.Position, 30f); var isFreeAimngAtEntity = Function.Call <bool>(Hash.IS_PLAYER_FREE_AIMING_AT_ENTITY, Game.Player, Character); var hasClearLosToEntity = Function.Call <bool>(Hash.HAS_ENTITY_CLEAR_LOS_TO_ENTITY, playerChar, Character, 17); if ((isInRange || isFreeAimngAtEntity) && hasClearLosToEntity) { var targetPos = Character.GetBoneCoord(Bone.IK_Head) + new Vector3(0, 0, 0.5f); targetPos += Character.Velocity / Game.FPS; thisCollection.Call(Hash.SET_DRAW_ORIGIN, targetPos.X, targetPos.Y, targetPos.Z, 0);; var nameText = Name ?? "<nameless>"; if (!string.IsNullOrEmpty(NametagText)) { nameText = NametagText; } if (TicksSinceLastUpdate > 10000) { nameText = "~r~AFK~w~~n~" + nameText; } var dist = (GameplayCamera.Position - Character.Position).Length(); var sizeOffset = Math.Max(1f - (dist / 30f), 0.3f); var defaultColor = Color.FromArgb(245, 245, 245); if ((NametagSettings & 2) != 0) { Util.Util.ToArgb(NametagSettings >> 8, out byte a, out byte r, out byte g, out byte b); defaultColor = Color.FromArgb(r, g, b); } Util.Util.DrawText(nameText, 0, 0, 0.4f * sizeOffset, defaultColor.R, defaultColor.G, defaultColor.B, 255, 0, 1, false, true, 0, thisCollection); var armorColor = Color.FromArgb(200, 220, 220, 220); var bgColor = Color.FromArgb(100, 0, 0, 0); var armorPercent = Math.Min(Math.Max(PedArmor / 100f, 0f), 1f); var armorBar = Math.Round(150 * armorPercent); armorBar = (armorBar * sizeOffset); Util.Util.DrawRectangle(-75 * sizeOffset, 36 * sizeOffset, armorBar, 20 * sizeOffset, armorColor.R, armorColor.G, armorColor.B, armorColor.A, thisCollection); Util.Util.DrawRectangle(-75 * sizeOffset + armorBar, 36 * sizeOffset, (sizeOffset * 150) - armorBar, sizeOffset * 20, bgColor.R, bgColor.G, bgColor.B, bgColor.A, thisCollection); Util.Util.DrawRectangle(-71 * sizeOffset, 40 * sizeOffset, (142 * Math.Min(Math.Max((PedHealth / 100f), 0f), 1f)) * sizeOffset, 12 * sizeOffset, 50, 250, 50, 150, thisCollection); thisCollection.Call(Hash.CLEAR_DRAW_ORIGIN); } } }
public static void DrawText(string caption, double xPos, double yPos, double scale, int r, int g, int b, int alpha, int font, int justify, bool shadow, bool outline, int wordWrap, CallCollection thisCol = null) { if (!Main.UIVisible || Main.MainMenu.Visible) { return; } const float height = 1080f; float ratio = (float)Main.screen.Width / Main.screen.Height; var width = height * ratio; float x = (float)(xPos) / width; float y = (float)(yPos) / height; bool localCollection = false; if (thisCol == null) { localCollection = true; thisCol = new CallCollection(); } thisCol.Call(Hash.SET_TEXT_FONT, font); thisCol.Call(Hash.SET_TEXT_SCALE, 1.0f, scale); thisCol.Call(Hash.SET_TEXT_COLOUR, r, g, b, alpha); if (shadow) { thisCol.Call(Hash.SET_TEXT_DROP_SHADOW); } if (outline) { thisCol.Call(Hash.SET_TEXT_OUTLINE); } switch (justify) { case 1: thisCol.Call(Hash.SET_TEXT_CENTRE, true); break; case 2: thisCol.Call(Hash.SET_TEXT_RIGHT_JUSTIFY, true); thisCol.Call(Hash.SET_TEXT_WRAP, 0, x); break; } if (wordWrap != 0) { float xsize = (float)(xPos + wordWrap) / width; thisCol.Call(Hash.SET_TEXT_WRAP, x, xsize); } thisCol.Call(Hash.BEGIN_TEXT_COMMAND_DISPLAY_TEXT, "CELL_EMAIL_BCON"); const int maxStringLength = 99; for (int i = 0; i < caption.Length; i += maxStringLength) { thisCol.Call(Hash.ADD_TEXT_COMPONENT_SUBSTRING_PLAYER_NAME, caption.Substring(i, System.Math.Min(maxStringLength, caption.Length - i))); //Function.Call((Hash)0x6C188BE134E074AA, caption.Substring(i, System.Math.Min(maxStringLength, caption.Length - i))); } thisCol.Call(Hash.END_TEXT_COMMAND_DISPLAY_TEXT, x, y); if (localCollection) { thisCol.Execute(); } }
public static void DrawRectangle(double xPos, double yPos, double wSize, double hSize, int r, int g, int b, int alpha, CallCollection thisCol = null) { if (!Main.UIVisible || Main.MainMenu.Visible) { return; } const float height = 1080f; float ratio = (float)Main.screen.Width / Main.screen.Height; var width = height * ratio; float w = (float)wSize / width; float h = (float)hSize / height; float x = (((float)xPos) / width) + w * 0.5f; float y = (((float)yPos) / height) + h * 0.5f; if (thisCol == null) { Function.Call(Hash.DRAW_RECT, x, y, w, h, r, g, b, alpha); } else { thisCol.Call(Hash.DRAW_RECT, x, y, w, h, r, g, b, alpha); } }
private void UpdateVehicleInternalInfo() { if (MainVehicle.MemoryAddress == IntPtr.Zero) { return; } CallCollection thisCollection = new CallCollection(); MainVehicle.EngineHealth = VehicleHealth; if (IsVehDead && !MainVehicle.IsDead) { MainVehicle.IsInvincible = false; MainVehicle.Explode(); } else if (!IsVehDead && MainVehicle.IsDead) { MainVehicle.IsInvincible = true; MainVehicle.Repair(); } //MainVehicle.PrimaryColor = (VehicleColor) VehiclePrimaryColor; //MainVehicle.SecondaryColor = (VehicleColor) VehicleSecondaryColor; //if (VehicleMods != null && _modSwitch % 50 == 0 && // Main.PlayerChar.IsInRangeOfEx(Position, 30f)) //{ // var id = _modSwitch / 50; // if (VehicleMods.ContainsKey(id) && VehicleMods[id] != MainVehicle.GetMod(id)) // { // Function.Call(Hash.SET_VEHICLE_MOD_KIT, MainVehicle.Handle, 0); // MainVehicle.SetMod(id, VehicleMods[id], false); // Function.Call(Hash.RELEASE_PRELOAD_MODS, id); // } //} //_modSwitch++; //if (_modSwitch >= 2500) // _modSwitch = 0; Function.Call(Hash.USE_SIREN_AS_HORN, MainVehicle, Siren); // No difference? if (IsHornPressed && !_lastHorn) { _lastHorn = true; MainVehicle.SoundHorn(99999); //Function.Call(Hash.START_VEHICLE_HORN, MainVehicle.Handle, 99999, Game.GenerateHash("HELDDOWN"), 0); } if (!IsHornPressed && _lastHorn) { _lastHorn = false; MainVehicle.SoundHorn(1); } if (IsInBurnout && !_lastBurnout) { thisCollection.Call(Hash.SET_VEHICLE_BURNOUT, MainVehicle, true); thisCollection.Call(Hash.TASK_VEHICLE_TEMP_ACTION, Character, MainVehicle, 23, 120000); // 30 - burnout } if (!IsInBurnout && _lastBurnout) { thisCollection.Call(Hash.SET_VEHICLE_BURNOUT, MainVehicle, false); thisCollection.Call(Hash.CLEAR_PED_TASKS, Character.Handle); //Character.Task.ClearAll(); } _lastBurnout = IsInBurnout; thisCollection.Call(Hash.SET_VEHICLE_BRAKE_LIGHTS, MainVehicle, Braking); if (MainVehicle.IsSirenActive && !Siren) { MainVehicle.IsSirenActive = Siren; } else if (!MainVehicle.IsSirenActive && Siren) { MainVehicle.IsSirenActive = Siren; } if (MainVehicle.ClassType == VehicleClass.Helicopters) { //thisCollection.Call(Hash.SET_HELI_BLADES_FULL_SPEED, MainVehicle.GetHashCode()); thisCollection.Call(Hash.SET_HELI_BLADES_FULL_SPEED, MainVehicle); } thisCollection.Execute(); MainVehicle.CurrentRPM = VehicleRPM; MainVehicle.SteeringAngle = Util.Util.Lerp(MainVehicle.SteeringAngle.ToRadians(), SteeringScale.ToRadians(), Math.Min(1.5f, TicksSinceLastUpdate / (float)AverageLatency)); }
CallDispatcher() { this.Calls = new CallCollection <T>(); }
public void OnTick(object sender, EventArgs e) { Main.TickCount++; try { Ped player = Game.Player.Character; var res = UIMenu.GetScreenResolutionMantainRatio(); if (Environment.TickCount - _lastCheck > 1000) { _bytesSentPerSecond = _bytesSent - _lastBytesSent; _bytesReceivedPerSecond = _bytesReceived - _lastBytesReceived; _lastBytesReceived = _bytesReceived; _lastBytesSent = _bytesSent; _lastCheck = Environment.TickCount; } if (!string.IsNullOrWhiteSpace(_threadsafeSubtitle)) { GTA.UI.Screen.ShowSubtitle(_threadsafeSubtitle, 500); } DEBUG_STEP = 1; if (!_hasInitialized) { RebuildServerBrowser(); #if INTEGRITYCHECK if (!VerifyGameIntegrity()) { _mainWarning = new Warning("alert", "Could not verify game integrity.\nPlease restart your game, or update Grand Theft Auto V."); _mainWarning.OnAccept = () => { if (Client != null && IsOnServer()) { Client.Disconnect("Quit"); } CEFManager.Dispose(); CEFManager.DisposeCef(); Script.Wait(500); //Environment.Exit(0); Process.GetProcessesByName("GTA5")[0].Kill(); Process.GetCurrentProcess().Kill(); }; } #endif _hasInitialized = true; } DEBUG_STEP = 2; if (!_hasPlayerSpawned && player != null && player.Handle != 0 && !Game.IsLoading) { GTA.UI.Screen.FadeOut(1); ResetPlayer(); MainMenu.RefreshIndex(); _hasPlayerSpawned = true; MainMenu.Visible = true; World.RenderingCamera = MainMenuCamera; var address = Util.Util.FindPattern("\x32\xc0\xf3\x0f\x11\x09", "xxxxxx"); // Weapon/radio slowdown DEBUG_STEP = 3; if (address != IntPtr.Zero) { Util.Util.WriteMemory(address, 0x90, 6); } address = Util.Util.FindPattern("\x48\x85\xC0\x0F\x84\x00\x00\x00\x00\x8B\x48\x50", "xxxxx????xxx"); // unlock objects; credit goes to the GTA-MP team DEBUG_STEP = 4; if (address != IntPtr.Zero) { Util.Util.WriteMemory(address, 0x90, 24); } //TerminateGameScripts(); GTA.UI.Screen.FadeIn(1000); } DEBUG_STEP = 5; Game.DisableControlThisFrame(0, Control.EnterCheatCode); Game.DisableControlThisFrame(0, Control.FrontendPause); Game.DisableControlThisFrame(0, Control.FrontendPauseAlternate); Game.DisableControlThisFrame(0, Control.FrontendSocialClub); Game.DisableControlThisFrame(0, Control.FrontendSocialClubSecondary); if (!player.IsJumping) { //Game.DisableControlThisFrame(0, Control.MeleeAttack1); Game.DisableControlThisFrame(0, Control.MeleeAttackLight); } Function.Call(Hash.HIDE_HELP_TEXT_THIS_FRAME); if (Game.Player.Character.IsRagdoll) { Game.DisableControlThisFrame(0, Control.Attack); Game.DisableControlThisFrame(0, Control.Attack2); } if (_mainWarning != null) { _mainWarning.Draw(); return; } if ((Game.IsControlJustPressed(0, Control.FrontendPauseAlternate) || Game.IsControlJustPressed(0, Control.FrontendPause)) && !MainMenu.Visible && !_wasTyping) { MainMenu.Visible = true; if (!IsOnServer()) { if (MainMenu.Visible) { World.RenderingCamera = MainMenuCamera; } else { World.RenderingCamera = null; } } else if (MainMenu.Visible) { RebuildPlayersList(); } MainMenu.RefreshIndex(); } else { if (!BlockControls) { MainMenu.ProcessControls(); } MainMenu.Update(); MainMenu.CanLeave = IsOnServer(); if (MainMenu.Visible && !MainMenu.TemporarilyHidden && !_mainMapItem.Focused && _hasScAvatar && File.Exists(GTANInstallDir + "\\images\\scavatar.png")) { var safe = new Point(300, 180); Util.Util.DxDrawTexture(0, GTANInstallDir + "images\\scavatar.png", res.Width - safe.X - 64, safe.Y - 80, 64, 64, 0, 255, 255, 255, 255, false); } if (!IsOnServer()) { Game.EnableControlThisFrame(0, Control.FrontendPause); } } DEBUG_STEP = 6; if (_isGoingToCar && Game.IsControlJustPressed(0, Control.PhoneCancel)) { Game.Player.Character.Task.ClearAll(); _isGoingToCar = false; } if (Client == null || Client.ConnectionStatus == NetConnectionStatus.Disconnected || Client.ConnectionStatus == NetConnectionStatus.None) { return; } // BELOW ONLY ON SERVER _versionLabel.Position = new Point((int)(res.Width / 2), 0); _versionLabel.TextAlignment = UIResText.Alignment.Centered; _versionLabel.Draw(); DEBUG_STEP = 7; if (_wasTyping) { Game.DisableControlThisFrame(0, Control.FrontendPauseAlternate); } var playerCar = Game.Player.Character.CurrentVehicle; DEBUG_STEP = 8; Watcher.Tick(); DEBUG_STEP = 9; _playerGodMode = Game.Player.IsInvincible; //invokeonLocalPlayerShoot if (player != null && player.IsShooting) { JavascriptHook.InvokeCustomEvent( api => api?.invokeonLocalPlayerShoot((int)(player.Weapons.Current?.Hash ?? 0), RaycastEverything(new Vector2(0, 0)).ToLVector())); } DEBUG_STEP = 10; int netPlayerCar = 0; RemoteVehicle cc = null; if (playerCar != null && (netPlayerCar = NetEntityHandler.EntityToNet(playerCar.Handle)) != 0) { var item = NetEntityHandler.NetToStreamedItem(netPlayerCar) as RemoteVehicle; if (item != null) { var lastHealth = item.Health; var lastDamageModel = item.DamageModel; item.Position = playerCar.Position.ToLVector(); item.Rotation = playerCar.Rotation.ToLVector(); item.Health = playerCar.EngineHealth; item.IsDead = playerCar.IsDead; item.DamageModel = playerCar.GetVehicleDamageModel(); if (lastHealth != playerCar.EngineHealth) { JavascriptHook.InvokeCustomEvent(api => api?.invokeonVehicleHealthChange((int)lastHealth)); } if (playerCar.IsEngineRunning ^ !PacketOptimization.CheckBit(item.Flag, EntityFlag.EngineOff)) { playerCar.IsEngineRunning = !PacketOptimization.CheckBit(item.Flag, EntityFlag.EngineOff); } if (lastDamageModel != null) { if (lastDamageModel.BrokenWindows != item.DamageModel.BrokenWindows) { for (int i = 0; i < 8; i++) { if (((lastDamageModel.BrokenWindows ^ item.DamageModel.BrokenWindows) & 1 << i) != 0) { var i1 = i; JavascriptHook.InvokeCustomEvent(api => api?.invokeonVehicleWindowSmash(i1)); } } } if (lastDamageModel.BrokenDoors != item.DamageModel.BrokenDoors) { for (int i = 0; i < 8; i++) { if (((lastDamageModel.BrokenDoors ^ item.DamageModel.BrokenDoors) & 1 << i) != 0) { var i1 = i; JavascriptHook.InvokeCustomEvent(api => api?.invokeonVehicleDoorBreak(i1)); } } } } } cc = item; } DEBUG_STEP = 11; if (playerCar != _lastPlayerCar) { if (_lastPlayerCar != null) { var c = NetEntityHandler.EntityToStreamedItem(_lastPlayerCar.Handle) as RemoteVehicle; if (VehicleSyncManager.IsSyncing(c)) { _lastPlayerCar.IsInvincible = c?.IsInvincible ?? false; } else { _lastPlayerCar.IsInvincible = true; } if (c != null) { Function.Call(Hash.SET_VEHICLE_ENGINE_ON, _lastPlayerCar, !PacketOptimization.CheckBit(c.Flag, EntityFlag.EngineOff), true, true); } int h = _lastPlayerCar.Handle; var lh = new LocalHandle(h); JavascriptHook.InvokeCustomEvent(api => api?.invokeonPlayerExitVehicle(lh)); _lastVehicleSiren = false; } if (playerCar != null) { if (!NetEntityHandler.ContainsLocalHandle(playerCar.Handle)) { playerCar.Delete(); playerCar = null; } else { playerCar.IsInvincible = cc?.IsInvincible ?? false; LocalHandle handle = new LocalHandle(playerCar.Handle); JavascriptHook.InvokeCustomEvent(api => api?.invokeonPlayerEnterVehicle(handle)); } } LastCarEnter = DateTime.Now; } DEBUG_STEP = 12; if (playerCar != null) { if (playerCar.GetResponsiblePed().Handle == player.Handle) { playerCar.IsInvincible = cc?.IsInvincible ?? false; } else { playerCar.IsInvincible = true; } var siren = playerCar.SirenActive; if (siren != _lastVehicleSiren) { JavascriptHook.InvokeCustomEvent(api => api?.invokeonVehicleSirenToggle()); } _lastVehicleSiren = siren; } Game.Player.Character.MaxHealth = 200; var playerObj = NetEntityHandler.EntityToStreamedItem(Game.Player.Character.Handle) as RemotePlayer; if (playerObj != null) { Game.Player.IsInvincible = playerObj.IsInvincible; } if (!string.IsNullOrWhiteSpace(CustomAnimation)) { var sp = CustomAnimation.Split(); if ( !Function.Call <bool>(Hash.IS_ENTITY_PLAYING_ANIM, Game.Player.Character, sp[0], sp[1], 3)) { Game.Player.Character.Task.ClearSecondary(); Function.Call(Hash.TASK_PLAY_ANIM, Game.Player.Character, Util.Util.LoadDict(sp[0]), sp[1], 8f, 10f, -1, AnimationFlag, -8f, 1, 1, 1); } } DEBUG_STEP = 13; _lastPlayerCar = playerCar; if (Game.IsControlJustPressed(0, Control.ThrowGrenade) && !Game.Player.Character.IsInVehicle() && IsOnServer() && !Chat.IsFocused) { var vehs = World.GetAllVehicles().OrderBy(v => v.Position.DistanceToSquared(Game.Player.Character.Position)).Take(1).ToList(); if (vehs.Any() && Game.Player.Character.IsInRangeOfEx(vehs[0].Position, 6f)) { var relPos = vehs[0].GetOffsetFromWorldCoords(Game.Player.Character.Position); VehicleSeat seat = VehicleSeat.Any; if (relPos.X < 0 && relPos.Y > 0) { seat = VehicleSeat.LeftRear; } else if (relPos.X >= 0 && relPos.Y > 0) { seat = VehicleSeat.RightFront; } else if (relPos.X < 0 && relPos.Y <= 0) { seat = VehicleSeat.LeftRear; } else if (relPos.X >= 0 && relPos.Y <= 0) { seat = VehicleSeat.RightRear; } if (vehs[0].PassengerCapacity == 1) { seat = VehicleSeat.Passenger; } if (vehs[0].PassengerCapacity > 3 && vehs[0].GetPedOnSeat(seat).Handle != 0) { if (seat == VehicleSeat.LeftRear) { for (int i = 3; i < vehs[0].PassengerCapacity; i += 2) { if (vehs[0].GetPedOnSeat((VehicleSeat)i).Handle == 0) { seat = (VehicleSeat)i; break; } } } else if (seat == VehicleSeat.RightRear) { for (int i = 4; i < vehs[0].PassengerCapacity; i += 2) { if (vehs[0].GetPedOnSeat((VehicleSeat)i).Handle == 0) { seat = (VehicleSeat)i; break; } } } } if (WeaponDataProvider.DoesVehicleSeatHaveGunPosition((VehicleHash)vehs[0].Model.Hash, 0, true) && Game.Player.Character.IsIdle && !Game.Player.IsAiming) { Game.Player.Character.SetIntoVehicle(vehs[0], seat); } else { Game.Player.Character.Task.EnterVehicle(vehs[0], seat, -1, 2f); } _isGoingToCar = true; } } DEBUG_STEP = 14; Game.DisableControlThisFrame(0, Control.SpecialAbility); Game.DisableControlThisFrame(0, Control.SpecialAbilityPC); Game.DisableControlThisFrame(0, Control.SpecialAbilitySecondary); Game.DisableControlThisFrame(0, Control.CharacterWheel); Game.DisableControlThisFrame(0, Control.Phone); Game.DisableControlThisFrame(0, Control.Duck); DEBUG_STEP = 15; VehicleSyncManager?.Pulse(); DEBUG_STEP = 16; if (StringCache != null) { StringCache?.Pulse(); } DEBUG_STEP = 17; double aver = 0; lock (_averagePacketSize) aver = _averagePacketSize.Count > 0 ? _averagePacketSize.Average() : 0; _statsItem.Text = string.Format( "~h~Bytes Sent~h~: {0}~n~~h~Bytes Received~h~: {1}~n~~h~Bytes Sent / Second~h~: {5}~n~~h~Bytes Received / Second~h~: {6}~n~~h~Average Packet Size~h~: {4}~n~~n~~h~Messages Sent~h~: {2}~n~~h~Messages Received~h~: {3}", _bytesSent, _bytesReceived, _messagesSent, _messagesReceived, aver, _bytesSentPerSecond, _bytesReceivedPerSecond); DEBUG_STEP = 18; if (Game.IsControlPressed(0, Control.Aim) && !Game.Player.Character.IsInVehicle() && Game.Player.Character.Weapons.Current.Hash != WeaponHash.Unarmed) { Game.DisableControlThisFrame(0, Control.Jump); } //CRASH WORKAROUND: DISABLE PARACHUTE RUINER2 if (Game.Player.Character.IsInVehicle()) { if (Game.Player.Character.CurrentVehicle.IsInAir && Game.Player.Character.CurrentVehicle.Model.Hash == 941494461) { Game.DisableAllControlsThisFrame(0); } } DEBUG_STEP = 19; Function.Call((Hash)0x5DB660B38DD98A31, Game.Player, 0f); DEBUG_STEP = 20; Game.MaxWantedLevel = 0; Game.Player.WantedLevel = 0; DEBUG_STEP = 21; lock (_localMarkers) { foreach (var marker in _localMarkers) { World.DrawMarker((MarkerType)marker.Value.MarkerType, marker.Value.Position.ToVector(), marker.Value.Direction.ToVector(), marker.Value.Rotation.ToVector(), marker.Value.Scale.ToVector(), Color.FromArgb(marker.Value.Alpha, marker.Value.Red, marker.Value.Green, marker.Value.Blue)); } } DEBUG_STEP = 22; var hasRespawned = (Function.Call <int>(Hash.GET_TIME_SINCE_LAST_DEATH) < 8000 && Function.Call <int>(Hash.GET_TIME_SINCE_LAST_DEATH) != -1 && Game.Player.CanControlCharacter); if (hasRespawned && !_lastDead) { _lastDead = true; var msg = Client.CreateMessage(); msg.Write((byte)PacketType.PlayerRespawned); Client.SendMessage(msg, NetDeliveryMethod.ReliableOrdered, (int)ConnectionChannel.SyncEvent); JavascriptHook.InvokeCustomEvent(api => api?.invokeonPlayerRespawn()); if (Weather != null) { Function.Call(Hash.SET_WEATHER_TYPE_NOW_PERSIST, Weather); } if (Time.HasValue) { World.CurrentDayTime = new TimeSpan(Time.Value.Hours, Time.Value.Minutes, 00); } Function.Call(Hash.PAUSE_CLOCK, true); var us = NetEntityHandler.EntityToStreamedItem(Game.Player.Character.Handle); NetEntityHandler.ReattachAllEntities(us, true); foreach ( var source in Main.NetEntityHandler.ClientMap.Values.Where( item => item is RemoteParticle && ((RemoteParticle)item).EntityAttached == us.RemoteHandle) .Cast <RemoteParticle>()) { Main.NetEntityHandler.StreamOut(source); Main.NetEntityHandler.StreamIn(source); } } var pHealth = player.Health; var pArmor = player.Armor; var pGun = player.Weapons.Current?.Hash ?? WeaponHash.Unarmed; var pModel = player.Model.Hash; if (pHealth != _lastPlayerHealth) { int test = _lastPlayerHealth; JavascriptHook.InvokeCustomEvent(api => api?.invokeonPlayerHealthChange(test)); } if (pArmor != _lastPlayerArmor) { int test = _lastPlayerArmor; JavascriptHook.InvokeCustomEvent(api => api?.invokeonPlayerArmorChange(test)); } if (pGun != _lastPlayerWeapon) { WeaponHash test = _lastPlayerWeapon; JavascriptHook.InvokeCustomEvent(api => api?.invokeonPlayerWeaponSwitch((int)test)); } if (pModel != (int)_lastPlayerModel) { PedHash test = _lastPlayerModel; JavascriptHook.InvokeCustomEvent(api => api?.invokeonPlayerModelChange((int)test)); } _lastPlayerHealth = pHealth; _lastPlayerArmor = pArmor; _lastPlayerWeapon = pGun; _lastPlayerModel = (PedHash)pModel; DEBUG_STEP = 23; _lastDead = hasRespawned; DEBUG_STEP = 24; var killed = Game.Player.Character.IsDead; DEBUG_STEP = 25; if (killed && !_lastKilled) { var msg = Client.CreateMessage(); msg.Write((byte)PacketType.PlayerKilled); var killer = Function.Call <int>(Hash.GET_PED_SOURCE_OF_DEATH, Game.Player.Character); var weapon = Function.Call <int>(Hash.GET_PED_CAUSE_OF_DEATH, Game.Player.Character); var killerEnt = NetEntityHandler.EntityToNet(killer); msg.Write(killerEnt); msg.Write(weapon); /* * var playerMod = (PedHash)Game.Player.Character.Model.Hash; * if (playerMod != PedHash.Michael && playerMod != PedHash.Franklin && playerMod != PedHash.Trevor) * { * _lastModel = Game.Player.Character.Model.Hash; * var lastMod = new Model(PedHash.Michael); * lastMod.Request(10000); * Function.Call(Hash.SET_PLAYER_MODEL, Game.Player, lastMod); * Game.Player.Character.Kill(); * } * else * { * _lastModel = 0; * } */ Client.SendMessage(msg, NetDeliveryMethod.ReliableOrdered, (int)ConnectionChannel.SyncEvent); JavascriptHook.InvokeCustomEvent(api => api?.invokeonPlayerDeath(new LocalHandle(killer), weapon)); NativeUI.BigMessageThread.MessageInstance.ShowColoredShard("WASTED", "", HudColor.HUD_COLOUR_BLACK, HudColor.HUD_COLOUR_RED, 7000); Function.Call(Hash.REQUEST_SCRIPT_AUDIO_BANK, "HUD_MINI_GAME_SOUNDSET", true); Function.Call(Hash.PLAY_SOUND_FRONTEND, -1, "CHECKPOINT_NORMAL", "HUD_MINI_GAME_SOUNDSET"); } /* * if (Function.Call<int>(Hash.GET_TIME_SINCE_LAST_DEATH) < 8000 && * Function.Call<int>(Hash.GET_TIME_SINCE_LAST_DEATH) != -1) * { * if (_lastModel != 0 && Game.Player.Character.Model.Hash != _lastModel) * { * var lastMod = new Model(_lastModel); * lastMod.Request(10000); * Function.Call(Hash.SET_PLAYER_MODEL, new InputArgument(Game.Player), lastMod.Hash); * } * } */ DEBUG_STEP = 28; if (!IsSpectating && _lastSpectating) { Game.Player.Character.Opacity = 255; Game.Player.Character.IsPositionFrozen = false; Game.Player.IsInvincible = false; Game.Player.Character.IsCollisionEnabled = true; SpectatingEntity = 0; CurrentSpectatingPlayer = null; _currentSpectatingPlayerIndex = 100000; Game.Player.Character.PositionNoOffset = _preSpectatorPos; } if (IsSpectating) { if (SpectatingEntity != 0) { Game.Player.Character.Opacity = 0; Game.Player.Character.IsPositionFrozen = true; Game.Player.IsInvincible = true; Game.Player.Character.IsCollisionEnabled = false; Control[] exceptions = new[] { Control.LookLeftRight, Control.LookUpDown, Control.LookLeft, Control.LookRight, Control.LookUp, Control.LookDown, }; Game.DisableAllControlsThisFrame(0); foreach (var c in exceptions) { Game.EnableControlThisFrame(0, c); } var ent = NetEntityHandler.NetToEntity(SpectatingEntity); if (ent != null) { if (Function.Call <bool>(Hash.IS_ENTITY_A_PED, ent) && new Ped(ent.Handle).IsInVehicle()) { Game.Player.Character.PositionNoOffset = ent.Position + new GTA.Math.Vector3(0, 0, 1.3f); } else { Game.Player.Character.PositionNoOffset = ent.Position; } } } else if (SpectatingEntity == 0 && CurrentSpectatingPlayer == null && NetEntityHandler.ClientMap.Values.Count(op => op is SyncPed && !((SyncPed)op).IsSpectating && (((SyncPed)op).Team == 0 || ((SyncPed)op).Team == Main.LocalTeam) && (((SyncPed)op).Dimension == 0 || ((SyncPed)op).Dimension == Main.LocalDimension)) > 0) { CurrentSpectatingPlayer = NetEntityHandler.ClientMap.Values.Where( op => op is SyncPed && !((SyncPed)op).IsSpectating && (((SyncPed)op).Team == 0 || ((SyncPed)op).Team == Main.LocalTeam) && (((SyncPed)op).Dimension == 0 || ((SyncPed)op).Dimension == Main.LocalDimension)) .ElementAt(_currentSpectatingPlayerIndex % NetEntityHandler.ClientMap.Values.Count( op => op is SyncPed && !((SyncPed)op).IsSpectating && (((SyncPed)op).Team == 0 || ((SyncPed)op).Team == Main.LocalTeam) && (((SyncPed)op).Dimension == 0 || ((SyncPed)op).Dimension == Main.LocalDimension))) as SyncPed; } else if (SpectatingEntity == 0 && CurrentSpectatingPlayer != null) { Game.Player.Character.Opacity = 0; Game.Player.Character.IsPositionFrozen = true; Game.Player.IsInvincible = true; Game.Player.Character.IsCollisionEnabled = false; Game.DisableAllControlsThisFrame(0); if (CurrentSpectatingPlayer.Character == null) { Game.Player.Character.PositionNoOffset = CurrentSpectatingPlayer.Position; } else if (CurrentSpectatingPlayer.IsInVehicle) { Game.Player.Character.PositionNoOffset = CurrentSpectatingPlayer.Character.Position + new GTA.Math.Vector3(0, 0, 1.3f); } else { Game.Player.Character.PositionNoOffset = CurrentSpectatingPlayer.Character.Position; } if (Game.IsControlJustPressed(0, Control.PhoneLeft)) { _currentSpectatingPlayerIndex--; CurrentSpectatingPlayer = null; } else if (Game.IsControlJustPressed(0, Control.PhoneRight)) { _currentSpectatingPlayerIndex++; CurrentSpectatingPlayer = null; } if (CurrentSpectatingPlayer != null) { var center = new Point((int)(res.Width / 2), (int)(res.Height / 2)); new UIResText("Now spectating:~n~" + CurrentSpectatingPlayer.Name, new Point(center.X, (int)(res.Height - 200)), 0.4f, Color.White, GTA.UI.Font.ChaletLondon, UIResText.Alignment.Centered) { Outline = true, }.Draw(); new Sprite("mparrow", "mp_arrowxlarge", new Point(center.X - 264, (int)(res.Height - 232)), new Size(64, 128), 180f, Color.White).Draw(); new Sprite("mparrow", "mp_arrowxlarge", new Point(center.X + 200, (int)(res.Height - 232)), new Size(64, 128)).Draw(); } } } _lastSpectating = IsSpectating; _lastKilled = killed; var collection = new CallCollection(); collection.Call(Hash.SET_RANDOM_TRAINS, 0); collection.Call(Hash.CAN_CREATE_RANDOM_COPS, false); DEBUG_STEP = 29; collection.Call(Hash.SET_VEHICLE_DENSITY_MULTIPLIER_THIS_FRAME, 0f); collection.Call(Hash.SET_VEHICLE_POPULATION_BUDGET, 0); collection.Call(Hash.SET_PED_POPULATION_BUDGET, 0); collection.Call(Hash.SUPPRESS_SHOCKING_EVENTS_NEXT_FRAME); collection.Call(Hash.SUPPRESS_AGITATION_EVENTS_NEXT_FRAME); collection.Call(Hash.SET_RANDOM_VEHICLE_DENSITY_MULTIPLIER_THIS_FRAME, 0f); collection.Call(Hash.SET_PARKED_VEHICLE_DENSITY_MULTIPLIER_THIS_FRAME, 0f); collection.Call(Hash.SET_NUMBER_OF_PARKED_VEHICLES, -1); collection.Call(Hash.SET_ALL_LOW_PRIORITY_VEHICLE_GENERATORS_ACTIVE, false); collection.Call(Hash.SET_FAR_DRAW_VEHICLES, false); collection.Call(Hash.DESTROY_MOBILE_PHONE); collection.Call((Hash)0x015C49A93E3E086E, true); collection.Call(Hash.SET_PED_DENSITY_MULTIPLIER_THIS_FRAME, 0f); collection.Call(Hash.SET_SCENARIO_PED_DENSITY_MULTIPLIER_THIS_FRAME, 0f, 0f); collection.Call(Hash.SET_CAN_ATTACK_FRIENDLY, Game.Player.Character, true, true); collection.Call(Hash.SET_PED_CAN_BE_TARGETTED, Game.Player.Character, true); collection.Call((Hash)0xF796359A959DF65D, false); // Display distant vehicles collection.Call(Hash.SET_AUTO_GIVE_PARACHUTE_WHEN_ENTER_PLANE, Game.Player, false); collection.Call((Hash)0xD2B315B6689D537D, Game.Player, false); collection.Call(Hash.DISPLAY_CASH, false); collection.Execute(); DEBUG_STEP = 30; GameScript.Pulse(); if ((Game.Player.Character.Position - _lastWaveReset).LengthSquared() > 10000f) // 100f * 100f { Function.Call((Hash)0x5E5E99285AE812DB); Function.Call((Hash)0xB96B00E976BE977F, 0f); _lastWaveReset = Game.Player.Character.Position; } Function.Call((Hash)0x2F9A292AD0A3BD89); Function.Call((Hash)0x5F3B7749C112D552); if (Function.Call <bool>(Hash.IS_STUNT_JUMP_IN_PROGRESS)) { Function.Call(Hash.CANCEL_STUNT_JUMP); } DEBUG_STEP = 31; if (Function.Call <int>(Hash.GET_PED_PARACHUTE_STATE, Game.Player.Character) == 2) { Game.DisableControlThisFrame(0, Control.Aim); Game.DisableControlThisFrame(0, Control.Attack); } DEBUG_STEP = 32; if (RemoveGameEntities && Util.Util.TickCount - _lastEntityRemoval > 500) // Save ressource { _lastEntityRemoval = Util.Util.TickCount; foreach (var entity in World.GetAllPeds()) { if (!NetEntityHandler.ContainsLocalHandle(entity.Handle) && entity != Game.Player.Character) { entity.Kill(); //"Some special peds like Epsilon guys or seashark minigame will refuse to despawn if you don't kill them first." - Guad entity.Delete(); } } foreach (var entity in World.GetAllVehicles()) { if (entity == null) { continue; } var veh = NetEntityHandler.NetToStreamedItem(entity.Handle, useGameHandle: true) as RemoteVehicle; if (veh == null) { entity.Delete(); continue; } //TO CHECK if (entity.IsVehicleEmpty() && !VehicleSyncManager.IsInterpolating(entity.Handle) && veh.TraileredBy == 0 && !VehicleSyncManager.IsSyncing(veh) && ((entity.Handle == Game.Player.LastVehicle?.Handle && DateTime.Now.Subtract(LastCarEnter).TotalMilliseconds > 3000) || entity.Handle != Game.Player.LastVehicle?.Handle)) { if (entity.Position.DistanceToSquared(veh.Position.ToVector()) > 2f) { entity.PositionNoOffset = veh.Position.ToVector(); entity.Quaternion = veh.Rotation.ToVector().ToQuaternion(); } } //veh.Position = entity.Position.ToLVector(); //veh.Rotation = entity.Rotation.ToLVector(); } } _whoseturnisitanyways = !_whoseturnisitanyways; DEBUG_STEP = 34; NetEntityHandler.UpdateAttachments(); DEBUG_STEP = 35; NetEntityHandler.DrawMarkers(); DEBUG_STEP = 36; NetEntityHandler.DrawLabels(); DEBUG_STEP = 37; NetEntityHandler.UpdateMisc(); DEBUG_STEP = 38; NetEntityHandler.UpdateInterpolations(); DEBUG_STEP = 39; WeaponInventoryManager.Update(); DEBUG_STEP = 40; /*string stats = string.Format("{0}Kb (D)/{1}Kb (U), {2}Msg (D)/{3}Msg (U)", _bytesReceived / 1000, * _bytesSent / 1000, _messagesReceived, _messagesSent); */ //GTA.UI.Screen.ShowSubtitle(stats); PedThread.OnTick("thisaintnullnigga", e); DebugInfo.Draw(); //Thread calcucationThread = new Thread(Work); //calcucationThread.IsBackground = true; //calcucationThread.Start(); lock (_threadJumping) { if (_threadJumping.Any()) { Action action = _threadJumping.Dequeue(); if (action != null) { action.Invoke(); } } } DEBUG_STEP = 41; } catch (Exception ex) // Catch any other exception. (can prevent crash) { LogManager.LogException(ex, "MAIN OnTick: STEP : " + DEBUG_STEP); } }
private void saveTSbtn_Click(object sender, EventArgs e) { if (MessageBox.Show("This will save " + objectListView1.CheckedObjects.Count.ToString() + " changes. Is that correct?", "Change Confirmation", MessageBoxButtons.YesNo, MessageBoxIcon.Warning) != System.Windows.Forms.DialogResult.Yes) { return; } Cursor = Cursors.WaitCursor; try { //Get all the checked objects IEnumerable <Call> toSave = objectListView1.CheckedObjects.Cast <Call>(); //Divide them up into Insert and Update IEnumerable <Call> toInsert = toSave.Where(c => c.ID == 0); IEnumerable <Call> toUpdate = toSave.Where(c => c.ID != 0); //Start the Loading Form. Loading.Instance.Start(toSave.Count()); //First lets get all the updates out of the way foreach (Call call in toUpdate) { call.Save(); Loading.Instance.Value++; } int batchIndex = 0; if (toInsert.Count() > 0) { //First things first, lets get the current max id from tbl_Calls int highestCallId = Convert.ToInt32(Database.ExecuteDatabaseQuery("SELECT ifnull(max(id), 0) FROM tbl_Calls").Rows[0][0]); //do a batch insert while (toInsert.Count() > 0) { //try to get the max amount of calls (MAX_PARAMETER_COUNT / 8 fields that a call has) int callFieldQueryCount = Call.TOTAL_DB_FIELD_COUNT - 1; //ignore geting id callFieldQueryCount += 1; // add 1 for the idBatchIndex //take a batch from the calls left to insert. this should hopefully not break any sqlite rules Call[] newcalls = toInsert.Take((int)Math.Floor((double)(Database.MAX_PARAMETER_COUNT / callFieldQueryCount))).ToArray(); //create a batch index for all call, so we can find it later int batchStartIndex = batchIndex; //iterate over each call foreach (Call call in newcalls) { call.idBatchIndex = batchIndex++; } //create the bulkquery statement and execute it BulkInsertData data = CallCollection.GenerateBulkInsertQuery(newcalls); Database.ExecuteDatabaseStatement(data.query, data.prms.ToArray()); //now get all the ids that have been inserted DataTable dt = Database.ExecuteDatabaseQuery("SELECT id, idBatchIndex FROM tbl_Calls WHERE id > " + highestCallId.ToString()); //now we can iterate over each call we just inserted for (int i = 0; i < newcalls.Length; i++) { //get this call from the list Call call = newcalls.SingleOrDefault(c => c.idBatchIndex == Convert.ToInt32(dt.Rows[i][1])); if (call == null) { continue; } //set the new id call.ID = Convert.ToInt32(dt.Rows[i][0]); //keep highestCallId up to date if (call.ID > highestCallId) { highestCallId = call.ID; } //insert change in change tracker ChangeTracker.InsertChange(System.Environment.UserName, DateTime.Now, "tbl_Calls", call.ID, call, ChangeTracker.ChangeType.Insert); call.ConstructOld(); } //add how many new calls have just been added! Loading.Instance.Value += newcalls.Length; } } Loading.Instance.Stop(); MessageBox.Show("Successfully Saved Selected Items", "Success", MessageBoxButtons.OK, MessageBoxIcon.Information); } catch (Exception ex) { Cura.Common.Common.LogError("There was an error saving some of the pending changes", ex); } try { RefreshPendingItems(); } catch (Exception ex) { } ServiceUserManager.Instance.RefreshControls(false, false, false); Cursor = Cursors.Default; }