From 2693ae38364712c2cd09b703247ae56e3efc5513 Mon Sep 17 00:00:00 2001
From: Huoji's <1296564236@qq.com>
Date: Mon, 9 Oct 2023 02:33:33 +0800
Subject: [PATCH] =?UTF-8?q?=E5=8C=BA=E5=88=86=E6=AD=BB=E6=96=97=E5=92=8C?=
=?UTF-8?q?=E6=AD=A3=E5=B8=B8respawn?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
csgo2/csgo2.vcxproj | 1 +
csgo2/offset.cpp | 8 ++++----
csgo2/offset.h | 7 ++++---
csgo2/script_apis.cpp | 17 ++++++++++++++++-
loader/loader/loader.cpp | 4 +++-
loader/loader/loader.vcxproj | 1 +
6 files changed, 29 insertions(+), 9 deletions(-)
diff --git a/csgo2/csgo2.vcxproj b/csgo2/csgo2.vcxproj
index 91df1b8..8c19363 100644
--- a/csgo2/csgo2.vcxproj
+++ b/csgo2/csgo2.vcxproj
@@ -150,6 +150,7 @@
NotUsing
pch.h
stdcpplatest
+ MultiThreaded
Windows
diff --git a/csgo2/offset.cpp b/csgo2/offset.cpp
index 0b8de55..b84f50d 100644
--- a/csgo2/offset.cpp
+++ b/csgo2/offset.cpp
@@ -11,7 +11,7 @@ uint64_t MaxPlayerNumsPtr;
HashFunction_t FnServerHashFunction;
StateChanged_t FnStateChanged;
NetworkStateChanged_t FnNetworkStateChanged;
-RespawnPlayer_t FnRespawnPlayer;
+RespawnPlayerInDeathMatch_t FnRespawnPlayerInDeathMatch;
GiveNamedItem_t FnGiveNamedItem;
EntityRemove_t FnEntityRemove;
UTIL_SayTextFilter_t FnUTIL_SayTextFilter;
@@ -71,7 +71,7 @@ auto Init() -> bool {
server.FindPattern(pattern_CreateCCSGameRulesInterFacePtr)
.ToAbsolute(3, 0)
.Get(CCSGameRulesInterFacePtr);
- server.FindPattern(pattern_FnRespawnPlayer).Get(FnRespawnPlayer);
+ server.FindPattern(pattern_FnRespawnPlayerInDeathMatch).Get(FnRespawnPlayerInDeathMatch);
server.FindPattern(pattern_FnEntityRemove).Get(FnEntityRemove);
server.FindPattern(pattern_FnGiveNamedItemPtr).Get(FnGiveNamedItem);
server.FindPattern(pattern_fnHost_SayPtr).Get(Host_SayPtr);
@@ -123,7 +123,7 @@ auto Init() -> bool {
LOG("[huoji]FnNetworkStateChanged : %llx \n", FnNetworkStateChanged);
LOG("[huoji]FnServerHashFunction : %llx \n", FnServerHashFunction);
LOG("[huoji]FnStateChanged : %llx \n", FnStateChanged);
- LOG("[huoji]FnRespawnPlayer : %llx \n", FnRespawnPlayer);
+ LOG("[huoji]FnRespawnPlayerInDeathMatch : %llx \n", FnRespawnPlayerInDeathMatch);
LOG("[huoji]FnGiveNamedItem : %llx \n", FnGiveNamedItem);
LOG("[huoji]FnClientPrint : %llx \n", FnClientPrint);
LOG("[huoji]FnUTIL_ClientPrintAll : %llx \n", FnUTIL_ClientPrintAll);
@@ -154,7 +154,7 @@ auto Init() -> bool {
0, NULL);
// LOG("FnServerHashFunction: %llx \n", FnServerHashFunction("here",
// sizeof("here") - 1, 0x31415926));
- return FnCCSWeaponBase_Spawn && FnEntityRemove && FnRespawnPlayer && FnGiveNamedItem &&
+ return FnCCSWeaponBase_Spawn && FnEntityRemove && FnRespawnPlayerInDeathMatch && FnGiveNamedItem &&
FnServerHashFunction && Host_SayPtr && InterFaces::IVEngineServer &&
InterFaces::GameResourceServiceServer &&
InterFaces::IServerGameClient && InterFaces::GameEventManager &&
diff --git a/csgo2/offset.h b/csgo2/offset.h
index 17487ed..ef16fee 100644
--- a/csgo2/offset.h
+++ b/csgo2/offset.h
@@ -14,7 +14,7 @@ typedef void(__fastcall* StateChanged_t)(void* networkTransmitComponent,
typedef void(__fastcall* NetworkStateChanged_t)(uintptr_t chainEntity,
uintptr_t offset, uintptr_t a3);
typedef void*(__fastcall* CreateGameRuleInterFace_t)();
-typedef bool(__fastcall* RespawnPlayer_t)(CCSPlayerPawn* player);
+typedef bool(__fastcall* RespawnPlayerInDeathMatch_t)(CCSPlayerPawn* player);
typedef void(__fastcall* GiveNamedItem_t)(void* itemService,
const char* pchName, void* iSubType,
void* pScriptItem, void* a5,
@@ -26,7 +26,6 @@ typedef void*(__fastcall* UTIL_SayTextFilter_t)(IRecipientFilter&, const char*,
typedef void(__fastcall* UTIL_ClientPrintAll_t)(int msg_dest, const char* msg_name, const char* param1, const char* param2, const char* param3, const char* param4);
typedef void(__fastcall* ClientPrint_t)(CCSPlayerController* player, int msg_dest, const char* msg_name, const char* param1, const char* param2, const char* param3, const char* param4);
typedef void(__fastcall* CCSWeaponBase_Spawn_t)(CBaseEntity*, void*);
-
class CSchemaSystem;
class CGameResourceService;
class CLocalize;
@@ -79,6 +78,8 @@ static const auto pattern_CreateCCSGameRulesInterFacePtr = THE_GAME_SIG(
"?? ?? 4C 8D ?? ?? ?? 49 8B ?? ?? 49 8B ?? ?? 49 8B ?? ?? 49 8B E3 41 5F "
"41 5E 5F C3");
static const auto pattern_FnRespawnPlayer = THE_GAME_SIG(
+ "48 89 ?? ?? ?? 48 89 ?? ?? ?? 56 48 ?? ?? ?? ?? ?? ?? 48 8B DA 48 8B E9 48 85 D2 0F ?? ?? ?? ?? ?? 48 8B 02 48 8B CA FF ?? ?? ?? ?? ?? 84 C0 0F ?? ?? ?? ?? ?? 83 BB ?? ?? ?? ?? ?? 0F ?? ?? ?? ?? ??");
+static const auto pattern_FnRespawnPlayerInDeathMatch = THE_GAME_SIG(
"48 89 ?? ?? ?? 57 48 ?? ?? ?? 48 8D ?? ?? ?? 48 8B F9 E8 ?? ?? ?? ?? 83 "
"?? ?? 74 ?? 48 ?? ?? ?? ?? ?? ?? 48 8B CF 48 8B 10 48 8B ?? ?? ?? ?? ?? "
"48 8D ?? ?? ?? E8 ?? ?? ?? ?? 48 ?? ?? ?? ?? ?? ??");
@@ -102,7 +103,7 @@ extern uint64_t MaxPlayerNumsPtr;
extern HashFunction_t FnServerHashFunction;
extern StateChanged_t FnStateChanged;
extern NetworkStateChanged_t FnNetworkStateChanged;
-extern RespawnPlayer_t FnRespawnPlayer;
+extern RespawnPlayerInDeathMatch_t FnRespawnPlayerInDeathMatch;
extern GiveNamedItem_t FnGiveNamedItem;
extern EntityRemove_t FnEntityRemove;
extern UTIL_SayTextFilter_t FnUTIL_SayTextFilter;
diff --git a/csgo2/script_apis.cpp b/csgo2/script_apis.cpp
index 9b6f489..ef7633a 100644
--- a/csgo2/script_apis.cpp
+++ b/csgo2/script_apis.cpp
@@ -111,6 +111,7 @@ auto luaApi_SetPlayerCurrentWeaponAmmo(lua_State* luaVm) -> int {
lua_pop(luaVm, 3);
return 0;
}
+//
auto luaApi_RespawnPlayer(lua_State* luaVm) -> int {
const auto playerIndex = lua_tointeger(luaVm, 1);
int playerArmorValue = 0;
@@ -120,7 +121,20 @@ auto luaApi_RespawnPlayer(lua_State* luaVm) -> int {
if (playerPawn == nullptr) {
return;
}
- Offset::FnRespawnPlayer(playerPawn);
+ Offset::InterFaces::CCSGameRulesInterFace->PlayerRespawn(playerPawn);
+ });
+ return 0;
+}
+auto luaApi_RespawnPlayerInDeathMatch(lua_State* luaVm) -> int {
+ const auto playerIndex = lua_tointeger(luaVm, 1);
+ int playerArmorValue = 0;
+ ExcutePlayerAction(playerIndex, [&](CCSPlayerController* playerController) {
+ const auto playerPawn =
+ playerController->m_hPawn().Get();
+ if (playerPawn == nullptr) {
+ return;
+ }
+ Offset::FnRespawnPlayerInDeathMatch(playerPawn);
});
return 0;
}
@@ -753,6 +767,7 @@ auto initFunciton(lua_State* luaVm) -> void {
lua_register(luaVm, "luaApi_SetPlayerArmorValue",
luaApi_SetPlayerArmorValue);
lua_register(luaVm, "luaApi_RespawnPlayer", luaApi_RespawnPlayer);
+ lua_register(luaVm, "luaApi_RespawnPlayerInDeathMatch", luaApi_RespawnPlayerInDeathMatch);
lua_register(luaVm, "luaApi_CreateTimer", luaApi_CreateTimer);
lua_register(luaVm, "luaApi_CreateTickRunFunction",
luaApi_CreateTickRunFunction);
diff --git a/loader/loader/loader.cpp b/loader/loader/loader.cpp
index cd3fc3a..dea2e6c 100644
--- a/loader/loader/loader.cpp
+++ b/loader/loader/loader.cpp
@@ -10,6 +10,7 @@
#include
struct _Config
{
+ std::string dll;
std::string path;
std::string command;
};
@@ -32,9 +33,10 @@ namespace Config {
for (rapidjson::SizeType i = 0; i < servers.Size(); i++) { // Uses SizeType instead of size_t
const rapidjson::Value& server = servers[i];
assert(server.IsObject()); // Each server should be an object.
- if (server.HasMember("path") && server["path"].IsString() && server.HasMember("command") && server["command"].IsString())
+ if (server.HasMember("path") && server["path"].IsString() && server.HasMember("command") && server["command"].IsString() && server.HasMember("dll") && server["dll"].IsString())
{
configs.push_back(_Config{
+ .dll = server["dll"].GetString(),
.path = server["path"].GetString(),
.command = server["command"].GetString()
});
diff --git a/loader/loader/loader.vcxproj b/loader/loader/loader.vcxproj
index 4dd5cac..cecc8cc 100644
--- a/loader/loader/loader.vcxproj
+++ b/loader/loader/loader.vcxproj
@@ -134,6 +134,7 @@
NDEBUG;_CONSOLE;%(PreprocessorDefinitions)
true
stdcpplatest
+ MultiThreaded
Console