diff --git a/src/cheatmenu.cpp b/src/cheatmenu.cpp
index 000b2c6..35f2648 100644
--- a/src/cheatmenu.cpp
+++ b/src/cheatmenu.cpp
@@ -9,6 +9,10 @@
#include "pages/teleport.h"
#include "pages/menu.h"
+// My headers
+#include "test/functions/player_functions.h"
+#include "test/events/test_events.h"
+
// 6-14-2024 @ 11:34AM - kelson8
// I setup this for building the asi:
// https://stackoverflow.com/questions/1776060/how-to-make-visual-studio-copy-a-dll-file-to-the-output-directory
@@ -226,6 +230,7 @@ CheatMenuMgr::CheatMenuMgr()
// Doesn't work with ThirteenAG's windowed mode while inside initRwEvent
Events::initGameEvent += [this]()
{
+
if (!D3dHook::Init(fArgNoneWrapper(CheatMenu.Draw)))
{
return;
@@ -234,8 +239,26 @@ CheatMenuMgr::CheatMenuMgr()
ApplyStyle();
};
+ // New
+ Events::gameProcessEvent += [this]()
+ {
+ //
+ // Custom events
+ // Chaos mode, these only run when defined in the test_events.cpp file.
+ TestEvents::KillPlayerIfAiming();
+ TestEvents::ChaosModeEvent();
+ };
+
+
Events::processScriptsEvent += [this]()
{
+
+ //
+ // Custom events
+ // Chaos mode, these only run when defined in the test_events.cpp file.
+ TestEvents::DrowningExplosionEvent();
+ //
+
if (!FrontEndMenuManager.m_bMenuActive)
{
if (menuOpen.Pressed())
diff --git a/src/test/events/test_events.cpp b/src/test/events/test_events.cpp
new file mode 100644
index 0000000..6313653
--- /dev/null
+++ b/src/test/events/test_events.cpp
@@ -0,0 +1,171 @@
+#include "pch.h"
+#include "test_events.h"
+#include "./test/functions/player_functions.h"
+#include "./test/utils/timer_util.h"
+
+#include "CPhysical.h"
+
+#ifdef GTASA
+#include "CClock.h"
+#include "CTimer.h"
+
+#endif //GTASA
+
+// TODO Move Chaos mode events into its own file.
+// Most of these events will only run if this is defined
+//#define _CHAOS_MODE
+
+
+// Stuff to mess around with
+// playerPed->m_nFightingStyle = STYLE_BOXING;
+// playerPed->m_nPhysicalFlags.bApplyGravity = false;
+
+// Make it to where if the car catches on fire the player can't exit it.
+// playerPed->m_nPedFlags.bCanExitCar = false;
+// playerPed->m_nPedFlags.bDontFight = false;
+// playerPed->m_nPedFlags.CantBeKnockedOffBike = false;
+
+
+// TODO Move these and other chaos items into a seperate mod named KCNet-SAChaosMod
+// Most of these are running on the main class which is cheatmenu.cpp
+
+// TODO Add this into a checkbox for a toggle in the test menu.
+
+TestEvents::TestEvents()
+{
+
+}
+
+///
+/// Kill the player if they are aiming, this didn't work.
+///
+void TestEvents::KillPlayerIfAiming()
+{
+#ifdef _CHAOS_MODE
+ CPlayerPed* player = FindPlayerPed();
+ CPed* playerPed = reinterpret_cast(player);
+
+ if (playerPed->m_nPedFlags.bIsAimingGun)
+ {
+ player->m_fHealth = 0;
+ player->m_fArmour = 0;
+ Util::SetMessage("You have been exterminated!");
+ }
+
+#endif //CHAOS_MODE
+}
+
+///
+/// Event that blows up the player if they are drowning.
+/// This just constantly blows up the player if they are in the water, not even if they are drowning.
+///
+void TestEvents::DrowningExplosionEvent()
+
+{
+#ifdef _CHAOS_MODE
+ CPlayerPed* player = FindPlayerPed();
+
+ // Oh wow this actually worked!
+ CPed* playerPed = reinterpret_cast(player);
+ //CPhysical* cPhysical = new CPhysical(player);
+
+ // This spawns too many bombs, sometimes hurts the player when they respawn, I wonder how to fix that.
+ if (playerPed->m_nPedFlags.bIsDrowning)
+ {
+ PlayerFunctions::SpawnBombOnPlayer();
+ }
+
+ //playerPed->m_nPedFlags.
+
+
+ //player->m_b
+ //if(player->)
+#endif //CHAOS_MODE
+}
+
+void CanNotExitCar()
+{
+ CPlayerPed* player = FindPlayerPed();
+ CPed* playerPed = reinterpret_cast(player);
+ playerPed->m_nPedFlags.bCanExitCar = false;
+}
+
+void KillPlayerInVehicle()
+{
+ // Blow up the player if they enter a car and don't let them escape.. How evil!
+ if (PlayerFunctions::IsPlayerInVehicle())
+ {
+ PlayerFunctions::SpawnBombOnPlayer();
+ // Set it to where the player cannot exit the vehicle.
+ //CanNotExitCar();
+ }
+}
+
+void KillPlayerInMiddleOfMap()
+{
+ PlayerFunctions* playerFunctions = new PlayerFunctions();
+ CPlayerPed* player = FindPlayerPed();
+#ifdef GTASA
+
+ CVector coords1 = CVector(2, 2, 2);
+ CVector coords2 = CVector(20, 20, 20);
+ if (playerFunctions->IsPlayerInArea(coords1.x, coords1.y, coords1.z, coords2.x, coords2.y, coords2.z))
+ {
+ playerFunctions->KillPlayer();
+ // This just spams the screen, I wonder how to check if they died or update a value
+ if (!player->IsAlive()) {
+ Util::SetMessage("You have been exterminated!");
+ }
+ //Util::SetMessage("Hello");
+ }
+#endif //GTASA
+}
+
+
+
+// This seems to work in this class.
+//#define _CHAOS_MODE
+void TestEvents::ChaosModeEvent()
+{
+
+ // Put this outside of the preprocessors here so the preprocessors don't comment it out.
+ PlayerFunctions* playerFunctions = new PlayerFunctions();
+ CPlayerPed* player = FindPlayerPed();
+
+
+
+ //if(PlayerFunctions::m_bRespawnMiddleOfMap)
+ // This doesn't seem to toggle it on/off properly
+#ifdef _TEST
+ if (playerFunctions->m_bRespawnMiddleOfMap)
+ {
+ Command(22.0, 22.0, 2.0, 20.0);
+ }
+ // Quick test, this will always run and cancel it all the time most likely.
+ else
+ {
+ Command();
+ }
+#endif //TEST
+ // This seems to work fine, idk if it'll crash the game though.
+//#ifdef _TEST
+// Command(22.0, 22.0, 2.0, 20.0);
+//#endif //_TEST
+#ifdef _CHAOS_MODE
+ // 6-18-2024 @ 3:37AM
+ // I figured out how to get timers working on here, this is running in Events::gameProcessEvent in cheatmenu.cpp
+ // This does work. Copied from overlay.cpp on lines 429-432
+ size_t game_ms = CTimer::m_snTimeInMilliseconds;
+ static size_t interval = 0;
+
+ // Add test timer for this, this works!
+ if (game_ms - interval > 1000) {
+ //
+ KillPlayerInVehicle();
+ interval = game_ms;
+ }
+
+ KillPlayerInMiddleOfMap();
+
+#endif //_CHAOS_MODE
+}
diff --git a/src/test/events/test_events.h b/src/test/events/test_events.h
new file mode 100644
index 0000000..46301b5
--- /dev/null
+++ b/src/test/events/test_events.h
@@ -0,0 +1,11 @@
+#pragma once
+//#include "pch.h"
+
+class TestEvents
+{
+public:
+ TestEvents();
+ static void ChaosModeEvent();
+ static void DrowningExplosionEvent();
+ static void KillPlayerIfAiming();
+};
diff --git a/src/test/functions/player_functions.cpp b/src/test/functions/player_functions.cpp
new file mode 100644
index 0000000..d1e695f
--- /dev/null
+++ b/src/test/functions/player_functions.cpp
@@ -0,0 +1,180 @@
+#include "pch.h"
+#include "player_functions.h"
+#include "enums/audio_ids.h"
+#include "test/utils/timer_util.h"
+
+#include "CExplosion.h"
+
+
+///
+/// Mostly helper functions for the player.
+///
+
+PlayerFunctions::PlayerFunctions()
+{
+ //if (m_bRespawnMiddleOfMap)
+ //{
+
+ //}
+}
+
+void PlayerFunctions::KillPlayer()
+{
+ CPlayerPed* player = FindPlayerPed();
+ player->m_fHealth = 0;
+ player->m_fArmour = 0;
+}
+
+///
+/// Sets the never wanted value, incomplete
+///
+/// If never wanted is on
+static void SetNeverWanted(bool toggle)
+{
+ if(toggle)
+ {
+ // Enable never wanted
+ }
+ else
+ {
+ // Disable never wanted
+ }
+}
+
+///
+/// Sets the player as invincible, incomplete
+///
+/// If the player is invincible.
+static void SetInvincible(bool toggle)
+{
+ if (toggle)
+ {
+ // Enable invincibility
+ }
+ else
+ {
+ // Disable invincibility
+ }
+}
+
+///
+/// Sets the infinte ammo cheat, incomplete.
+///
+/// If infinite ammo is active.
+static void SetInfiniteAmmo(bool toggle)
+{
+ if (toggle)
+ {
+ // Enable infinite ammo
+ }
+ else
+ {
+ // Disable infinite ammo
+ }
+}
+
+// This should work in here, untested
+
+///
+/// Spawn a bomb on the player with sound, like a grenade or satchel charge.
+///
+void PlayerFunctions::SpawnBombOnPlayer()
+{
+#ifdef GTASA
+ //TODO Test these in the other games, 3 and vc later!
+ CPlayerPed* player = FindPlayerPed();
+ int hplayer = CPools::GetPedRef(player);
+
+ CVector playerPos = player->GetPosition();
+
+ // https://library.sannybuilder.com/#/sa/default/020C
+ // x, y, z, EXPLOSION_CAR
+ // Will this work for a time delay on this?
+ // No this didn't work at all.
+
+ // This stops the explosions when the player dies.
+ if (!player->IsAlive()) {
+ return;
+ }
+
+ Command(playerPos.x, playerPos.y, playerPos.z, EXPLOSION_CAR);
+
+ // https://library.sannybuilder.com/#/sa/default/018C
+ // These might work: https://sampwiki.blast.hk/wiki/SoundID
+ Command(playerPos.x, playerPos.y, playerPos.z, AudioIds::EXPLOSION_SOUND);
+
+ // This does about the same as above with a bit more code.
+
+
+ // Will this work?
+ //int explosionId = CExplosion::AddExplosion(FindPlayerPed(), FindPlayerPed(), EXPLOSION_CAR, playerPos, 1000, 1, 1.0f, true);
+ //CExplosion::GetExplosionPosition(explosionId);
+
+
+ //CExplosion::RemoveAllExplosionsInArea();
+#endif //GTASA
+}
+
+//static bool IsPlayerInCar()
+//{
+//
+//}
+
+///
+/// Checks if the player is in the specified area.
+/// Values are the first set of x,y,z and the second set in a cube, if you have ever messed with mta sa lua it's kind of like that.
+/// So if you want the player to be killed going from 2,2,2 to 20,20,20 that would be possible.
+///
+/// If player is in specified area
+///
+//static bool IsPlayerInArea(float x1, float y1, float z1, float x2, float y2, float z2)
+bool PlayerFunctions::IsPlayerInArea(float x1, float y1, float z1, float x2, float y2, float z2)
+{
+ CPlayerPed* player = FindPlayerPed();
+ int hplayer = CPools::GetPedRef(player);
+
+ CVector playerPos = player->GetPosition();
+
+ // https://library.sannybuilder.com/#/sa/default/00A4
+
+ if (Command(hplayer,
+ x1, y1, z1, x2, y2, z2, false)) {
+ return true;
+ }
+ else
+ {
+ return false;
+ }
+}
+
+///
+/// Check if player is in a train
+///
+/// If the player is in a train
+bool PlayerFunctions::IsPlayerInTrain()
+{
+ CPlayerPed* player = FindPlayerPed();
+ int hplayer = CPools::GetPedRef(player);
+ if (Command(hplayer)) {
+ return true;
+ }
+ else
+ {
+ return false;
+ }
+}
+
+bool PlayerFunctions::IsPlayerInVehicle()
+{
+ CPlayerPed* player = FindPlayerPed();
+ int hplayer = CPools::GetPedRef(player);
+ if (Command(hplayer))
+ {
+ return true;
+ }
+ else
+ {
+ return false;
+ }
+}
+
diff --git a/src/test/player_functions.h b/src/test/functions/player_functions.h
similarity index 81%
rename from src/test/player_functions.h
rename to src/test/functions/player_functions.h
index 4ac5071..b4216b0 100644
--- a/src/test/player_functions.h
+++ b/src/test/functions/player_functions.h
@@ -8,6 +8,8 @@ public:
PlayerFunctions();
PlayerFunctions(const PlayerFunctions&);
static void KillPlayer();
+ static void SpawnBombOnPlayer();
+ static bool IsPlayerInVehicle();
static bool IsPlayerInArea(float x1, float y1, float z1, float x2, float y2, float z2);
static bool IsPlayerInTrain();
};
diff --git a/src/test/functions/vehicle_functions.cpp b/src/test/functions/vehicle_functions.cpp
new file mode 100644
index 0000000..3253180
--- /dev/null
+++ b/src/test/functions/vehicle_functions.cpp
@@ -0,0 +1,67 @@
+#include "pch.h"
+
+#include "vehicle_functions.h"
+#include "player_functions.h"
+
+void VehicleTest()
+{
+ CPlayerPed* player = FindPlayerPed();
+ int hplayer = CPools::GetPedRef(player);
+ CVehicle* pVeh = nullptr;
+ if (PlayerFunctions::IsPlayerInVehicle())
+ {
+ CVehicle* pVeh = player->m_pVehicle;
+ //pVeh->
+ }
+}
+
+///
+/// Quick test for making sure this class is working.
+///
+void VehicleFunctions::PlayerInCarMsg()
+{
+ CPlayerPed* player = FindPlayerPed();
+ int hplayer = CPools::GetPedRef(player);
+ CVehicle* pVeh = nullptr;
+ if (PlayerFunctions::IsPlayerInVehicle())
+ {
+ Util::SetMessage("You are in a car.");
+ }
+ else
+ {
+ Util::SetMessage("You are not in a car.");
+ }
+}
+
+///
+/// Check if the players current vehicle is in the water
+///
+/// If the current vehicle is in water.
+bool VehicleFunctions::IsCarInWater()
+{
+#ifdef GTASA
+ CPlayerPed* player = FindPlayerPed();
+ int hplayer = CPools::GetPedRef(player);
+ CVehicle* pVeh = nullptr;
+
+ // TODO Possibly Move this into a vehicle_functions file.
+ // First we check if the player is in a vehicle
+ if (PlayerFunctions::IsPlayerInVehicle()) {
+ CVehicle* pVeh = player->m_pVehicle;
+ int hVeh = CPools::GetVehicleRef(pVeh);
+ // https://library.sannybuilder.com/#/sa/default/04D8
+ bool isCarInWater = Command(hVeh);
+
+ // If the car is not in water
+ if (!isCarInWater)
+ {
+ return false;
+ }
+ // If the car is in water
+ else
+ {
+ return true;
+ }
+ }
+#endif //GTASA
+}
\ No newline at end of file
diff --git a/src/test/functions/vehicle_functions.h b/src/test/functions/vehicle_functions.h
new file mode 100644
index 0000000..f5c09a6
--- /dev/null
+++ b/src/test/functions/vehicle_functions.h
@@ -0,0 +1,10 @@
+#pragma once
+
+//#include "pch.h"
+
+class VehicleFunctions
+{
+public:
+ static void PlayerInCarMsg();
+ static bool IsCarInWater();
+};
\ No newline at end of file
diff --git a/src/test/player_functions.cpp b/src/test/player_functions.cpp
deleted file mode 100644
index 7c482b3..0000000
--- a/src/test/player_functions.cpp
+++ /dev/null
@@ -1,106 +0,0 @@
-#include "pch.h"
-#include "player_functions.h"
-
-PlayerFunctions::PlayerFunctions()
-{
- //if (m_bRespawnMiddleOfMap)
- //{
-
- //}
-}
-
-void PlayerFunctions::KillPlayer()
-{
- CPlayerPed* player = FindPlayerPed();
- player->m_fHealth = 0;
- player->m_fArmour = 0;
-}
-
-static void SetNeverWanted(bool toggle)
-{
- if(toggle)
- {
- // Enable never wanted
- }
- else
- {
- // Disable never wanted
- }
-}
-
-static void SetInvincible(bool toggle)
-{
- if (toggle)
- {
- // Enable invincibility
- }
- else
- {
- // Disable invincibility
- }
-}
-
-static void SetInfiniteAmmo(bool toggle)
-{
- if (toggle)
- {
- // Enable infinite ammo
- }
- else
- {
- // Disable infinite ammo
- }
-}
-
-//static bool IsPlayerInCar()
-//{
-//
-//}
-
-/// This is untested but it should work.
-///
-/// Checks if the player is in the specified area.
-/// Values are the first set of x,y,z and the second set in a cube, if you have ever messed with mta sa lua it's kind of like that.
-/// So if you want the player to be killed going from 2,2,2 to 20,20,20 that would be possible.
-///
-/// If player is in specified area
-///
-//static bool IsPlayerInArea(float x1, float y1, float z1, float x2, float y2, float z2)
-bool PlayerFunctions::IsPlayerInArea(float x1, float y1, float z1, float x2, float y2, float z2)
-{
- CPlayerPed* player = FindPlayerPed();
- int hplayer = CPools::GetPedRef(player);
-
- CVector playerPos = player->GetPosition();
-
- // https://library.sannybuilder.com/#/sa/default/00A4
-
- if (Command(hplayer,
- x1, y1, z1, x2, y2, z2, false)) {
- return true;
- }
- else
- {
- return false;
- }
-}
-
-///
-/// Check if player is in a train
-///
-/// If the player is in a train
-bool PlayerFunctions::IsPlayerInTrain()
-{
- CPlayerPed* player = FindPlayerPed();
- int hplayer = CPools::GetPedRef(player);
- if (Command(hplayer)) {
- return true;
- }
- else
- {
- return false;
- }
-}
-
-
-
diff --git a/src/test/test.cpp b/src/test/test.cpp
index d3c6f79..17110d3 100644
--- a/src/test/test.cpp
+++ b/src/test/test.cpp
@@ -18,6 +18,9 @@
https://github.com/user-grinch/Cheat-Menu
*/
+// TODO Move this into my own menu named KCNet-SAMenu, possibly try to make it work on Vice City and 3.
+
+
// TODO Figure out how to get the coordniates of where the player is looking at, I think that should be possible.
// TODO Try to get this working on VC and 3 sometime, the menu normally works on those games I would just have to make sure I don't have any SA specific
// memory addresses or anything in it.
@@ -33,6 +36,9 @@
// Set ped vehicle multipler: https://library.sannybuilder.com/#/sa/default/01EB
//
+// This guide might be useful:
+// https://www.open.mp/docs/tutorials/PluginDevelopmentGuide
+
#ifdef GTASA
#include "CExplosion.h"
@@ -86,7 +92,8 @@
#include "test_hud.h"
#include "test_ped.h"
#include "test_world.h"
-#include "player_functions.h"
+#include "functions/player_functions.h"
+#include "functions/vehicle_functions.h"
// Well I had this working but then broke it 6-14-2024 @ 3:51PM...
// I fixed it 3:53PM.
@@ -292,6 +299,7 @@ void TestPage::Draw()
if (ImGui::Button("Play Mission Passed"))
{
// https://library.sannybuilder.com/#/sa/default/0394
+
Command(1);
//bool isFlyingActive = CCheat::m_aCheatsActive);
//Util::SetMessage(std::format("Is Flying Active: {}", isFlyingActive).c_str());
@@ -331,6 +339,29 @@ void TestPage::Draw()
//////
// New
ImGui::Separator();
+
+ ImGui::Text("In game clock");
+
+
+ //if (ImGui::Button("Show mili Seconds?"))
+ //{
+ // short currentGameSeconds = CClock::ms_nGameClockSeconds;
+ // Util::SetMessage(std::format("ms {}", currentGameSeconds).c_str());
+ //}
+
+ if (ImGui::Button("Show hours"))
+ {
+ short currentGameHours = CClock::ms_nGameClockHours;
+ Util::SetMessage(std::format("Hour: {}", currentGameHours).c_str());
+ }
+
+ if (ImGui::Button("Show Minutes"))
+ {
+ short currentGameMinutes = CClock::ms_nGameClockMinutes;
+ Util::SetMessage(std::format("Minute: {}", currentGameMinutes).c_str());
+ }
+
+ // Train Menu
TrainTestMenu();
//////