From 4f98c460f11d4d14914d4662b4a37319a68b240f Mon Sep 17 00:00:00 2001 From: Linewalker Date: Wed, 6 Jul 2022 04:50:04 +0200 Subject: [PATCH] New functions Some new code for new functions --- GTAVCSMM.csproj | 3 +- Helpers/EnumData.cs | 527 ++++++++++++++++++++++++++++++++++++++++++ Helpers/ProcessMgr.cs | 72 ++++++ Helpers/Speeder.cs | 134 ----------- Memory/Mem.cs | 4 + Program.cs | 248 +++++++++++++------- 6 files changed, 765 insertions(+), 223 deletions(-) create mode 100644 Helpers/EnumData.cs create mode 100644 Helpers/ProcessMgr.cs delete mode 100644 Helpers/Speeder.cs diff --git a/GTAVCSMM.csproj b/GTAVCSMM.csproj index cdc75f9..9198685 100644 --- a/GTAVCSMM.csproj +++ b/GTAVCSMM.csproj @@ -60,11 +60,12 @@ + + - diff --git a/Helpers/EnumData.cs b/Helpers/EnumData.cs new file mode 100644 index 0000000..397242f --- /dev/null +++ b/Helpers/EnumData.cs @@ -0,0 +1,527 @@ +namespace GTAVCSMM.Helpers +{ + public class EnumData + { + public enum PedTypes : int + { + PLAYER_0, + PLAYER_1, + NETWORK_PLAYER, + PLAYER_2, + CIVMALE, + CIVFEMALE, + COP, + GANG_ALBANIAN, + GANG_BIKER_1, + GANG_BIKER_2, + GANG_ITALIAN, + GANG_RUSSIAN, + GANG_RUSSIAN_2, + GANG_IRISH, + GANG_JAMAICAN, + GANG_AFRICAN_AMERICAN, + GANG_KOREAN, + GANG_CHINESE_JAPANESE, + GANG_PUERTO_RICAN, + DEALER, + MEDIC, + FIREMAN, + CRIMINAL, + BUM, + PROSTITUTE, + SPECIAL, + MISSION, + SWAT, + ANIMAL, + ARMY + }; + + public enum FrameFlags + { + ExplosiveAmmo = 1 << 11, + FireAmmo = 1 << 12, + ExplosiveMelee = 1 << 13, + SuperJump = 1 << 14, + } + + public enum BlipIcons + { + Null, + Circle, + Empty, + Cop, + CopSearchZone, + Square, + PlayerArrow, + North, + Waypoint, + BigCircle, + BigCircleOutline, + ArrowUpOutlined, + ArrowDownOutlined, + ArrowUp, + ArrowDown, + PoliceHelicopter, + Jet, + Number1, + Number2, + Number3, + Number4, + Number5, + Number6, + Number7, + Number8, + Number9, + Number10, + GTAOCrew, + GTAOFriend, + CableCar = 36, + RaceFinish = 38, + Safehouse = 40, + Cop2, + CopCar, + Helicopter, + ChatBubble = 47, + Garage = 50, + Drugs, + ConvenienceStore, + PoliceCar = 56, + Circle2, + CircleWithStar, + ConvenienceStore2, + ShieldWithStar, + Asterisk, + Helicopter2 = 64, + StrangersAndFreaks = 66, + ArmoredTruck, + TowTruck, + Barber = 71, + LosSantosCustoms, + Clothes, + TattooParlor = 75, + Simeon, + Lester, + Michael, + Trevor, + Heist1, + Rampage = 84, + VinewoodTours, + Franklin, + Franklin2 = 88, + Chinese, + FlightSchool, + Bar = 93, + ParachuteJump, + Heist2 = 96, + CarWash = 100, + ComedyClub = 102, + Darts, + FIB = 106, + Heist3, + DollarSign, + Golf, + AmmuNation, + Exile = 112, + ShootingRange = 119, + Solomon, + StripClub, + Tennis, + Triathlon = 126, + OffRoadRaceFinish, + Key = 134, + MovieTheater, + Music, + Marijuana = 140, + Hunting, + ArmsTraffickingGround = 147, + Nigel = 149, + AssaultRifle, + Bat, + Grenade, + Health, + Knife, + Molotov, + Pistol, + RPG, + Shotgun, + SMG, + Sniper, + SonicWave, + PointOfInterest, + GTAOPassive, + GTAOUsingMenu, + Link = 171, + Minigun = 173, + GrenadeLauncher, + Armor, + Castle, + CameraIcon = 184, + Handcuffs = 188, + Yoga = 197, + Cab, + Number11, + Number12, + Number13, + Number14, + Number15, + Number16, + Shrink, + Epsilon, + PersonalVehicleCar = 225, + PersonalVehicleBike, + Custody = 237, + ArmsTraffickingAir = 251, + Fairground = 266, + PropertyManagement, + Altruist = 269, + Enemy, + Chop = 273, + Dead, + Hooker = 279, + Friend, + BountyHit = 303, + GTAOMission, + GTAOSurvival, + CrateDrop, + PlaneDrop, + Sub, + Race, + Deathmatch, + ArmWrestling, + AmmuNationShootingRange = 313, + RaceAir, + RaceCar, + RaceSea, + GarbageTruck = 318, + Motorcycle = 348, + SafehouseForSale = 350, + Package, + MartinMadrazo, + EnemyHelicopter, + Boost, + Devin, + Marina, + Garage2, + GolfFlag, + Hangar, + Helipad, + JerryCan, + Masks, + HeistSetup, + Incapacitated, + PickupSpawn, + BoilerSuit, + Completed, + Rockets, + GarageForSale, + HelipadForSale, + MarinaForSale, + HangarForSale, + Business = 374, + BusinessForSale, + RaceBike, + Parachute, + TeamDeathmatch, + RaceFoot, + VehicleDeathmatch, + Barry, + Dom, + MaryAnn, + Cletus, + Josh, + Minute, + Omega, + Tonya, + Paparazzo, + Crosshair, + Creator = 398, + CreatorDirection, + Abigail, + Blimp, + Repair, + Testosterone, + Dinghy, + Fanatic, + GangAttack, + Information, + CaptureBriefcase, + LastTeamStanding, + Boat, + CaptureHouse, + JerryCan2 = 415, + RPLogo, + GTAOPlayerSafehouse, + GTAOPlayerSafehouseBounty, + CaptureAmericanFlag, + CaptureFlag, + Tank, + PlayerHelicopter, + PlayerPlane, + PlayerJet, + PlayerArrowNoColor, + PlayerLAPV, + PlayerBoat, + HeistRoom, + Stopwatch = 430, + DollarSignCircled, + Crosshair2, + Crosshair3, + DollarSignSquared, + RaceFlagWithArrow, + Fire, + DoubleDeathmatchSkulls, + CastleIcon, + Crown, + SupplyBag, + QuadirectionalArrows, + Fox, + Triangle, + ThreeBars, + LamarDavis, + Mechanic, + LamarDavisOne, + LamarDavisTwo, + LamarDavisThree, + LamarDavisFour, + LamarDavisFive, + LamarDavisSix, + LamarDavisSeven, + LamarDavisEight, + Yacht, + SmallQuestionMark, + GymBag, + CrosshairWithPersonInMiddle, + PlayerSpeaking, + Taxi, + ShieldWithX, + YachtMinimap, + Fox2, + Hourglass, + SmallQuestionMark2, + Stopwatch2, + Restart, + SunWithEye, + Marijuana2, + Shotgun2, + Jetski, + EyeWithLineThroughIt, + Garage3, + GarageForSale2, + Building, + BuildingForSale, + Truck, + Crate, + Trailer, + Person, + Cargobob, + BigOutlineSquare, + Speedometer, + Ghost, + RemoteControl, + Bomb, + Shield, + StuntRace, + Heart, + StuntRaceMoney, + TeamDeathMatch2, + HouseWithGarage, + QuadirectionalArrowsWithMotorcycle, + CircleWithMotorcycle, + MotorcycleRace, + Weed, + Cocaine, + ForgedDocuments, + Meth, + CounterfeitMoney, + DrugPickup, + BigOne, + BigTwo, + BigThree, + BigFour, + BigFive, + BigSix, + BigSeven, + BigEight, + BigNine, + BigTen, + ATVQuad, + Bus, + BagMaybe, + UpArrowOnSquare, + FourPlayers, + EightPlayers, + TenPlayers, + TwelvePlayers, + SixteenPlayers, + Laptop, + Supercycle, + Supercar, + GarageWithCar, + PaperDocument, + ShieldWithBlackStar, + CraneClaw, + PhantomWedge, + BoxvilleArmored, + Ruiner2000, + RampBuggy, + Wastelander, + RocketVoltic, + TechnicalAqua, + LetterA, + LetterB, + LetterC, + LetterD, + LetterE, + LetterF, + LetterG, + LetterH, + SkullWithTriangleTop, + Wrench, + SteeringWheel, + Trolphy, + Rocket, + Missile, + Bullets, + Parachute2, + Number5WithCircle, + Number10WithCircle, + Number15WithCircle, + Number20WithCircle, + Number30WithCircle, + Bullets2, + Bunker, + InsurgentPickup, + Opressor, + TechnicalCustom, + DuneFAV, + HalfTrack, + AntiAircraftTrailer, + Satelite, + BunkerWithPeople, + ScrewdriverAndHammer, + UpgradedWeaponWorkbench, + CrateWithStraps, + AircraftHanger, + Icosikaitetragon, + RaceflagWithQuestionmark, + AlphaZ1, + Bombushka, + Havok, + HowardNX25, + Hunter, + Ultralight, + Mogul, + Molotok, + Nokota, + Pyro, + Rogue, + Starling, + Starbreeze, + Tula, + GymBagWithLetterH, + LockedCrate, + SateliteIcon, + Avenger, + IAAFacility, + DoomsdayHeist, + SAMTurret, + HackingPuzzleRed, + HackingPuzzleDiode, + Stromburg, + Deluxo, + ThrusterJetpack, + TM02KhanjaliTank, + RCV, + Volatol, + Barrage, + Akula, + Chernobog, + SpeakerMaybe, + YellowishBrownMoneySign, + ComputerTerminal, + HackingPuzzleMirror, + HackingPuzzleReflector, + HackingPuzzleRotator, + RaceFlagWithCrosshair, + RaceFlagWithSteeringWheel, + SeaSparrow, + Caracara, + Nightclub, + CrateB, + VanB, + Diamond, + BullionStacks, + CalculatorMaybe, + CarWithLightningBolt, + HeartIcon, + StarWithAdd, + StarWithSubtract, + BombWithAdd, + BombWithSubtract, + CrosshairDJ, + Drone, + Cashregister, + SpeakerMaybeBigger, + Skull, + FestivalBus, + Terrorbyte, + Menacer, + Scramjet, + PounderCustom, + MuleCustom, + SpeedoCustom, + BlimpIcon, + OpressorMKII, + B11StrikeForce, + GearWithCar, + GearWithMoney, + GearWithWrench, + RaceFlagWithGear, + CrosshairOnCar, + RCBandito, + RCRemote, + FlameSign, + ArrowSign, + GearSign, + RepeatSign, + DownArrowSign, + ExplosionSign, + WheelExplosionSign, + ElevatorSign, + ElevatorSign2, + EjectorPlatformSign, + Bruiser, + Brutus, + Cerberus, + Deathbike, + Dominator, + Impaler, + Imperator, + Issi, + Sasquatch, + Scarab, + Slamvan, + ZR380 + } + + public enum BlipColors + { + None, + Red, + Green, + Blue, + PlayerColor, + YellowMission, + FriendlyVehicle = 0x26, + MichaelColor = 0x2A, + FranklinColor, + TravorColor, + BlipColorEnemy = 0x31, + MissionVehicle = 0x36, + RedMission = 0x3B, + YellowMission2 = 0x3C, + Mission = 0x42, + WaypointColor = 0x54 + } + } +} diff --git a/Helpers/ProcessMgr.cs b/Helpers/ProcessMgr.cs new file mode 100644 index 0000000..f8c0044 --- /dev/null +++ b/Helpers/ProcessMgr.cs @@ -0,0 +1,72 @@ +using System; +using System.Runtime.InteropServices; + +namespace GTAVCSMM.Helpers +{ + public static class ProcessMgr + { + [Flags] + public enum ProcessAccess : uint + { + Terminate = 0x1, + CreateThread = 0x2, + SetSessionId = 0x4, + VmOperation = 0x8, + VmRead = 0x10, + VmWrite = 0x20, + DupHandle = 0x40, + CreateProcess = 0x80, + SetQuota = 0x100, + SetInformation = 0x200, + QueryInformation = 0x400, + SetPort = 0x800, + SuspendResume = 0x800, + QueryLimitedInformation = 0x1000, + Synchronize = 0x100000 + } + + [DllImport("ntdll.dll")] + private static extern uint NtResumeProcess([In] IntPtr processHandle); + + [DllImport("ntdll.dll")] + private static extern uint NtSuspendProcess([In] IntPtr processHandle); + + [DllImport("kernel32.dll", SetLastError = true)] + private static extern IntPtr OpenProcess(ProcessAccess desiredAccess, bool inheritHandle, int processId); + + [DllImport("kernel32.dll", SetLastError = true)] + [return: MarshalAs(UnmanagedType.Bool)] + private static extern bool CloseHandle([In] IntPtr handle); + + public static void SuspendProcess(int processId) + { + IntPtr hProc = IntPtr.Zero; + try + { + hProc = OpenProcess(ProcessAccess.SuspendResume, false, processId); + if (hProc != IntPtr.Zero) + NtSuspendProcess(hProc); + } + finally + { + if (hProc != IntPtr.Zero) + CloseHandle(hProc); + } + } + public static void ResumeProcess(int processId) + { + IntPtr hProc = IntPtr.Zero; + try + { + hProc = OpenProcess(ProcessAccess.SuspendResume, false, processId); + if (hProc != IntPtr.Zero) + NtResumeProcess(hProc); + } + finally + { + if (hProc != IntPtr.Zero) + CloseHandle(hProc); + } + } + } +} diff --git a/Helpers/Speeder.cs b/Helpers/Speeder.cs deleted file mode 100644 index 2d0a147..0000000 --- a/Helpers/Speeder.cs +++ /dev/null @@ -1,134 +0,0 @@ -using System; -using System.Diagnostics; -using System.Runtime.InteropServices; - -namespace GTAVCSMM.Helpers -{ - - public static class Speeder - { - public static bool Suspend(int process) - { - try - { - // Obtain process instance. - Process proc = Process.GetProcessById(process); - - if (proc == null) - return false; - - // Obtain thread handle. - ProcessThread thread = proc.Threads[0]; - IntPtr lpThreadHandle = NativeAPI.OpenThread(NativeAPI.ThreadAccess.SUSPEND_RESUME, false, (uint)thread.Id); - if (lpThreadHandle == IntPtr.Zero) - return false; - - NativeAPI.SuspendThread(lpThreadHandle); - NativeAPI.CloseHandle(lpThreadHandle); - - return true; - } - catch { return false; } - } - - public static bool Resume(int process, bool bForceResume = false) - { - try - { - // Obtain process instance. - Process proc = Process.GetProcessById(process); - if (proc == null) - return false; - - // Obtain thread handle. - ProcessThread thread = proc.Threads[0]; - IntPtr lpThreadHandle = NativeAPI.OpenThread(NativeAPI.ThreadAccess.SUSPEND_RESUME, false, (uint)thread.Id); - if (lpThreadHandle == IntPtr.Zero) - return false; - - if (bForceResume == true) - while (NativeAPI.ResumeThread(lpThreadHandle) != 0) ; - else - NativeAPI.ResumeThread(lpThreadHandle); - - NativeAPI.CloseHandle(lpThreadHandle); - return true; - } - catch { return false; } - } - - #region "Native Win32 API Definitions" - /// - /// Native Win32 API Definitions - /// - /// API needed in order to do the required tasks of - /// loading, injection, and remote export calling. - /// - internal class NativeAPI - { - /// - /// kernel32.CloseHandle - /// - /// - /// - [DllImport("kernel32.dll", SetLastError = true)] - [return: MarshalAs(UnmanagedType.Bool)] - public static extern bool CloseHandle( - IntPtr hObject - ); - - /// - /// kernel32.OpenThread - /// - /// - /// - /// - /// - [DllImport("kernel32.dll")] - public static extern IntPtr OpenThread( - ThreadAccess dwDesiredAccess, - bool bInheritHandle, - uint dwThreadId - ); - - - /// - /// kernel32.ResumeThread - /// - /// - /// - [DllImport("kernel32.dll")] - public static extern uint ResumeThread( - IntPtr hThread - ); - - /// - /// kernel32.SuspendThread - /// - /// - /// - [DllImport("kernel32.dll")] - public static extern uint SuspendThread( - IntPtr hThread - ); - - /// - /// Thread access flags. - /// - [Flags] - public enum ThreadAccess : int - { - TERMINATE = (0x0001), - SUSPEND_RESUME = (0x0002), - GET_CONTEXT = (0x0008), - SET_CONTEXT = (0x0010), - SET_INFORMATION = (0x0020), - QUERY_INFORMATION = (0x0040), - SET_THREAD_TOKEN = (0x0080), - IMPERSONATE = (0x0100), - DIRECT_IMPERSONATION = (0x0200) - } - } - #endregion - } -} diff --git a/Memory/Mem.cs b/Memory/Mem.cs index 6ebd984..87c1710 100644 --- a/Memory/Mem.cs +++ b/Memory/Mem.cs @@ -124,5 +124,9 @@ public void writeFloat(long BasePTR, int[] offset, float Value) public byte ReadByte(long BasePTR, int[] offset) => ReadBytes(BasePTR, offset, 1)[0]; public string ReadStr(long BasePTR, int[] offset, int size) => new ASCIIEncoding().GetString(ReadBytes_new(BasePTR, offset, size)); + public bool IsValid(long Address) + { + return Address >= 0x10000 && Address < 0x000F000000000000; + } } } \ No newline at end of file diff --git a/Program.cs b/Program.cs index 5025664..ab69d31 100644 --- a/Program.cs +++ b/Program.cs @@ -9,6 +9,7 @@ using System.Linq; using System.Runtime.InteropServices; using System.Threading; +using System.Threading.Tasks; using System.Windows.Forms; namespace GTAVCSMM @@ -86,7 +87,6 @@ public struct RECT public static Patterns pattern = new Patterns(); public static TSettings settings = new TSettings(); public static Mem Mem; - public static Thread _freezeGame; public static System.Windows.Forms.Timer ProcessTimer = new System.Windows.Forms.Timer(); public static System.Windows.Forms.Timer MemoryTimer = new System.Windows.Forms.Timer(); @@ -404,25 +404,6 @@ public static void getPointer() Quit(); } } - - public static void freezeGame() - { - Console.WriteLine("Freezing game"); - Speeder.Suspend(settings.gameProcess); - Thread.Sleep(10000); - Speeder.Resume(settings.gameProcess); - _freezeGame.Abort(); - } - - public static void setWeaponUnlimitedAmmo() - { - Console.WriteLine("Freezing game"); - Speeder.Suspend(settings.gameProcess); - Mem.Write(settings.WorldPTR, new int[] { offsets.pCPed, offsets.pCWeaponInventory, offsets.oAmmoModifier }, 1); - Speeder.Resume(settings.gameProcess); - Activate(); - _freezeGame.Abort(); - } #endregion @@ -617,6 +598,7 @@ public static void listboxFill(int mainMenulevel, int menulevel) listBx.Items.Add("Teleport \t\t\t ►"); // 0,5 listBx.Items.Add("Tunables \t\t\t ►"); // 0,6 listBx.Items.Add("Online Services \t\t ►"); // 0,7 + listBx.Items.Add("World \t\t\t ►"); // 0,8 menuMainLvl = 0; menuLvl = 0; @@ -741,7 +723,7 @@ public static void listboxFill(int mainMenulevel, int menulevel) case 7: listBx.Items.Add("Get Lucky Wheel Price \t ►"); - listBx.Items.Add("Trigger Nightclub Production \t ►"); + listBx.Items.Add("Faster Nightclub Production"); listBx.Items.Add("Quick Car Spawn \t\t ►"); listBx.Items.Add("Manual Car Spawn \t\t ►"); @@ -752,6 +734,17 @@ public static void listboxFill(int mainMenulevel, int menulevel) LastMenuLvl = 1; LastMenuItm = 7; break; + + case 8: + listBx.Items.Add("Kill NPCs"); + + menuMainLvl = 1; + menuLvl = 8; + + LastMenuMainLvl = 0; + LastMenuLvl = 1; + LastMenuItm = 8; + break; } break; @@ -1089,6 +1082,9 @@ public static void runitem(int mainMenulevel, int menulevel, int menuItem) case 7: listboxFill(1, 7); break; + case 8: + listboxFill(1, 8); + break; } break; } @@ -1130,8 +1126,7 @@ public static void runitem(int mainMenulevel, int menulevel, int menuItem) break; case 4: Activate(); - _freezeGame = new Thread(freezeGame) { IsBackground = true }; - _freezeGame.Start(); + empty_session(); break; case 5: Activate(); @@ -1234,8 +1229,7 @@ public static void runitem(int mainMenulevel, int menulevel, int menuItem) listboxFill(4, 2); break; case 4: - _freezeGame = new Thread(setWeaponUnlimitedAmmo) { IsBackground = true }; - _freezeGame.Start(); + setWeaponUnlimitedAmmo(); break; } break; @@ -1309,7 +1303,8 @@ public static void runitem(int mainMenulevel, int menulevel, int menuItem) listboxFill(7, 0); break; case 1: - listboxFill(7, 1); + set_nightclub_produce_time(1, true); + Activate(); break; case 2: listboxFill(7, 2); @@ -1328,6 +1323,14 @@ public static void runitem(int mainMenulevel, int menulevel, int menuItem) break; } break; + case 8: + switch (menuItem) + { + case 0: + kill_npcs(); + break; + } + break; } break; @@ -2410,39 +2413,6 @@ public static void runitem(int mainMenulevel, int menulevel, int menuItem) break; } break; - case 1: - switch (menuItem) - { - case 0: - Activate(); - _SG_Int(262145 + 24135, 1); // South American Imports (14400000) - break; - case 1: - Activate(); - _SG_Int(262145 + 24136, 1); // Pharmaceutical Research (7200000) - break; - case 2: - Activate(); - _SG_Int(262145 + 24137, 1); // Organic Produce (2400000) - break; - case 3: - Activate(); - _SG_Int(262145 + 24138, 1); // Printing and Copying (1800000) - break; - case 4: - Activate(); - _SG_Int(262145 + 24139, 1); // Cash Creation (3600000) - break; - case 5: - Activate(); - _SG_Int(262145 + 24134, 1); // Sporting Goods (4800000) - break; - case 6: - Activate(); - _SG_Int(262145 + 24140, 1); // Cargo and Shipments (8400000) - break; - } - break; case 2: switch (menuItem) { @@ -2603,7 +2573,7 @@ private static IntPtr HookCallback( /* * Development */ - getPeds(); + kill_npcs(); } } } @@ -2612,26 +2582,12 @@ private static IntPtr HookCallback( public static void LoadSession(int id) { - if (id == -1) - { - _SG_Int(1574589 + 2, -1); // 1.60 1574587 -> 1574589 - _SG_Int(1574589, 1); - Thread.Sleep(200); - _SG_Int(1574589, 0); - } - else if (id == -2) - { - _SG_Int(1574589 + 2, 1); - Thread.Sleep(200); - _SG_Int(1574589, 0); - } - else + Task.Run(() => { - _SG_Int(1575012, id); // 1.60 1575004 -> 1575012 + _SG_Int(1575012, id); + _SG_Int(1574589 + 2, id == -1 ? -1 : 0); _SG_Int(1574589, 1); - Thread.Sleep(200); - _SG_Int(1574589, 0); - } + }); } public static void getLuckyWheelPrice(int id) @@ -2655,15 +2611,15 @@ public static void setRPMultipler(float m) public static void setREPMultipler(float m) { - _SG_Float(262145 + 31278, m); // Street Race - _SG_Float(262145 + 31279, m); // Pursuit Race - _SG_Float(262145 + 31280, m); // Scramble - _SG_Float(262145 + 31281, m); // Head 2 Head - _SG_Float(262145 + 31283, m); // Car Meet - _SG_Float(262145 + 31284, m); // Test Track - _SG_Float(262145 + 31312, m); // Auto Shop Contract - _SG_Float(262145 + 31313, m); // Customer Deliveries - _SG_Float(262145 + 31314, m); // Exotic Exports Deliveries + _SG_Float(262145 + 31294, m); // Street Race - old 31278 + 16 for 1.60 + _SG_Float(262145 + 31295, m); // Pursuit Race + _SG_Float(262145 + 31296, m); // Scramble + _SG_Float(262145 + 31297, m); // Head 2 Head + _SG_Float(262145 + 31289, m); // Car Meet + _SG_Float(262145 + 31300, m); // Test Track + _SG_Float(262145 + 31328, m); // Auto Shop Contract + _SG_Float(262145 + 31329, m); // Customer Deliveries + _SG_Float(262145 + 31330, m); // Exotic Exports Deliveries } #region Teleport part @@ -2982,7 +2938,7 @@ public static void getPeds() { long Ped = Mem.ReadPointer(settings.ReplayInterfacePTR, new int[] { offsets.pCPedInterface, offsets.pPedList, (i * pedListOffset) }); int pedType = Mem.ReadByte(settings.ReplayInterfacePTR, new int[] { offsets.pCPedInterface, offsets.pPedList, (i * pedListOffset), offsets.oEntityType }); - if (pedType != 156) { + if (pedType != 156 && Ped != 0) { pedList.Add(Ped); } } @@ -2997,6 +2953,122 @@ public static void getVehs() } } + public static void set_nightclub_produce_time(int produce_time, bool toggle) + { + // Time to Produce + _SG_Int(262145 + 24135, toggle ? produce_time : 4800000); // Sporting Goods + _SG_Int(262145 + 24136, toggle ? produce_time : 14400000); // South American Imports + _SG_Int(262145 + 24137, toggle ? produce_time : 7200000); // Pharmaceutical Research + _SG_Int(262145 + 24138, toggle ? produce_time : 2400000); // Organic Produce + _SG_Int(262145 + 24139, toggle ? produce_time : 1800000); // Printing and Copying + _SG_Int(262145 + 24140, toggle ? produce_time : 3600000); // Cash Creation + _SG_Int(262145 + 24141, toggle ? produce_time : 8400000); // Cargo and Shipments + } + + public static void set_mc_produce_time(int produce_time, bool toggle) + { + // Base Time to Produce + _SG_Int(262145 + 17198, toggle ? produce_time : 360000); // Weed + _SG_Int(262145 + 17199, toggle ? produce_time : 1800000); // Meth + _SG_Int(262145 + 17200, toggle ? produce_time : 3000000); // Cocaine + _SG_Int(262145 + 17201, toggle ? produce_time : 300000); // Documents + _SG_Int(262145 + 17202, toggle ? produce_time : 720000); // Cash + + // Time to Produce Reductions + _SG_Int(262145 + 17203, toggle ? 1 : 60000); // Documents Equipment + _SG_Int(262145 + 17204, toggle ? 1 : 120000); // Cash Equipment + _SG_Int(262145 + 17205, toggle ? 1 : 600000); // Cocaine Equipment + _SG_Int(262145 + 17206, toggle ? 1 : 360000); // Meth Equipment + _SG_Int(262145 + 17207, toggle ? 1 : 60000); // Weed Equipment + _SG_Int(262145 + 17208, toggle ? 1 : 60000); // Documents Staff + _SG_Int(262145 + 17209, toggle ? 1 : 120000); // Cash Staff + _SG_Int(262145 + 17210, toggle ? 1 : 600000); // Cocaine Staff + _SG_Int(262145 + 17211, toggle ? 1 : 360000); // Meth Staff + _SG_Int(262145 + 17212, toggle ? 1 : 60000); // Weed Staff + } + public static void empty_session() + { + Task.Run(() => + { + ProcessMgr.SuspendProcess(settings.gameProcess); + Task.Delay(10000).Wait(); + ProcessMgr.ResumeProcess(settings.gameProcess); + }); + } + + public static void setWeaponUnlimitedAmmo() + { + Task.Run(() => + { + ProcessMgr.SuspendProcess(settings.gameProcess); + Task.Delay(20).Wait(); + Mem.Write(settings.WorldPTR, new int[] { offsets.pCPed, offsets.pCWeaponInventory, offsets.oAmmoModifier }, 1); + Task.Delay(20).Wait(); + Activate(); + ProcessMgr.ResumeProcess(settings.gameProcess); + }); + } + + public static void kill_npcs() + { + Task.Run(() => + { + Activate(); + getPeds(); + for (int i = 0; i < pedList.Count; i++) + { + long ped = pedList[i]; + set_health(ped, 0.0f); + } + }); + } + + public static void kill_enemies() + { + getPeds(); + for (int i = 0; i < pedList.Count; i++) + { + long ped = pedList[i]; + if (is_enemy(ped)) + { + set_health(ped, 0.0f); + } + } + } + + public static void kill_cops() + { + getPeds(); + for (int i = 0; i < pedList.Count; i++) + { + long ped = pedList[i]; + uint pedtype = get_pedtype(ped); + Console.WriteLine(ped + " " + pedtype); + if (pedtype == (uint)EnumData.PedTypes.COP || + pedtype == (uint)EnumData.PedTypes.SWAT || + pedtype == (uint)EnumData.PedTypes.ARMY) + { + set_health(ped, 0.0f); + } + } + } + + public static int get_network_time() { return (int)_GG_Int(1574755 + 11); } + public static int player_id() { return (int)_GG_Int(offsets.oPlayerGA); } + public static byte get_type(long entity) { return Mem.ReadByte(entity, new int[] { 0x2B }); } + public static bool is_player(long entity) { return ((get_type(entity) == 156) ? true : false); } + public static byte get_hostility(long ped) { return Mem.ReadByte(ped, new int[] { 0x18C }); } + public static bool is_enemy(long ped) { return ((get_hostility(ped) > 1) ? true : false); } + public static uint get_pedtype(long ped) { + long paddr = Mem.GetPtrAddr(ped + 0x10B8, null); + Console.WriteLine(Mem.ReadUInt(paddr, null)); + return Mem.ReadUInt(paddr, null) << 11 >> 25; + } + public static void set_health(long ped, float value) { + long paddr = Mem.GetPtrAddr(ped + offsets.oHealth, null); + Mem.writeFloat(paddr, null, value); + } + } struct Location { public float x, y, z; } }