Compare commits
14 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
32f4f638e3 | ||
|
|
89046db624 | ||
|
|
d3f22fc9fc | ||
|
|
31a3fe5428 | ||
|
|
4a5a37ba95 | ||
|
|
56cd154f31 | ||
|
|
ea7c896842 | ||
|
|
fe8531413d | ||
|
|
af727eaa6b | ||
|
|
f5413c4516 | ||
|
|
e5bb3ec652 | ||
|
|
254d0e1cd5 | ||
|
|
b53f4457e6 | ||
|
|
60d1ebac1f |
@@ -230,6 +230,7 @@
|
||||
<ClInclude Include="sdk\public\eiface.h" />
|
||||
<ClInclude Include="sdk\public\IAppSystem.h" />
|
||||
<ClInclude Include="sdk\public\icvar.h" />
|
||||
<ClInclude Include="sdk\public\igameeventsystem.h" />
|
||||
<ClInclude Include="sdk\public\irecipientfilter.h" />
|
||||
<ClInclude Include="sdk\public\iserver.h" />
|
||||
<ClInclude Include="sdk\public\mathlib.h" />
|
||||
|
||||
@@ -369,6 +369,9 @@
|
||||
<ClInclude Include="luaCjson\strbuf.h">
|
||||
<Filter>源文件\script_engine\lua_cjson</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="sdk\public\igameeventsystem.h">
|
||||
<Filter>头文件\sdk\public</Filter>
|
||||
</ClInclude>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="dllmain.cpp">
|
||||
|
||||
@@ -35,9 +35,9 @@ auto init(void* ctx) -> bool {
|
||||
serverHandle = reinterpret_cast<uint64_t>(GetModuleHandleA("server.dll"));
|
||||
localizeHandle = reinterpret_cast<uint64_t>(GetModuleHandleA("localize.dll"));
|
||||
|
||||
Sleep(200);
|
||||
Sleep(100);
|
||||
}
|
||||
global::isMetaModInit = (GetModuleHandleA("metamod.2.cs2.dll") != nullptr);
|
||||
global::IsMetaModInit = (GetModuleHandleA("metamod.2.cs2.dll") != nullptr);
|
||||
if (Offset::Init() == false) {
|
||||
LOG("Offset::Init() == false !\n");
|
||||
return false;
|
||||
|
||||
@@ -2,12 +2,12 @@
|
||||
|
||||
namespace events {
|
||||
auto OnPlayerTeamChangeEevent(IGameEvent* event) -> void {
|
||||
GameEventKeySymbol_t userIdNameParams{ "userid" };
|
||||
GameEventKeySymbol_t teamNameParams{ "team" };
|
||||
GameEventKeySymbol_t oldteamNameParams{ "oldteam" };
|
||||
GameEventKeySymbol_t disconnectNameParams{ "disconnect"};
|
||||
GameEventKeySymbol_t silentNameParams{ "silent" };
|
||||
GameEventKeySymbol_t isbotParams{ "isbot"};
|
||||
GameEventKeySymbol_t userIdNameParams{"userid"};
|
||||
GameEventKeySymbol_t teamNameParams{"team"};
|
||||
GameEventKeySymbol_t oldteamNameParams{"oldteam"};
|
||||
GameEventKeySymbol_t disconnectNameParams{"disconnect"};
|
||||
GameEventKeySymbol_t silentNameParams{"silent"};
|
||||
GameEventKeySymbol_t isbotParams{"isbot"};
|
||||
|
||||
const auto PlayerPawn = reinterpret_cast<CCSPlayerPawn*>(
|
||||
event->GetPlayerPawn(userIdNameParams));
|
||||
@@ -27,7 +27,8 @@ auto OnPlayerTeamChangeEevent(IGameEvent* event) -> void {
|
||||
auto disconnect = event->GetBool(disconnectNameParams);
|
||||
auto slient = event->GetBool(silentNameParams);
|
||||
auto isBot = event->GetBool(isbotParams);
|
||||
if (ScriptCallBacks::luaCall_onPlayerTeamChange(playerIndex, team, oldTeam, disconnect, slient, isBot) == true) {
|
||||
if (ScriptCallBacks::luaCall_onPlayerTeamChange(
|
||||
playerIndex, team, oldTeam, disconnect, slient, isBot) == true) {
|
||||
event->SetBool(silentNameParams, true);
|
||||
}
|
||||
}
|
||||
@@ -115,7 +116,7 @@ auto OnPlayerDeathEvent(IGameEvent* event) -> void {
|
||||
GameEventKeySymbol_t userIdNameParams{"userid"};
|
||||
GameEventKeySymbol_t attackerNameParams{"attacker"};
|
||||
GameEventKeySymbol_t headshotNameParams{"headshot"};
|
||||
|
||||
|
||||
const auto victimPawn = reinterpret_cast<CCSPlayerPawn*>(
|
||||
event->GetPlayerPawn(userIdNameParams));
|
||||
const auto attackerPawn = reinterpret_cast<CCSPlayerPawn*>(
|
||||
@@ -137,7 +138,11 @@ auto OnPlayerDeathEvent(IGameEvent* event) -> void {
|
||||
const auto attackerIndex = attacker->GetRefEHandle().GetEntryIndex();
|
||||
ScriptCallBacks::luaCall_onPlayerDeath(victimIndex, attackerIndex,
|
||||
isHeadShot);
|
||||
//printf("player[%p] %s kill[%p] %llu\n", attacker, &attacker->m_iszPlayerName(), victim, &victim->m_steamID());
|
||||
// printf("player[%p] %s kill[%p] %llu\n", attacker,
|
||||
// &attacker->m_iszPlayerName(), victim, &victim->m_steamID());
|
||||
}
|
||||
auto OnConsoleChat(std::string message) -> bool {
|
||||
return ScriptCallBacks::luaCall_onPlayerSpeak(-1, static_cast<int>(_ChatType::kConsole), message);
|
||||
}
|
||||
auto OnPlayerChat(CCSPlayerController* player, std::string message) -> bool {
|
||||
auto [procesChatSuccess, chatType, chatCtx] =
|
||||
@@ -146,7 +151,8 @@ auto OnPlayerChat(CCSPlayerController* player, std::string message) -> bool {
|
||||
return false;
|
||||
}
|
||||
return ScriptCallBacks::luaCall_onPlayerSpeak(
|
||||
player->GetRefEHandle().GetEntryIndex(), chatType, chatCtx);
|
||||
player->GetRefEHandle().GetEntryIndex(), static_cast<int>(chatType),
|
||||
chatCtx);
|
||||
}
|
||||
auto OnPlayerConnect(int slot, const char* pszName, uint64_t xuid,
|
||||
const char* pszNetworkID, const char* pszAddress,
|
||||
|
||||
@@ -4,6 +4,7 @@ class CCSPlayerController;
|
||||
namespace events {
|
||||
auto OnPlayerDeathEvent(IGameEvent* event) -> void;
|
||||
auto OnPlayerChat(CCSPlayerController* player, std::string message) -> bool;
|
||||
auto OnConsoleChat(std::string message) -> bool;
|
||||
auto OnPlayerConnect(int slot, const char* pszName, uint64_t xuid,
|
||||
const char* pszNetworkID, const char* pszAddress,
|
||||
bool bFakePlayer) -> void;
|
||||
|
||||
@@ -7,5 +7,5 @@ namespace global {
|
||||
CGlobalVars* GlobalVars;
|
||||
float m_flUniversalTime;
|
||||
float m_flLastTickedTime;
|
||||
bool isMetaModInit;
|
||||
bool IsMetaModInit;
|
||||
}
|
||||
@@ -10,5 +10,5 @@ namespace global {
|
||||
extern CGlobalVars* GlobalVars;
|
||||
extern float m_flUniversalTime;
|
||||
extern float m_flLastTickedTime;
|
||||
extern bool isMetaModInit;
|
||||
extern bool IsMetaModInit;
|
||||
}
|
||||
123
csgo2/hooks.cpp
123
csgo2/hooks.cpp
@@ -6,6 +6,8 @@ namespace hooks {
|
||||
VMTHook* VMT_IServerGameClient;
|
||||
VMTHook* VMT_INetworkServerServiceInteFace;
|
||||
VMTHook* VMT_ISource2ServerInterFace;
|
||||
VMTHook* VMT_GameEventSystem;
|
||||
|
||||
FireEventServerSide_t original_FireEventServerSide = NULL;
|
||||
OnClientConnect_t original_OnClientConnected = NULL;
|
||||
OnClientDisconnect_t original_OnClientDisconnect = NULL;
|
||||
@@ -13,6 +15,90 @@ Host_Say_t original_Host_Say = NULL;
|
||||
StartupServer_t origin_StartServer = NULL;
|
||||
GameFrame_t origin_GameFrame = NULL;
|
||||
CCSWeaponBase_Spawn_t origin_CCSWeaponBase_Spawn = NULL;
|
||||
UTIL_SayText2Filter_t origin_UTIL_SayText2Filter = NULL;
|
||||
PostEventAbstract_t origin_PostEventAbstract = NULL;
|
||||
|
||||
void __fastcall hook_PostEventAbstract(
|
||||
void* rcx,
|
||||
CSplitScreenSlot nSlot,
|
||||
bool bLocalOnly,
|
||||
int nClientCount,
|
||||
const uint64* clients,
|
||||
INetworkSerializable* pEvent,
|
||||
const void* pData,
|
||||
unsigned long nSize,
|
||||
NetChannelBufType_t bufType)
|
||||
{
|
||||
do
|
||||
{
|
||||
if (global::EntitySystem == nullptr) {
|
||||
break;
|
||||
}
|
||||
if (pEvent == nullptr) {
|
||||
break;
|
||||
}
|
||||
NetMessageInfo_t* info = pEvent->GetNetMessageInfo();
|
||||
if (info == nullptr) {
|
||||
break;
|
||||
}
|
||||
const auto isBloodAboutMessage = (info->m_MessageId == TE_WorldDecalId || info->m_MessageId == TE_EffectDispatchId);
|
||||
if (isBloodAboutMessage == false/* && isWeaponAboutMessage == false */) {
|
||||
break;
|
||||
}
|
||||
// lazy fix me
|
||||
for (uint64_t i = 0; i < global::MaxPlayers; i++)
|
||||
{
|
||||
if (!(*(uint64_t*)clients & ((uint64_t)1 << i))) {
|
||||
continue;
|
||||
}
|
||||
|
||||
const auto pEntity = global::EntitySystem->GetBaseEntity(PlayerSlot_to_EntityIndex(i));
|
||||
if (pEntity == nullptr) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (pEntity->IsBasePlayerController() == false) {
|
||||
continue;
|
||||
}
|
||||
const auto player = reinterpret_cast<CCSPlayerController*>(pEntity);
|
||||
|
||||
const auto [isSuccess, playerSetting] = ExtendPlayerManager::GetPlayerSettingBySteamId(player->m_steamID());
|
||||
if (isSuccess == false) {
|
||||
continue;
|
||||
}
|
||||
bool skipTheEvent = false;
|
||||
if (isBloodAboutMessage) {
|
||||
skipTheEvent = (playerSetting.bloodSetting == _ExtendPlayerSetting_Blood::kDisableBloodEffectDispatch && info->m_MessageId == TE_EffectDispatchId) ||
|
||||
(playerSetting.bloodSetting == _ExtendPlayerSetting_Blood::kDisableBloodWorldDecal && info->m_MessageId == TE_WorldDecalId) ||
|
||||
(playerSetting.bloodSetting == _ExtendPlayerSetting_Blood::kDisableBloodWorldDecalAndEffectDispatch);
|
||||
}
|
||||
/*
|
||||
else if (isWeaponAboutMessage)
|
||||
{
|
||||
skipTheEvent = (playerSetting.weaponSetting == _ExtendPlayerSetting_Weapon::kDisablebulletHole);
|
||||
}
|
||||
*/
|
||||
if (skipTheEvent) {
|
||||
*(uint64*)clients &= ~((uint64)1 << i);
|
||||
nClientCount--;
|
||||
}
|
||||
}
|
||||
} while (false);
|
||||
origin_PostEventAbstract(rcx, nSlot, bLocalOnly, nClientCount, clients, pEvent, pData, nSize, bufType);
|
||||
}
|
||||
void __fastcall hook_UTIL_SayText2Filter(
|
||||
IRecipientFilter& filter, CCSPlayerController* pEntity,
|
||||
uint64_t eMessageType, const char* messeageName, const char* param1,
|
||||
const char* param2, const char* param3, const char* param4) {
|
||||
const auto entIndex =
|
||||
PlayerSlot_to_EntityIndex(filter.GetRecipientIndex(0).Get());
|
||||
const auto isHandle = ScriptCallBacks::luCall_onSayText2Filter(
|
||||
entIndex, eMessageType, messeageName, param1, param2, param3, param4);
|
||||
if (isHandle == false) {
|
||||
origin_UTIL_SayText2Filter(filter, pEntity, eMessageType, messeageName,
|
||||
param1, param2, param3, param4);
|
||||
}
|
||||
}
|
||||
// https://github.com/Source2ZE/CS2Fixes/blob/main/src/commands.cpp#L494
|
||||
void __fastcall hook_CCSWeaponBase_Spawn(CBaseEntity* pThis, void* a2) {
|
||||
const char* pszClassName = pThis->m_pEntity()->m_designerName;
|
||||
@@ -36,8 +122,7 @@ void __fastcall hook_CCSWeaponBase_Spawn(CBaseEntity* pThis, void* a2) {
|
||||
for (const auto& weapon : GameWeapons::WeaponMap) {
|
||||
const auto& key = weapon.first;
|
||||
const auto& [fullWeaponName, weaponItemDefIndex] = weapon.second;
|
||||
if (fullWeaponName.find(weaponName) ==
|
||||
std::string::npos) {
|
||||
if (fullWeaponName.find(weaponName) == std::string::npos) {
|
||||
continue;
|
||||
}
|
||||
lookupWeaponSimpleName = key;
|
||||
@@ -50,7 +135,8 @@ void __fastcall hook_CCSWeaponBase_Spawn(CBaseEntity* pThis, void* a2) {
|
||||
const auto [fullWeaponName, weaponiItemDefIndex] =
|
||||
GameWeapons::WeaponMap.at(lookupWeaponSimpleName);
|
||||
|
||||
LOG("Fixing a %s with index = %d and initialized = %d\n", fullWeaponName.c_str(),
|
||||
LOG("Fixing a %s with index = %d and initialized = %d\n",
|
||||
fullWeaponName.c_str(),
|
||||
pWeapon->m_AttributeManager()->m_Item()->m_iItemDefinitionIndex(),
|
||||
pWeapon->m_AttributeManager()->m_Item()->m_bInitialized());
|
||||
|
||||
@@ -85,6 +171,9 @@ void __fastcall hook_GameFrame(void* rcx, bool simulating, bool bFirstTick,
|
||||
if (global::EntitySystem == nullptr) {
|
||||
global::EntitySystem = CGameEntitySystem::GetInstance();
|
||||
}
|
||||
if (global::GlobalVars == nullptr) {
|
||||
global::GlobalVars = GetGameGlobals();
|
||||
}
|
||||
return origin_GameFrame(rcx, simulating, bFirstTick, bLastTick);
|
||||
}
|
||||
void __fastcall hook_StartServer(void* rcx,
|
||||
@@ -139,11 +228,17 @@ void __fastcall hook_Host_Say(void* pEntity, void* args, bool teamonly,
|
||||
char* pos = nullptr;
|
||||
bool blockMsg = false;
|
||||
do {
|
||||
if (theArgs == nullptr || theEntity == nullptr) {
|
||||
if (theArgs == nullptr) {
|
||||
break;
|
||||
}
|
||||
const auto message = std::string(theArgs->GetCommandString());
|
||||
|
||||
if (theEntity == nullptr) {
|
||||
if (events::OnConsoleChat(message) == true) {
|
||||
blockMsg = true;
|
||||
break;
|
||||
}
|
||||
break;
|
||||
}
|
||||
if (events::OnPlayerChat(theEntity, message) == true) {
|
||||
blockMsg = true;
|
||||
break;
|
||||
@@ -244,6 +339,13 @@ auto initMinHook() -> bool {
|
||||
LOG("MH_CreateHook origin_CCSWeaponBase_Spawn\n");
|
||||
break;
|
||||
}
|
||||
if (MH_CreateHook((LPVOID)Offset::FnUTIL_SayText2FilterPtr,
|
||||
&hook_UTIL_SayText2Filter,
|
||||
reinterpret_cast<LPVOID*>(
|
||||
&origin_UTIL_SayText2Filter)) != MH_OK) {
|
||||
LOG("MH_CreateHook origin_UTIL_SayText2Filter\n");
|
||||
break;
|
||||
}
|
||||
// <20><><EFBFBD>ù<EFBFBD><C3B9><EFBFBD>
|
||||
if (MH_EnableHook(MH_ALL_HOOKS) != MH_OK) {
|
||||
LOG("MH_EnableHook \n");
|
||||
@@ -262,7 +364,12 @@ auto initVmtHook() -> bool {
|
||||
VMT_ISource2ServerInterFace =
|
||||
new VMTHook(Memory::read<void*>(reinterpret_cast<uint64_t>(
|
||||
Offset::InterFaces::ISource2ServerInterFace)));
|
||||
VMT_GameEventSystem =
|
||||
new VMTHook(Memory::read<void*>(reinterpret_cast<uint64_t>(
|
||||
Offset::InterFaces::GameEventSystem)));
|
||||
|
||||
origin_PostEventAbstract = reinterpret_cast<PostEventAbstract_t>(
|
||||
VMT_GameEventSystem->Hook(16, hook_PostEventAbstract));
|
||||
original_OnClientConnected = reinterpret_cast<OnClientConnect_t>(
|
||||
VMT_IServerGameClient->Hook(11, hook_OnClientConnected));
|
||||
original_OnClientDisconnect = reinterpret_cast<OnClientDisconnect_t>(
|
||||
@@ -285,8 +392,14 @@ auto init() -> bool {
|
||||
}
|
||||
auto unload() -> void {
|
||||
VMT_IServerGameClient->ClearHooks();
|
||||
VMT_INetworkServerServiceInteFace->ClearHooks();
|
||||
VMT_ISource2ServerInterFace->ClearHooks();
|
||||
VMT_GameEventSystem->ClearHooks();
|
||||
|
||||
delete VMT_IServerGameClient;
|
||||
delete VMT_INetworkServerServiceInteFace;
|
||||
delete VMT_ISource2ServerInterFace;
|
||||
delete VMT_GameEventSystem;
|
||||
|
||||
MH_DisableHook(MH_ALL_HOOKS);
|
||||
MH_RemoveHook(MH_ALL_HOOKS);
|
||||
|
||||
@@ -1,14 +1,28 @@
|
||||
#pragma once
|
||||
#include "head.h"
|
||||
|
||||
typedef bool(__fastcall* FireEventServerSide_t)(CGameEventManager*, IGameEvent*, bool);
|
||||
class IRecipientFilter;
|
||||
typedef bool(__fastcall* FireEventServerSide_t)(CGameEventManager*, IGameEvent*,
|
||||
bool);
|
||||
typedef void(__fastcall* Host_Say_t)(void*, void*, bool, int, const char*);
|
||||
typedef void(__fastcall* OnClientConnect_t)(void*, CPlayerSlot, const char*, uint64_t, const char*, const char*, bool);
|
||||
typedef void(__fastcall* OnClientDisconnect_t)(void*, CPlayerSlot, int, const char*, uint64_t, const char*);
|
||||
typedef void(__fastcall* StartupServer_t)(void*, const GameSessionConfiguration_t&, ISource2WorldSession*, const char*);
|
||||
typedef void(__fastcall* OnClientConnect_t)(void*, CPlayerSlot, const char*,
|
||||
uint64_t, const char*, const char*,
|
||||
bool);
|
||||
typedef void(__fastcall* OnClientDisconnect_t)(void*, CPlayerSlot, int,
|
||||
const char*, uint64_t,
|
||||
const char*);
|
||||
typedef void(__fastcall* StartupServer_t)(void*,
|
||||
const GameSessionConfiguration_t&,
|
||||
ISource2WorldSession*, const char*);
|
||||
typedef void(__fastcall* GameFrame_t)(void*, bool, bool, bool);
|
||||
typedef void(__fastcall* UTIL_SayText2Filter_t)(IRecipientFilter&,
|
||||
CCSPlayerController*, uint64_t,
|
||||
const char*, const char*,
|
||||
const char*, const char*,
|
||||
const char*);
|
||||
//typedef void(__fastcall* PostEventAbstract_t)(void*, CSplitScreenSlot, bool, IRecipientFilter*, INetworkSerializable*, const void*, unsigned long);
|
||||
typedef void(__fastcall* PostEventAbstract_t)(void*, CSplitScreenSlot, bool, int, const uint64_t*, INetworkSerializable*, const void*, unsigned long, NetChannelBufType_t);
|
||||
namespace hooks {
|
||||
extern Host_Say_t original_Host_Say;
|
||||
auto init() -> bool;
|
||||
auto unload() -> void;
|
||||
}
|
||||
extern Host_Say_t original_Host_Say;
|
||||
auto init() -> bool;
|
||||
auto unload() -> void;
|
||||
} // namespace hooks
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
class InterfaceReg;
|
||||
//cancer fix me plz
|
||||
namespace global {
|
||||
extern bool isMetaModInit;
|
||||
extern bool IsMetaModInit;
|
||||
};
|
||||
// Pointer arithmetic utility class.
|
||||
struct UTILPtr {
|
||||
@@ -119,7 +119,7 @@ class CModule {
|
||||
|
||||
private:
|
||||
void InitializeHandle() {
|
||||
if (global::isMetaModInit == false) {
|
||||
if (global::IsMetaModInit == false) {
|
||||
this->m_handle = static_cast<void*>(GetModuleHandleA(this->GetName()));
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -43,7 +43,7 @@ auto CCSPlayerPawn::GetPlayerController() -> CCSPlayerController* {
|
||||
if (!pEntitySystem) {
|
||||
return nullptr;
|
||||
}
|
||||
for (int i = 1; i <= global::MaxPlayers; ++i) {
|
||||
for (int i = 0; i <= global::MaxPlayers; ++i) {
|
||||
CBaseEntity* pEntity = pEntitySystem->GetBaseEntity(i);
|
||||
if (!pEntity) continue;
|
||||
if (pEntity->IsBasePlayerController()) {
|
||||
|
||||
@@ -8,6 +8,8 @@ uint64_t CCSGameRulesInterFacePtr;
|
||||
uint64_t Host_SayPtr;
|
||||
uint64_t Module_tier0;
|
||||
uint64_t MaxPlayerNumsPtr;
|
||||
uint64_t FnUTIL_SayText2FilterPtr;
|
||||
PlayerChangeName_t FnPlayerChangeName;
|
||||
HashFunction_t FnServerHashFunction;
|
||||
StateChanged_t FnStateChanged;
|
||||
NetworkStateChanged_t FnNetworkStateChanged;
|
||||
@@ -32,6 +34,7 @@ CLocalize* ILocalize;
|
||||
INetworkServerService* INetworkServerServiceInteFace;
|
||||
CCSGameRules* CCSGameRulesInterFace;
|
||||
ICvar* IVEngineCvar;
|
||||
IGameEventSystem* GameEventSystem;
|
||||
}; // namespace InterFaces
|
||||
auto SafeDelayInit(void* ctx) -> void {
|
||||
// <20><>Ҫ<EFBFBD><D2AA>Ϸ<EFBFBD><CFB7><EFBFBD>ú<EFBFBD><C3BA><EFBFBD><EFBFBD><EFBFBD>ʼ<EFBFBD><CABC>
|
||||
@@ -67,6 +70,7 @@ auto Init() -> bool {
|
||||
server.FindPattern(pattern_FireEventServerSide).Get(FireEventServerSidePtr);
|
||||
server.FindPattern(pattern_NetworkStateChanged).Get(FnNetworkStateChanged);
|
||||
server.FindPattern(pattern_FnStateChangedPtr).Get(FnStateChanged);
|
||||
server.FindPattern(pattern_PlayerChangeName).Get(FnPlayerChangeName);
|
||||
|
||||
server.FindPattern(pattern_CGameEventManager)
|
||||
.ToAbsolute(3, 0)
|
||||
@@ -74,16 +78,19 @@ auto Init() -> bool {
|
||||
server.FindPattern(pattern_CreateCCSGameRulesInterFacePtr)
|
||||
.ToAbsolute(3, 0)
|
||||
.Get(CCSGameRulesInterFacePtr);
|
||||
server.FindPattern(pattern_FnRespawnPlayerInDeathMatch).Get(FnRespawnPlayerInDeathMatch);
|
||||
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);
|
||||
//server.FindPattern(pattern_ServerHashFunctionPtr).Get(FnServerHashFunction);
|
||||
// server.FindPattern(pattern_ServerHashFunctionPtr).Get(FnServerHashFunction);
|
||||
server.FindPattern(pattern_UTIL_ClientPrintAll).Get(FnUTIL_ClientPrintAll);
|
||||
server.FindPattern(pattern_FnClientPrint).Get(FnClientPrint);
|
||||
|
||||
server.FindPattern(pattern_FnUTIL_SayTextFilter).Get(FnUTIL_SayTextFilter);
|
||||
server.FindPattern(pattern_CCSWeaponBase_Spawn).Get(FnCCSWeaponBase_Spawn);
|
||||
server.FindPattern(pattern_FnUTIL_SayText2FilterPtr)
|
||||
.Get(FnUTIL_SayText2FilterPtr);
|
||||
|
||||
InterFaces::SchemaSystem = reinterpret_cast<CSchemaSystem*>(
|
||||
schemasystem.FindInterface("SchemaSystem_001").Get());
|
||||
@@ -91,8 +98,8 @@ auto Init() -> bool {
|
||||
// engine.FindInterface("GameEventSystemServerV001").Get());
|
||||
InterFaces::ILocalize = reinterpret_cast<CLocalize*>(
|
||||
localize.FindInterface("Localize_001").Get());
|
||||
InterFaces::IVEngineCvar = reinterpret_cast<ICvar*>(
|
||||
tier0.FindInterface("VEngineCvar007").Get());
|
||||
InterFaces::IVEngineCvar =
|
||||
reinterpret_cast<ICvar*>(tier0.FindInterface("VEngineCvar007").Get());
|
||||
|
||||
InterFaces::GameResourceServiceServer =
|
||||
reinterpret_cast<CGameResourceService*>(
|
||||
@@ -102,6 +109,8 @@ auto Init() -> bool {
|
||||
InterFaces::INetworkServerServiceInteFace =
|
||||
reinterpret_cast<INetworkServerService*>(
|
||||
engine.FindInterface("NetworkServerService_001").Get());
|
||||
InterFaces::GameEventSystem = reinterpret_cast<IGameEventSystem*>(
|
||||
engine.FindInterface("GameEventSystemServerV001").Get());
|
||||
InterFaces::IServerGameClient = reinterpret_cast<IServerGameClients*>(
|
||||
server.FindInterface("Source2GameClients001").Get());
|
||||
InterFaces::ISource2ServerInterFace = reinterpret_cast<ISource2Server*>(
|
||||
@@ -124,13 +133,16 @@ auto Init() -> bool {
|
||||
LOG("[huoji]FireEventServerSidePtr : %llx \n", FireEventServerSidePtr);
|
||||
LOG("[huoji]Host_SayPtr : %llx \n", Host_SayPtr);
|
||||
LOG("[huoji]FnNetworkStateChanged : %llx \n", FnNetworkStateChanged);
|
||||
//LOG("[huoji]FnServerHashFunction : %llx \n", FnServerHashFunction);
|
||||
// LOG("[huoji]FnServerHashFunction : %llx \n", FnServerHashFunction);
|
||||
LOG("[huoji]FnStateChanged : %llx \n", FnStateChanged);
|
||||
LOG("[huoji]FnRespawnPlayerInDeathMatch : %llx \n", FnRespawnPlayerInDeathMatch);
|
||||
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);
|
||||
LOG("[huoji]FnCCSWeaponBase_Spawn : %llx \n", FnCCSWeaponBase_Spawn);
|
||||
LOG("[huoji]FnPlayerChangeName : %llx \n", FnPlayerChangeName);
|
||||
LOG("[huoji]FnUTIL_SayText2FilterPtr : %llx \n", FnUTIL_SayText2FilterPtr);
|
||||
|
||||
LOG("[huoji]MaxGlobals : %d \n", global::MaxPlayers);
|
||||
|
||||
@@ -147,8 +159,9 @@ auto Init() -> bool {
|
||||
InterFaces::IVEngineServer);
|
||||
LOG("[huoji]InterFaces::ISource2ServerInterFace : %llx \n",
|
||||
InterFaces::ISource2ServerInterFace);
|
||||
LOG("[huoji]InterFaces::IVEngineCvar : %llx \n",
|
||||
InterFaces::IVEngineCvar);
|
||||
LOG("[huoji]InterFaces::IVEngineCvar : %llx \n", InterFaces::IVEngineCvar);
|
||||
LOG("[huoji]InterFaces::GameEventSystem : %llx \n", InterFaces::GameEventSystem);
|
||||
|
||||
LOG("[huoji] CGameEntitySystem::GetInstance : %llx \n",
|
||||
CGameEntitySystem::GetInstance());
|
||||
LOG("init offset success !\n");
|
||||
@@ -157,7 +170,10 @@ auto Init() -> bool {
|
||||
0, NULL);
|
||||
// LOG("FnServerHashFunction: %llx \n", FnServerHashFunction("here",
|
||||
// sizeof("here") - 1, 0x31415926));
|
||||
return FnCCSWeaponBase_Spawn && FnEntityRemove && FnRespawnPlayerInDeathMatch && FnGiveNamedItem && Host_SayPtr && InterFaces::IVEngineServer &&
|
||||
return FnPlayerChangeName && FnCCSWeaponBase_Spawn && FnEntityRemove &&
|
||||
FnRespawnPlayerInDeathMatch && FnGiveNamedItem && Host_SayPtr &&
|
||||
InterFaces::GameEventSystem &&
|
||||
InterFaces::IVEngineServer &&
|
||||
InterFaces::GameResourceServiceServer &&
|
||||
InterFaces::IServerGameClient && InterFaces::GameEventManager &&
|
||||
InterFaces::SchemaSystem && FireEventServerSidePtr &&
|
||||
|
||||
@@ -6,6 +6,11 @@ class CCSPlayerPawn;
|
||||
class CGameEntitySystem;
|
||||
class CCSPlayerController;
|
||||
class CBaseEntity;
|
||||
class IGameEventSystem;
|
||||
class CSchemaSystem;
|
||||
class CGameResourceService;
|
||||
class CLocalize;
|
||||
class CCSGameRules;
|
||||
typedef uint64_t(__fastcall* HashFunction_t)(const char*, unsigned int,
|
||||
unsigned int);
|
||||
typedef void(__fastcall* StateChanged_t)(void* networkTransmitComponent,
|
||||
@@ -23,13 +28,16 @@ typedef void*(__fastcall* EntityRemove_t)(CGameEntitySystem*, void*, void*,
|
||||
uint64_t);
|
||||
typedef void*(__fastcall* UTIL_SayTextFilter_t)(IRecipientFilter&, const char*,
|
||||
CCSPlayerController*, uint64_t);
|
||||
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* 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;
|
||||
class CCSGameRules;
|
||||
typedef void(__fastcall* PlayerChangeName_t)(CBaseEntity*, char*);
|
||||
|
||||
namespace Offset {
|
||||
namespace InterFaces {
|
||||
extern CSchemaSystem* SchemaSystem;
|
||||
@@ -43,8 +51,17 @@ extern INetworkServerService* INetworkServerServiceInteFace;
|
||||
extern ISource2Server* ISource2ServerInterFace;
|
||||
extern CCSGameRules* CCSGameRulesInterFace;
|
||||
extern ICvar* IVEngineCvar;
|
||||
extern IGameEventSystem* GameEventSystem;
|
||||
}; // namespace InterFaces
|
||||
static const auto pattern_VscriptPath = THE_GAME_SIG("BE 01 ?? ?? ?? 2B D6 74 ?? 3B D6");
|
||||
static const auto pattern_FnUTIL_SayText2FilterPtr = THE_GAME_SIG(
|
||||
"48 89 5C 24 ?? 55 56 57 48 8D 6C 24 ?? 48 81 EC ?? ?? ?? ?? 41 0F B6 F8");
|
||||
static const auto pattern_PlayerChangeName = THE_GAME_SIG(
|
||||
"4C 8B DC 55 56 41 54 49 8D ?? ?? ?? ?? ?? 48 ?? ?? ?? ?? ?? ?? 48 8B F1 "
|
||||
"41 ?? ?? ?? ?? ?? 8B 89 ?? ?? ?? ?? 4C 8B D2 41 3B CC 0F ?? ?? ?? ?? ?? "
|
||||
"4C ?? ?? ?? ?? ?? ?? 4D 85 C0 0F ?? ?? ?? ?? ?? 83 ?? ?? 0F ?? ?? ?? ?? "
|
||||
"?? 8B C1 25 ?? ?? ?? ??");
|
||||
static const auto pattern_VscriptPath =
|
||||
THE_GAME_SIG("BE 01 ?? ?? ?? 2B D6 74 ?? 3B D6");
|
||||
static const auto pattern_CGameEventManager = THE_GAME_SIG(
|
||||
"48 ?? ?? ?? ?? ?? ?? 48 89 ?? ?? ?? 48 89 01 48 8B D9 48 ?? ?? ?? ?? ?? "
|
||||
"?? 48 89 ?? ?? E8 ?? ?? ?? ?? 48 ?? ?? ?? ?? ?? ??");
|
||||
@@ -79,7 +96,9 @@ 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 ?? ?? ?? ?? ??");
|
||||
"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 ?? ?? ?? ?? ?? "
|
||||
@@ -92,15 +111,20 @@ static const auto pattern_FnEntityRemove = THE_GAME_SIG(
|
||||
static const auto pattern_FnUTIL_SayTextFilter = THE_GAME_SIG(
|
||||
"48 89 5C 24 ?? 55 56 57 48 8D 6C 24 ?? 48 81 EC ?? ?? ?? ?? 49 8B D8");
|
||||
static const auto pattern_UTIL_ClientPrintAll = THE_GAME_SIG(
|
||||
"48 89 5C 24 08 48 89 6C 24 10 48 89 74 24 18 57 48 81 EC 70 01 ?? ?? 8B E9");
|
||||
static const auto pattern_FnClientPrint = THE_GAME_SIG(
|
||||
"48 85 C9 0F 84 ?? ?? ?? ?? 48 8B C4 48 89 58 18");
|
||||
static const auto pattern_CCSWeaponBase_Spawn = THE_GAME_SIG("48 89 5C 24 08 48 89 6C 24 18 48 89 74 24 20 57 48 83 EC 30 48 8B DA 48 8B E9 E8 ?? ?? ?? ??");
|
||||
"48 89 5C 24 08 48 89 6C 24 10 48 89 74 24 18 57 48 81 EC 70 01 ?? ?? 8B "
|
||||
"E9");
|
||||
static const auto pattern_FnClientPrint =
|
||||
THE_GAME_SIG("48 85 C9 0F 84 ?? ?? ?? ?? 48 8B C4 48 89 58 18");
|
||||
static const auto pattern_CCSWeaponBase_Spawn = THE_GAME_SIG(
|
||||
"48 89 5C 24 08 48 89 6C 24 18 48 89 74 24 20 57 48 83 EC 30 48 8B DA 48 "
|
||||
"8B E9 E8 ?? ?? ?? ??");
|
||||
extern uint64_t GameResourceServicePtr;
|
||||
extern uint64_t FireEventServerSidePtr;
|
||||
extern uint64_t Module_tier0;
|
||||
extern uint64_t Host_SayPtr;
|
||||
extern uint64_t MaxPlayerNumsPtr;
|
||||
extern uint64_t FnUTIL_SayText2FilterPtr;
|
||||
|
||||
extern HashFunction_t FnServerHashFunction;
|
||||
extern StateChanged_t FnStateChanged;
|
||||
extern NetworkStateChanged_t FnNetworkStateChanged;
|
||||
@@ -111,6 +135,7 @@ extern UTIL_SayTextFilter_t FnUTIL_SayTextFilter;
|
||||
extern UTIL_ClientPrintAll_t FnUTIL_ClientPrintAll;
|
||||
extern ClientPrint_t FnClientPrint;
|
||||
extern CCSWeaponBase_Spawn_t FnCCSWeaponBase_Spawn;
|
||||
extern PlayerChangeName_t FnPlayerChangeName;
|
||||
extern bool InitOffsetSuccess;
|
||||
auto Init() -> bool;
|
||||
}; // namespace Offset
|
||||
|
||||
@@ -1,32 +1,41 @@
|
||||
#include "player_manager.h"
|
||||
namespace ExtendPlayerManager {
|
||||
std::shared_mutex mutex_Table_PlayerSteamIdPlayerSlot;
|
||||
|
||||
std::unordered_map<uint64_t, uint64_t> Table_PlayerSteamIdPlayerSlot;
|
||||
|
||||
std::unordered_map<uint64_t, _ExtendPlayerSetting> Table_PlayerSteamIdPlayerSlot;
|
||||
//GPT error fixed;
|
||||
auto SteamIDStringToUInt64(const std::string& steamID) -> uint64_t {
|
||||
std::istringstream iss(
|
||||
steamID.substr(3, steamID.size() - 4)); // 去掉"[U:"和"]"
|
||||
std::string tmp;
|
||||
uint32_t instance, account_id;
|
||||
|
||||
// 读取 Account Instance
|
||||
std::getline(iss, tmp, ':');
|
||||
instance = std::stoi(tmp);
|
||||
|
||||
// 读取 Account ID
|
||||
std::getline(iss, tmp);
|
||||
account_id = std::stoi(tmp);
|
||||
|
||||
// 计算并返回结果
|
||||
return (uint64_t(account_id) << 1 | instance) + 76561197960265728ULL;
|
||||
std::size_t pos = steamID.find_last_of(":");
|
||||
if (pos != std::string::npos) {
|
||||
uint64_t x = std::stoull(steamID.substr(pos + 1));
|
||||
return 76561197960265728 + x;
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
auto AddSteamIdToPlayerSteamIdWithNameTable(uint64_t SteamId,
|
||||
uint64_t PlayerSlot) -> void {
|
||||
std::unique_lock<std::shared_mutex> lock(
|
||||
mutex_Table_PlayerSteamIdPlayerSlot);
|
||||
Table_PlayerSteamIdPlayerSlot.insert(std::make_pair(SteamId, PlayerSlot));
|
||||
Table_PlayerSteamIdPlayerSlot.insert(std::make_pair(SteamId, _ExtendPlayerSetting{.playerSlot = PlayerSlot }));
|
||||
}
|
||||
auto UpdatePlayerSettingBySteamId(uint64_t SteamId, _ExtendPlayerSetting setting) -> void {
|
||||
std::shared_lock<std::shared_mutex> lock(
|
||||
mutex_Table_PlayerSteamIdPlayerSlot);
|
||||
|
||||
auto it = Table_PlayerSteamIdPlayerSlot.find(SteamId);
|
||||
if (it != Table_PlayerSteamIdPlayerSlot.end()) {
|
||||
it->second.bloodSetting = setting.bloodSetting;
|
||||
it->second.weaponSetting = setting.weaponSetting;
|
||||
}
|
||||
}
|
||||
auto GetPlayerSettingBySteamId(uint64_t SteamId) -> std::pair<bool, _ExtendPlayerSetting> {
|
||||
std::shared_lock<std::shared_mutex> lock(
|
||||
mutex_Table_PlayerSteamIdPlayerSlot);
|
||||
|
||||
auto it = Table_PlayerSteamIdPlayerSlot.find(SteamId);
|
||||
if (it != Table_PlayerSteamIdPlayerSlot.end()) {
|
||||
return { true, it->second };
|
||||
}
|
||||
return { false, {} };
|
||||
}
|
||||
auto GetPlayerSlotBySteamId(uint64_t SteamId) -> uint64_t {
|
||||
std::shared_lock<std::shared_mutex> lock(
|
||||
@@ -34,15 +43,15 @@ auto GetPlayerSlotBySteamId(uint64_t SteamId) -> uint64_t {
|
||||
|
||||
auto it = Table_PlayerSteamIdPlayerSlot.find(SteamId);
|
||||
if (it != Table_PlayerSteamIdPlayerSlot.end()) {
|
||||
return it->second;
|
||||
return it->second.playerSlot;
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
auto GetPlayerSteamIdByPlayerSlot(uint64_t playerSlot) -> uint64_t {
|
||||
std::shared_lock<std::shared_mutex> lock(
|
||||
mutex_Table_PlayerSteamIdPlayerSlot);
|
||||
for (auto& [SteamId, PlayerSlot] : Table_PlayerSteamIdPlayerSlot) {
|
||||
if (PlayerSlot == playerSlot) {
|
||||
for (auto& [SteamId, PlayerSetting] : Table_PlayerSteamIdPlayerSlot) {
|
||||
if (PlayerSetting.playerSlot == playerSlot) {
|
||||
return SteamId;
|
||||
}
|
||||
}
|
||||
@@ -65,7 +74,7 @@ auto GetPlayerByPlayerSlot(uint64_t playerSlot) -> CCSPlayerController* {
|
||||
if (!pEntitySystem) {
|
||||
return nullptr;
|
||||
}
|
||||
for (int i = 1; i <= global::MaxPlayers; ++i) {
|
||||
for (int i = 0; i <= global::MaxPlayers; ++i) {
|
||||
CBaseEntity* pEntity = pEntitySystem->GetBaseEntity(i);
|
||||
if (!pEntity) continue;
|
||||
if (pEntity->IsBasePlayerController()) {
|
||||
|
||||
@@ -1,5 +1,24 @@
|
||||
#pragma once
|
||||
#include "head.h"
|
||||
enum class _ExtendPlayerSetting_Blood
|
||||
{
|
||||
kNone,
|
||||
kDisableBloodWorldDecal,
|
||||
kDisableBloodEffectDispatch,
|
||||
kDisableBloodWorldDecalAndEffectDispatch,
|
||||
kMax
|
||||
};
|
||||
enum class _ExtendPlayerSetting_Weapon
|
||||
{
|
||||
kNone,
|
||||
kDisablebulletHole,
|
||||
kMax
|
||||
};
|
||||
struct _ExtendPlayerSetting {
|
||||
uint64_t playerSlot;
|
||||
_ExtendPlayerSetting_Blood bloodSetting;
|
||||
_ExtendPlayerSetting_Weapon weaponSetting;
|
||||
};
|
||||
namespace ExtendPlayerManager {
|
||||
auto AddSteamIdToPlayerSteamIdWithNameTable(uint64_t SteamId,
|
||||
uint64_t PlayerSlot) -> void;
|
||||
@@ -7,4 +26,6 @@ auto GetPlayerSlotBySteamId(uint64_t SteamId) -> uint64_t;
|
||||
auto SteamIDStringToUInt64(const std::string& steamID) -> uint64_t;
|
||||
auto RemovePlayerSlotBySteamId(uint64_t SteamId) -> void;
|
||||
auto GetPlayerByPlayerSlot(uint64_t playerSlot) -> CCSPlayerController*;
|
||||
auto UpdatePlayerSettingBySteamId(uint64_t SteamId, _ExtendPlayerSetting setting) -> void;
|
||||
auto GetPlayerSettingBySteamId(uint64_t SteamId)->std::pair<bool, _ExtendPlayerSetting>;
|
||||
}; // namespace ExtendPlayerManager
|
||||
|
||||
@@ -54,7 +54,6 @@ auto ExcutePlayerAction(int playerIndex,
|
||||
function(playerController);
|
||||
} while (false);
|
||||
}
|
||||
// <20><><EFBFBD><EFBFBD><EFBFBD>Ƿ<EFBFBD><C7B7><EFBFBD>ֵ<EFBFBD><D6B5><EFBFBD><EFBFBD>,<2C><><EFBFBD><EFBFBD>ֵ<EFBFBD><D6B5><EFBFBD><EFBFBD>Ҫ<EFBFBD>Լ<EFBFBD>push<73><68>stack<63><6B>
|
||||
auto luaApi_ListenToGameEvent(lua_State* luaVm) -> int {
|
||||
const auto eventName = lua_tostring(luaVm, 1);
|
||||
do {
|
||||
@@ -73,7 +72,6 @@ auto luaApi_ListenToGameEvent(lua_State* luaVm) -> int {
|
||||
LOG("luaApi_ListenToGameEvent unknown event name: %s\n", eventName);
|
||||
break;
|
||||
}
|
||||
// <20><><EFBFBD>ص<EFBFBD><D8B5><EFBFBD><EFBFBD>ӵ<EFBFBD>ӳ<EFBFBD><D3B3><EFBFBD><EFBFBD>
|
||||
std::unique_lock lock(ScriptCallBacks::mutex_callbackList);
|
||||
ScriptCallBacks::callbackList[luaVm][callbackType] =
|
||||
luaL_ref(luaVm, LUA_REGISTRYINDEX);
|
||||
@@ -82,7 +80,7 @@ auto luaApi_ListenToGameEvent(lua_State* luaVm) -> int {
|
||||
eventName);
|
||||
} while (false);
|
||||
|
||||
lua_pop(luaVm, 2); // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ջ
|
||||
lua_pop(luaVm, 2);
|
||||
return 0;
|
||||
}
|
||||
auto luaApi_SetPlayerCurrentWeaponAmmo(lua_State* luaVm) -> int {
|
||||
@@ -414,13 +412,14 @@ auto luaApi_GivePlayerWeapon(lua_State* luaVm) -> int {
|
||||
const auto playerIndex = lua_tointeger(luaVm, 1);
|
||||
const auto weaponName = lua_tostring(luaVm, 2);
|
||||
auto isSuccess = false;
|
||||
ExcutePlayerAction(playerIndex, [&](CCSPlayerController* playerController) {
|
||||
if (playerController->m_bPawnIsAlive() == false) {
|
||||
return;
|
||||
}
|
||||
isSuccess =
|
||||
GameWeapons::ParseWeaponCommand(playerController, weaponName);
|
||||
});
|
||||
if (weaponName != nullptr) {
|
||||
ExcutePlayerAction(playerIndex, [&](CCSPlayerController* playerController) {
|
||||
if (playerController->m_bPawnIsAlive() == false) {
|
||||
return;
|
||||
}
|
||||
isSuccess = GameWeapons::ParseWeaponCommand(playerController, weaponName);
|
||||
});
|
||||
}
|
||||
lua_pop(luaVm, 2);
|
||||
lua_pushboolean(luaVm, isSuccess);
|
||||
return 1;
|
||||
@@ -593,7 +592,8 @@ auto luaApi_SendToPlayerChat(lua_State* luaVm) -> int {
|
||||
const auto playerIndex = lua_tointeger(luaVm, 1);
|
||||
const auto hudType = lua_tointeger(luaVm, 2);
|
||||
const auto message = lua_tostring(luaVm, 3);
|
||||
if (hudType >= _HubType::kMax || hudType < _HubType::kNotify) {
|
||||
if (hudType >= static_cast<int>(_HubType::kMax) ||
|
||||
hudType < static_cast<int>(_HubType::kNotify)) {
|
||||
lua_pop(luaVm, 3);
|
||||
return 0;
|
||||
}
|
||||
@@ -608,7 +608,8 @@ auto luaApi_SentToAllPlayerChat(lua_State* luaVm) -> int {
|
||||
// param: playerIndex:int, message:string
|
||||
const auto message = lua_tostring(luaVm, 1);
|
||||
const auto hudType = lua_tointeger(luaVm, 2);
|
||||
if (hudType >= _HubType::kMax || hudType < _HubType::kNotify) {
|
||||
if (hudType >= static_cast<int>(_HubType::kMax) ||
|
||||
hudType < static_cast<int>(_HubType::kNotify)) {
|
||||
lua_pop(luaVm, 3);
|
||||
return 0;
|
||||
}
|
||||
@@ -714,6 +715,57 @@ auto luaApi_RunServerCommand(lua_State* luaVm) -> int {
|
||||
lua_pop(luaVm, 1);
|
||||
return 0;
|
||||
}
|
||||
auto luaApi_RunClientCommand(lua_State* luaVm) -> int {
|
||||
const auto playerIndex = lua_tointeger(luaVm, 1);
|
||||
const auto command = lua_tostring(luaVm, 2);
|
||||
|
||||
ExcutePlayerAction(playerIndex, [&](CCSPlayerController* playerController) {
|
||||
Offset::InterFaces::IVEngineServer->ClientCommand(
|
||||
EntityIndex_to_PlayerSlot(playerIndex), command);
|
||||
});
|
||||
lua_pop(luaVm, 2);
|
||||
return 0;
|
||||
}
|
||||
auto luaApi_SetPlayerName(lua_State* luaVm) -> int {
|
||||
const auto playerIndex = lua_tointeger(luaVm, 1);
|
||||
const auto playerName = lua_tostring(luaVm, 2);
|
||||
|
||||
if (playerName != nullptr) {
|
||||
ExcutePlayerAction(
|
||||
playerIndex, [&](CCSPlayerController* playerController) {
|
||||
Offset::FnPlayerChangeName(playerController->m_hPawn().Get(),
|
||||
(char*)playerName);
|
||||
});
|
||||
}
|
||||
lua_pop(luaVm, 2);
|
||||
return 0;
|
||||
}
|
||||
auto luaApi_SetPlayerNameSlient(lua_State* luaVm) -> int {
|
||||
const auto playerIndex = lua_tointeger(luaVm, 1);
|
||||
const auto playerName = lua_tostring(luaVm, 2);
|
||||
|
||||
if (playerName != nullptr) {
|
||||
ExcutePlayerAction(
|
||||
playerIndex, [&](CCSPlayerController* playerController) {
|
||||
const auto playerNameAddress =
|
||||
&playerController->m_iszPlayerName();
|
||||
const auto playerNameLength = min(strlen(playerName) + 1, 127);
|
||||
memcpy(playerNameAddress, playerName, playerNameLength);
|
||||
});
|
||||
}
|
||||
lua_pop(luaVm, 2);
|
||||
return 0;
|
||||
}
|
||||
auto luaApi_GetPlayerName(lua_State* luaVm) -> int {
|
||||
const auto playerIndex = lua_tointeger(luaVm, 1);
|
||||
std::string playerName;
|
||||
ExcutePlayerAction(playerIndex, [&](CCSPlayerController* playerController) {
|
||||
playerName = &playerController->m_iszPlayerName();
|
||||
});
|
||||
lua_pop(luaVm, 1);
|
||||
lua_pushstring(luaVm, playerName.c_str());
|
||||
return 1;
|
||||
}
|
||||
auto luaApi_GetPlayerSteamId(lua_State* luaVm) -> int {
|
||||
const auto playerIndex = lua_tointeger(luaVm, 1);
|
||||
std::string steamid;
|
||||
@@ -874,15 +926,20 @@ auto luaApi_HttpAsyncGet(lua_State* luaVm) -> int {
|
||||
}
|
||||
auto luaApi_GetConVarString(lua_State* luaVm) -> int {
|
||||
// param: convarObject:int
|
||||
ConVarHandle theConvarHandle{};
|
||||
theConvarHandle.Set(lua_tointeger(luaVm, 1));
|
||||
const auto inputData = lua_tointeger(luaVm, 1);
|
||||
std::string value;
|
||||
if (theConvarHandle.IsValid()) {
|
||||
const auto convarData =
|
||||
Offset::InterFaces::IVEngineCvar->GetConVar(theConvarHandle);
|
||||
const auto address = convarData->values;
|
||||
const auto valueData = reinterpret_cast<char*>(address);
|
||||
value = convarData ? std::string(valueData) : "";
|
||||
if (inputData != NULL) {
|
||||
ConVarHandle theConvarHandle{};
|
||||
theConvarHandle.Set(inputData);
|
||||
if (theConvarHandle.IsValid()) {
|
||||
const auto convarData =
|
||||
Offset::InterFaces::IVEngineCvar->GetConVar(theConvarHandle);
|
||||
if (convarData) {
|
||||
const auto address = convarData->values;
|
||||
const auto valueData = reinterpret_cast<char*>(address);
|
||||
value = valueData ? std::string(valueData) : "";
|
||||
}
|
||||
}
|
||||
}
|
||||
lua_pop(luaVm, 1);
|
||||
lua_pushstring(luaVm, value.c_str());
|
||||
@@ -891,16 +948,19 @@ auto luaApi_GetConVarString(lua_State* luaVm) -> int {
|
||||
}
|
||||
auto luaApi_GetConVarInt(lua_State* luaVm) -> int {
|
||||
// param: convarObject:int
|
||||
ConVarHandle theConvarHandle{};
|
||||
theConvarHandle.Set(lua_tointeger(luaVm, 1));
|
||||
int value = -1;
|
||||
if (theConvarHandle.IsValid()) {
|
||||
const auto convarData =
|
||||
Offset::InterFaces::IVEngineCvar->GetConVar(theConvarHandle);
|
||||
value = reinterpret_cast<int>(convarData->values);
|
||||
const auto inputData = lua_tointeger(luaVm, 1);
|
||||
if (inputData) {
|
||||
ConVarHandle theConvarHandle{};
|
||||
theConvarHandle.Set(inputData);
|
||||
int value = -1;
|
||||
if (theConvarHandle.IsValid()) {
|
||||
const auto convarData =
|
||||
Offset::InterFaces::IVEngineCvar->GetConVar(theConvarHandle);
|
||||
value = convarData ? reinterpret_cast<int>(convarData->values) : -1;
|
||||
}
|
||||
lua_pop(luaVm, 1);
|
||||
lua_pushinteger(luaVm, value);
|
||||
}
|
||||
lua_pop(luaVm, 1);
|
||||
lua_pushinteger(luaVm, value);
|
||||
return 1;
|
||||
}
|
||||
auto luaApi_GetConVarObject(lua_State* luaVm) -> int {
|
||||
@@ -908,8 +968,74 @@ auto luaApi_GetConVarObject(lua_State* luaVm) -> int {
|
||||
const auto name = lua_tostring(luaVm, 1);
|
||||
lua_pushnumber(luaVm,
|
||||
Offset::InterFaces::IVEngineCvar->FindConVar(name).Get());
|
||||
lua_pop(luaVm, 1);
|
||||
|
||||
return 1;
|
||||
}
|
||||
auto luaApi_SetPlayerWeaponEffectStatus(lua_State* luaVm) -> int {
|
||||
const auto playerIndex = lua_tointeger(luaVm, 1);
|
||||
const auto status = lua_tointeger(luaVm, 2);
|
||||
auto playerSlot = EntityIndex_to_PlayerSlot(playerIndex);
|
||||
do
|
||||
{
|
||||
if (status >= static_cast<int>(_ExtendPlayerSetting_Weapon::kMax)
|
||||
|| status < static_cast<int>(_ExtendPlayerSetting_Weapon::kNone)) {
|
||||
break;
|
||||
}
|
||||
if (playerSlot == -1) {
|
||||
break;
|
||||
}
|
||||
auto player = ExtendPlayerManager::GetPlayerByPlayerSlot(playerSlot);
|
||||
if (player == nullptr) {
|
||||
break;
|
||||
}
|
||||
auto [isSuccess, playerSetting] = ExtendPlayerManager::GetPlayerSettingBySteamId(player->m_steamID());
|
||||
if (isSuccess == false) {
|
||||
LOG("can't get player setting, wtf bug?? \n");
|
||||
break;
|
||||
}
|
||||
ExtendPlayerManager::UpdatePlayerSettingBySteamId(player->m_steamID(), _ExtendPlayerSetting{
|
||||
.bloodSetting = playerSetting.bloodSetting,
|
||||
.weaponSetting = static_cast<_ExtendPlayerSetting_Weapon>(status)
|
||||
});
|
||||
|
||||
} while (false);
|
||||
|
||||
lua_pop(luaVm, 2);
|
||||
return 0;
|
||||
}
|
||||
auto luaApi_SetPlayerBloodStatus(lua_State* luaVm) -> int {
|
||||
const auto playerIndex = lua_tointeger(luaVm, 1);
|
||||
const auto status = lua_tointeger(luaVm, 2);
|
||||
auto playerSlot = EntityIndex_to_PlayerSlot(playerIndex);
|
||||
do
|
||||
{
|
||||
if (status >= static_cast<int>(_ExtendPlayerSetting_Blood::kMax)
|
||||
|| status < static_cast<int>(_ExtendPlayerSetting_Blood::kNone)) {
|
||||
break;
|
||||
}
|
||||
if (playerSlot == -1) {
|
||||
break;
|
||||
}
|
||||
auto player = ExtendPlayerManager::GetPlayerByPlayerSlot(playerSlot);
|
||||
if (player == nullptr) {
|
||||
break;
|
||||
}
|
||||
auto [isSuccess, playerSetting] = ExtendPlayerManager::GetPlayerSettingBySteamId(player->m_steamID());
|
||||
if (isSuccess == false) {
|
||||
LOG("can't get player setting, wtf bug?? \n");
|
||||
break;
|
||||
}
|
||||
ExtendPlayerManager::UpdatePlayerSettingBySteamId(player->m_steamID(), _ExtendPlayerSetting {
|
||||
.bloodSetting = static_cast<_ExtendPlayerSetting_Blood>(status),
|
||||
.weaponSetting = playerSetting.weaponSetting
|
||||
});
|
||||
|
||||
} while (false);
|
||||
|
||||
lua_pop(luaVm, 2);
|
||||
return 0;
|
||||
}
|
||||
auto initFunciton(lua_State* luaVm) -> void {
|
||||
lua_register(luaVm, "ListenToGameEvent", luaApi_ListenToGameEvent);
|
||||
lua_register(luaVm, "luaApi_SetPlayerCurrentWeaponAmmo",
|
||||
@@ -964,7 +1090,13 @@ auto initFunciton(lua_State* luaVm) -> void {
|
||||
lua_register(luaVm, "luaApi_GetConVarString", luaApi_GetConVarString);
|
||||
lua_register(luaVm, "luaApi_GetConVarInt", luaApi_GetConVarInt);
|
||||
lua_register(luaVm, "luaApi_GetPlayerSteamId", luaApi_GetPlayerSteamId);
|
||||
|
||||
lua_register(luaVm, "luaApi_RunClientCommand", luaApi_RunClientCommand);
|
||||
lua_register(luaVm, "luaApi_SetPlayerName", luaApi_SetPlayerName);
|
||||
lua_register(luaVm, "luaApi_GetPlayerName", luaApi_GetPlayerName);
|
||||
lua_register(luaVm, "luaApi_SetPlayerNameSlient",
|
||||
luaApi_SetPlayerNameSlient);
|
||||
//lua_register(luaVm, "luaApi_SetPlayerWeaponEffectStatus", luaApi_SetPlayerWeaponEffectStatus);
|
||||
lua_register(luaVm, "luaApi_SetPlayerBloodStatus", luaApi_SetPlayerBloodStatus);
|
||||
// lua_register(luaVm, "luaApi_TeleportPlayer", luaApi_TeleportPlayer);
|
||||
|
||||
luabridge::getGlobalNamespace(luaVm)
|
||||
@@ -979,7 +1111,6 @@ auto initFunciton(lua_State* luaVm) -> void {
|
||||
.addData("weaponIndex", &_luaApi_WeaponInfo::weaponIndex)
|
||||
.endClass()
|
||||
.addFunction("luaApi_GetPlayerWeaponInfo", &luaApi_GetPlayerWeaponInfo);
|
||||
// <20>Ҳ<EFBFBD>ϲ<EFBFBD><CFB2><EFBFBD><EFBFBD>
|
||||
luabridge::getGlobalNamespace(luaVm)
|
||||
.beginClass<_luaApi_WeaponInfo>("WeaponInfo")
|
||||
.addConstructor<void (*)(void)>()
|
||||
|
||||
@@ -16,6 +16,8 @@ std::unordered_map<uint32_t, _CallbackNames> callbackNameWithEnumMap{
|
||||
{hash_32_fnv1a_const("player_hurt"), _CallbackNames::kOnPlayerHurt},
|
||||
{hash_32_fnv1a_const("player_team"), _CallbackNames::kOnPlayerTeamChange},
|
||||
{hash_32_fnv1a_const("http_request"), _CallbackNames::kOnHttpRequest},
|
||||
{hash_32_fnv1a_const("say_text_to_filter"),
|
||||
_CallbackNames::kOnSayText2Filter},
|
||||
|
||||
};
|
||||
auto CallBackNameToEnum(const char* name) -> _CallbackNames {
|
||||
@@ -129,7 +131,7 @@ auto luaCall_onPlayerSpeak(int speaker, int chatType, std::string message)
|
||||
lua_tostring(luaVm, -1));
|
||||
lua_pop(luaVm, 1);
|
||||
}
|
||||
if (lua_isboolean(luaVm, -1)) {
|
||||
if (lua_isboolean(luaVm, -1) && result == false) {
|
||||
result = lua_toboolean(luaVm, -1);
|
||||
}
|
||||
}
|
||||
@@ -229,7 +231,7 @@ auto luaCall_onPlayerTeamChange(int userid, int team, int oldteam,
|
||||
lua_tostring(luaVm, -1));
|
||||
lua_pop(luaVm, 1);
|
||||
}
|
||||
if (lua_isboolean(luaVm, -1)) {
|
||||
if (lua_isboolean(luaVm, -1) && result == false) {
|
||||
result = lua_toboolean(luaVm, -1);
|
||||
}
|
||||
}
|
||||
@@ -255,4 +257,33 @@ auto luaCall_onHttpRequest(std::string url, std::string metaData,
|
||||
}
|
||||
});
|
||||
}
|
||||
auto luCall_onSayText2Filter(int player, uint64_t eMessageType,
|
||||
const char* messeageName, const char* param1,
|
||||
const char* param2, const char* param3,
|
||||
const char* param4) -> bool {
|
||||
bool result = false;
|
||||
ExcuteCallbackInAllLuaVm(_CallbackNames::kOnSayText2Filter,
|
||||
[&](lua_State* luaVm, int refIndex) -> void {
|
||||
lua_rawgeti(luaVm, LUA_REGISTRYINDEX,
|
||||
refIndex);
|
||||
if (lua_isfunction(luaVm, -1)) {
|
||||
lua_pushinteger(luaVm, player);
|
||||
lua_pushinteger(luaVm, eMessageType);
|
||||
lua_pushstring(luaVm, messeageName);
|
||||
lua_pushstring(luaVm, param1);
|
||||
lua_pushstring(luaVm, param2);
|
||||
lua_pushstring(luaVm, param3);
|
||||
lua_pushstring(luaVm, param4);
|
||||
if (lua_pcall(luaVm, 7, 1, 0) != LUA_OK) {
|
||||
LOG("Error calling Lua callback: %s\n",
|
||||
lua_tostring(luaVm, -1));
|
||||
lua_pop(luaVm, 1);
|
||||
}
|
||||
if (lua_isboolean(luaVm, -1) && result == false) {
|
||||
result = lua_toboolean(luaVm, -1);
|
||||
}
|
||||
}
|
||||
});
|
||||
return result;
|
||||
}
|
||||
} // namespace ScriptCallBacks
|
||||
|
||||
@@ -13,7 +13,8 @@ enum class _CallbackNames {
|
||||
kOnRoundEnd,
|
||||
kOnPlayerHurt,
|
||||
kOnPlayerTeamChange,
|
||||
kOnHttpRequest
|
||||
kOnHttpRequest,
|
||||
kOnSayText2Filter
|
||||
};
|
||||
extern std::unordered_map<lua_State*, std::unordered_map<_CallbackNames, int>>
|
||||
callbackList;
|
||||
@@ -40,4 +41,8 @@ auto luaCall_onPlayerTeamChange(int userid, int team, int oldteam,
|
||||
-> bool;
|
||||
auto luaCall_onHttpRequest(std::string url, std::string metaData,
|
||||
std::string respon, int statusCode) -> void;
|
||||
auto luCall_onSayText2Filter(int player, uint64_t eMessageType,
|
||||
const char* messeageName, const char* param1,
|
||||
const char* param2, const char* param3,
|
||||
const char* param4) -> bool;
|
||||
} // namespace ScriptCallBacks
|
||||
|
||||
@@ -161,6 +161,7 @@ class EconControlPointInfo_t;
|
||||
struct EconItemInfo_t {
|
||||
|
||||
};
|
||||
class bf_read;
|
||||
class bf_write;
|
||||
typedef uint32_t SpawnGroupHandle_t;
|
||||
typedef uint32_t SwapChainHandle_t;
|
||||
|
||||
149
csgo2/sdk/public/igameeventsystem.h
Normal file
149
csgo2/sdk/public/igameeventsystem.h
Normal file
@@ -0,0 +1,149 @@
|
||||
#include "../sdk.h"
|
||||
class IAppSystem;
|
||||
class CUtlSlot;
|
||||
class CUtlAbstractDelegate;
|
||||
class CBaseHandle;
|
||||
typedef uint16 NetworkMessageId;
|
||||
typedef uint8 NetworkGroupId;
|
||||
typedef uint NetworkCategoryId;
|
||||
|
||||
enum NetChannelBufType_t
|
||||
{
|
||||
BUF_RELIABLE = 0,
|
||||
BUF_UNRELIABLE,
|
||||
BUF_VOICE,
|
||||
};
|
||||
enum NetworkValidationMode_t
|
||||
{
|
||||
kFuckOffAss_NetworkValidationMode
|
||||
};
|
||||
class IProtobufBinding
|
||||
{
|
||||
public:
|
||||
virtual const char* GetName() = 0;
|
||||
virtual int GetSize() = 0;
|
||||
|
||||
virtual const char* ToString(const void* pData, CUtlString& sResult) = 0;
|
||||
|
||||
virtual const char* GetGroup() = 0;
|
||||
virtual Color GetGroupColor() = 0;
|
||||
virtual NetChannelBufType_t GetBufType() = 0;
|
||||
|
||||
virtual bool ReadFromBuffer(void* pData, bf_read& pBuf) = 0;
|
||||
virtual bool WriteToBuffer(const void* pData, bf_write& pBuf) = 0;
|
||||
|
||||
virtual void* AllocateMessage() = 0;
|
||||
virtual void DeallocateMessage(void* pMsg) = 0;
|
||||
virtual void* AllocateAndCopyConstructNetMessage(const void* pOther) = 0;
|
||||
|
||||
virtual bool OkToRedispatch() = 0;
|
||||
virtual void Copy(const void* pFrom, void* pTo) = 0;
|
||||
virtual bool unk001() = 0;
|
||||
};
|
||||
|
||||
struct NetMessageInfo_t
|
||||
{
|
||||
int m_nCategories;
|
||||
IProtobufBinding* m_pBinding;
|
||||
CUtlString m_szGroup;
|
||||
NetworkMessageId m_MessageId;
|
||||
NetworkGroupId m_GroupId;
|
||||
|
||||
// (1 << 0) - FLAG_RELIABLE
|
||||
// (1 << 6) - FLAG_AUTOASSIGNEDID
|
||||
// (1 << 7) - FLAG_UNK001
|
||||
uint8 m_nFlags;
|
||||
|
||||
int m_unk001;
|
||||
int m_unk002;
|
||||
bool m_bOkayToRedispatch;
|
||||
};
|
||||
enum NetworkSerializationMode_t
|
||||
{
|
||||
NET_SERIALIZATION_MODE_0 = 0x0,
|
||||
NET_SERIALIZATION_MODE_1 = 0x1,
|
||||
NET_SERIALIZATION_MODE_COUNT = 0x2,
|
||||
NET_SERIALIZATION_MODE_DEFAULT = 0x0,
|
||||
NET_SERIALIZATION_MODE_SERVER = 0x0,
|
||||
NET_SERIALIZATION_MODE_CLIENT = 0x1,
|
||||
};
|
||||
enum ETEProtobufIds : int {
|
||||
TE_EffectDispatchId = 400,
|
||||
TE_ArmorRicochetId = 401,
|
||||
TE_BeamEntPointId = 402,
|
||||
TE_BeamEntsId = 403,
|
||||
TE_BeamPointsId = 404,
|
||||
TE_BeamRingId = 405,
|
||||
TE_BSPDecalId = 407,
|
||||
TE_BubblesId = 408,
|
||||
TE_BubbleTrailId = 409,
|
||||
TE_DecalId = 410,
|
||||
TE_WorldDecalId = 411,
|
||||
TE_EnergySplashId = 412,
|
||||
TE_FizzId = 413,
|
||||
TE_ShatterSurfaceId = 414,
|
||||
TE_GlowSpriteId = 415,
|
||||
TE_ImpactId = 416,
|
||||
TE_MuzzleFlashId = 417,
|
||||
TE_BloodStreamId = 418,
|
||||
TE_ExplosionId = 419,
|
||||
TE_DustId = 420,
|
||||
TE_LargeFunnelId = 421,
|
||||
TE_SparksId = 422,
|
||||
TE_PhysicsPropId = 423,
|
||||
TE_PlayerDecalId = 424,
|
||||
TE_ProjectedDecalId = 425,
|
||||
TE_SmokeId = 426,
|
||||
TE_BulletHold = 452
|
||||
};
|
||||
class INetworkSerializable
|
||||
{
|
||||
public:
|
||||
virtual ~INetworkSerializable() = 0;
|
||||
|
||||
virtual const char *GetUnscopedName() = 0;
|
||||
virtual NetMessageInfo_t *GetNetMessageInfo() = 0;
|
||||
|
||||
virtual void SetMessageId(unsigned short nMessageId) = 0;
|
||||
|
||||
virtual void AddCategoryMask(int nMask, bool) = 0;
|
||||
|
||||
virtual void SwitchMode(NetworkValidationMode_t nMode) = 0;
|
||||
|
||||
virtual void *AllocateMessage() = 0;
|
||||
virtual void DeallocateMessage(void *pMsg) = 0;
|
||||
virtual void *AllocateAndCopyConstructNetMessage(void const *pOther) = 0;
|
||||
|
||||
virtual bool Serialize(bf_write &pBuf, void const *pData, NetworkSerializationMode_t unused) = 0;
|
||||
virtual bool Unserialize(bf_read &pBuf, void *pData, NetworkSerializationMode_t unused) = 0;
|
||||
};
|
||||
|
||||
class IGameEventSystem : public IAppSystem
|
||||
{
|
||||
public:
|
||||
//vmt index 11
|
||||
virtual void RegisterGameEvent(INetworkSerializable * pEvent) = 0;
|
||||
|
||||
virtual void RegisterGameEventHandlerAbstract(CUtlSlot* nSlot, const CUtlAbstractDelegate& delegate, INetworkSerializable* pEvent) = 0;
|
||||
virtual void UnregisterGameEventHandlerAbstract(CUtlSlot* nSlot, const CUtlAbstractDelegate& delegate, INetworkSerializable* pEvent) = 0;
|
||||
|
||||
// Providing nSize has no effect and is unused.
|
||||
virtual void PostEventAbstract_Local(CSplitScreenSlot nSlot, INetworkSerializable* pEvent, const void* pData, unsigned long nSize) = 0;
|
||||
|
||||
// Providing nSlot as -1 would select 0nth slot.
|
||||
// clients pointer is a masked uint64 value where (client index - 1) is mapped to each bit.
|
||||
// Providing nClientCount as -1 and clients pointer as NULL would post event to all available clients.
|
||||
// Providing nSize has no effect and is unused.
|
||||
virtual void PostEventAbstract(CSplitScreenSlot nSlot, bool bLocalOnly, int nClientCount, const uint64* clients,
|
||||
INetworkSerializable* pEvent, const void* pData, unsigned long nSize, NetChannelBufType_t bufType) = 0;
|
||||
virtual void PostEventAbstract(CSplitScreenSlot nSlot, bool bLocalOnly, IRecipientFilter* pFilter,
|
||||
INetworkSerializable* pEvent, const void* pData, unsigned long nSize) = 0;
|
||||
|
||||
// Posts the event to all clients, even tho the function name tells otherwise
|
||||
// Providing nSize has no effect and is unused.
|
||||
virtual void PostEntityEventAbstract(const CBaseHandle& hndl, INetworkSerializable* pEvent, const void* pData, unsigned long nSize, NetChannelBufType_t bufType) = 0;
|
||||
|
||||
virtual void ProcessQueuedEvents() = 0;
|
||||
virtual int GetEventSource() const = 0;
|
||||
virtual void PurgeQueuedEvents() = 0;
|
||||
};
|
||||
@@ -16,6 +16,7 @@
|
||||
#define INCORRECT_PATH_SEPARATOR '/'
|
||||
#define INCORRECT_PATH_SEPARATOR_S "/"
|
||||
#define FMTFUNCTION(a, b)
|
||||
#define DLL_CLASS_IMPORT __declspec( dllimport )
|
||||
|
||||
enum EStringConvertErrorPolicy {
|
||||
_STRINGCONVERTFLAG_SKIP = 1,
|
||||
@@ -112,3 +113,4 @@ inline T AlignValue(T val, uintptr_t alignment) {
|
||||
#include "gameevent/IGameEvent.h"
|
||||
#include "tier1/bufferstring.h"
|
||||
#include "public/eiface.h"
|
||||
#include "public/igameeventsystem.h"
|
||||
|
||||
@@ -116,195 +116,15 @@ CUtlString::CUtlString(const CUtlString& string)
|
||||
{
|
||||
Set(string.Get());
|
||||
}
|
||||
|
||||
// Attaches the string to external memory. Useful for avoiding a copy
|
||||
CUtlString::CUtlString(void* pMemory, int nSizeInBytes, int nInitialLength) : m_Storage(pMemory, nSizeInBytes, nInitialLength)
|
||||
inline const char* CUtlString::Get() const
|
||||
{
|
||||
}
|
||||
|
||||
CUtlString::CUtlString(const void* pMemory, int nSizeInBytes) : m_Storage(pMemory, nSizeInBytes)
|
||||
{
|
||||
}
|
||||
|
||||
void CUtlString::Set(const char *pValue)
|
||||
{
|
||||
_UtlString_assert(!m_Storage.IsReadOnly());
|
||||
int nLen = pValue ? strlen(pValue) + 1 : 0;
|
||||
m_Storage.Set(pValue, nLen);
|
||||
}
|
||||
|
||||
// Returns strlen
|
||||
int CUtlString::Length() const
|
||||
{
|
||||
return m_Storage.Length() ? m_Storage.Length() - 1 : 0;
|
||||
}
|
||||
|
||||
// Sets the length (used to serialize into the buffer )
|
||||
void CUtlString::SetLength(int nLen)
|
||||
{
|
||||
_UtlString_assert(!m_Storage.IsReadOnly());
|
||||
|
||||
// Add 1 to account for the NULL
|
||||
m_Storage.SetLength(nLen > 0 ? nLen + 1 : 0);
|
||||
}
|
||||
|
||||
const char *CUtlString::Get() const
|
||||
{
|
||||
if(m_Storage.Length() == 0) {
|
||||
if (!m_pString)
|
||||
{
|
||||
return "";
|
||||
}
|
||||
|
||||
return reinterpret_cast<const char*>(m_Storage.Get());
|
||||
return m_pString;
|
||||
}
|
||||
|
||||
// Converts to c-strings
|
||||
CUtlString::operator const char*() const
|
||||
inline void CUtlString::Set(const char* pValue)
|
||||
{
|
||||
return Get();
|
||||
}
|
||||
|
||||
char *CUtlString::Get()
|
||||
{
|
||||
_UtlString_assert(!m_Storage.IsReadOnly());
|
||||
|
||||
if(m_Storage.Length() == 0) {
|
||||
// In general, we optimise away small mallocs for empty strings
|
||||
// but if you ask for the non-const bytes, they must be writable
|
||||
// so we can't return "" here, like we do for the const version - jd
|
||||
m_Storage.SetLength(1);
|
||||
m_Storage[0] = '\0';
|
||||
}
|
||||
|
||||
return reinterpret_cast<char*>(m_Storage.Get());
|
||||
}
|
||||
|
||||
CUtlString &CUtlString::operator=(const CUtlString &src)
|
||||
{
|
||||
_UtlString_assert(!m_Storage.IsReadOnly());
|
||||
m_Storage = src.m_Storage;
|
||||
return *this;
|
||||
}
|
||||
|
||||
CUtlString &CUtlString::operator=(const char *src)
|
||||
{
|
||||
_UtlString_assert(!m_Storage.IsReadOnly());
|
||||
Set(src);
|
||||
return *this;
|
||||
}
|
||||
|
||||
bool CUtlString::operator==(const CUtlString &src) const
|
||||
{
|
||||
return m_Storage == src.m_Storage;
|
||||
}
|
||||
|
||||
bool CUtlString::operator==(const char *src) const
|
||||
{
|
||||
return (strcmp(Get(), src) == 0);
|
||||
}
|
||||
|
||||
CUtlString &CUtlString::operator+=(const CUtlString &rhs)
|
||||
{
|
||||
_UtlString_assert(!m_Storage.IsReadOnly());
|
||||
|
||||
const int lhsLength(Length());
|
||||
const int rhsLength(rhs.Length());
|
||||
const int requestedLength(lhsLength + rhsLength);
|
||||
|
||||
SetLength(requestedLength);
|
||||
const int allocatedLength(Length());
|
||||
const int copyLength(allocatedLength - lhsLength < rhsLength ? allocatedLength - lhsLength : rhsLength);
|
||||
memcpy(Get() + lhsLength, rhs.Get(), copyLength);
|
||||
m_Storage[allocatedLength] = '\0';
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
CUtlString &CUtlString::operator+=(const char *rhs)
|
||||
{
|
||||
_UtlString_assert(!m_Storage.IsReadOnly());
|
||||
|
||||
const int lhsLength(Length());
|
||||
const int rhsLength(strlen(rhs));
|
||||
const int requestedLength(lhsLength + rhsLength);
|
||||
|
||||
SetLength(requestedLength);
|
||||
const int allocatedLength(Length());
|
||||
const int copyLength(allocatedLength - lhsLength < rhsLength ? allocatedLength - lhsLength : rhsLength);
|
||||
memcpy(Get() + lhsLength, rhs, copyLength);
|
||||
m_Storage[allocatedLength] = '\0';
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
CUtlString &CUtlString::operator+=(char c)
|
||||
{
|
||||
_UtlString_assert(!m_Storage.IsReadOnly());
|
||||
|
||||
int nLength = Length();
|
||||
SetLength(nLength + 1);
|
||||
m_Storage[nLength] = c;
|
||||
m_Storage[nLength + 1] = '\0';
|
||||
return *this;
|
||||
}
|
||||
|
||||
CUtlString &CUtlString::operator+=(int rhs)
|
||||
{
|
||||
_UtlString_assert(!m_Storage.IsReadOnly());
|
||||
_UtlString_assert(sizeof(rhs) == 4);
|
||||
|
||||
char tmpBuf[12]; // Sufficient for a signed 32 bit integer [ -2147483648 to +2147483647 ]
|
||||
snprintf(tmpBuf, sizeof(tmpBuf), "%d", rhs);
|
||||
tmpBuf[sizeof(tmpBuf) - 1] = '\0';
|
||||
|
||||
return operator+=(tmpBuf);
|
||||
}
|
||||
|
||||
CUtlString &CUtlString::operator+=(double rhs)
|
||||
{
|
||||
_UtlString_assert(!m_Storage.IsReadOnly());
|
||||
|
||||
char tmpBuf[256]; // How big can doubles be??? Dunno.
|
||||
snprintf(tmpBuf, sizeof(tmpBuf), "%lg", rhs);
|
||||
tmpBuf[sizeof(tmpBuf) - 1] = '\0';
|
||||
|
||||
return operator+=(tmpBuf);
|
||||
}
|
||||
|
||||
int CUtlString::Format(const char *pFormat, ...)
|
||||
{
|
||||
_UtlString_assert(!m_Storage.IsReadOnly());
|
||||
|
||||
char tmpBuf[4096]; //< Nice big 4k buffer, as much memory as my first computer had, a Radio Shack Color Computer
|
||||
|
||||
va_list marker;
|
||||
|
||||
va_start(marker, pFormat);
|
||||
int len = _vsnprintf_s(tmpBuf, 4096, sizeof(tmpBuf) - 1, pFormat, marker);
|
||||
va_end(marker);
|
||||
|
||||
// Len < 0 represents an overflow
|
||||
if(len < 0) {
|
||||
len = sizeof(tmpBuf) - 1;
|
||||
tmpBuf[sizeof(tmpBuf) - 1] = 0;
|
||||
}
|
||||
|
||||
Set(tmpBuf);
|
||||
|
||||
return len;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Strips the trailing slash
|
||||
//-----------------------------------------------------------------------------
|
||||
void CUtlString::StripTrailingSlash()
|
||||
{
|
||||
if(IsEmpty())
|
||||
return;
|
||||
|
||||
int nLastChar = Length() - 1;
|
||||
char c = m_Storage[nLastChar];
|
||||
if(c == '\\' || c == '/') {
|
||||
m_Storage[nLastChar] = 0;
|
||||
m_Storage.SetLength(m_Storage.Length() - 1);
|
||||
}
|
||||
}
|
||||
@@ -181,7 +181,8 @@ public:
|
||||
static int __cdecl SortCaseSensitive(const CUtlString *pString1, const CUtlString *pString2);
|
||||
|
||||
private:
|
||||
CUtlBinaryBlock m_Storage;
|
||||
//CUtlBinaryBlock m_Storage;
|
||||
char* m_pString;
|
||||
};
|
||||
|
||||
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
#pragma once
|
||||
#include "../sdk.h"
|
||||
#define DLL_CLASS_IMPORT __declspec( dllimport )
|
||||
|
||||
class CFormatStringElement;
|
||||
class IFormatOutputStream;
|
||||
|
||||
@@ -38,7 +38,7 @@ auto SentChatToClient(CCSPlayerController* player, _HubType hubtype, const char*
|
||||
|
||||
va_end(args);
|
||||
|
||||
Offset::FnClientPrint(player, hubtype, buf, nullptr, nullptr, nullptr, nullptr);
|
||||
Offset::FnClientPrint(player, static_cast<int>(hubtype), buf, nullptr, nullptr, nullptr, nullptr);
|
||||
}
|
||||
auto SendConsoleChat(_HubType hubtype, const char* msg, ...) -> void
|
||||
{
|
||||
@@ -50,6 +50,6 @@ auto SendConsoleChat(_HubType hubtype, const char* msg, ...) -> void
|
||||
|
||||
va_end(args);
|
||||
|
||||
Offset::FnUTIL_ClientPrintAll(hubtype, buf, nullptr, nullptr, nullptr, nullptr);
|
||||
Offset::FnUTIL_ClientPrintAll(static_cast<int>(hubtype), buf, nullptr, nullptr, nullptr, nullptr);
|
||||
}
|
||||
}; // namespace SdkTools
|
||||
|
||||
@@ -8,8 +8,8 @@ inline int EntityIndex_to_PlayerSlot(int EntityIndex) {
|
||||
#define HUD_PRINTCONSOLE 2
|
||||
#define HUD_PRINTTALK 3
|
||||
#define HUD_PRINTCENTER 4
|
||||
enum _ChatType { kTeam, kAll };
|
||||
enum _HubType { kNotify = 1, kConsole, kTalk, kCenter, kMax };
|
||||
enum class _ChatType { kTeam, kAll, kConsole };
|
||||
enum class _HubType { kNotify = 1, kConsole, kTalk, kCenter, kMax };
|
||||
|
||||
namespace SdkTools {
|
||||
auto ProcessChatString(const std::string& input)
|
||||
|
||||
13
readme.md
13
readme.md
@@ -60,3 +60,16 @@ example:
|
||||
### Test Plugin
|
||||
api and plugin example:
|
||||
https://github.com/huoji120/cs2_funny_trash_plugin
|
||||
|
||||
### Q&A
|
||||
Summarize some common issues:
|
||||
1. Q: why not use metamod?
|
||||
A: At the time of writing this project, there was no metamod yet.
|
||||
2. Q: Why is there no skin changer?
|
||||
A: no such content will be considered because harm the interests of the game company
|
||||
3. Q: Why not continue updating like add linux support && more api && convar?
|
||||
A: I have my own job in real-life and I do not have much time to maintain this project. I will only maintain it when I am free. If you want to continue to maintain it, you can fork it and continue to maintain it.
|
||||
4. Q: I would like to hire you for a fee
|
||||
A: It is impossible for accept. I am very satisfied with my real-life job and doing it is just a hobby
|
||||
5. Q: THIS PROJECT HAVE BUG!
|
||||
A: Yes i Know it and i fix it, BUT I WOULD NOT BE PUBLIC.Because everyone enters the tavern without paying, they only copy and paste the code and sell it.
|
||||
|
||||
Reference in New Issue
Block a user