diff --git a/csgo2/events.cpp b/csgo2/events.cpp index 0f818c9..146609e 100644 --- a/csgo2/events.cpp +++ b/csgo2/events.cpp @@ -9,7 +9,7 @@ auto OnPlayerHurtEvent(IGameEvent* event) -> void { */ UnkGameEventStruct_t userIdNameParams{"userid"}; UnkGameEventStruct_t attackerNameParams{"attacker"}; - UnkGameEventStruct_t healthNameParams{"health"}; + UnkGameEventStruct_t healthNameParams{0}; UnkGameEventStruct_t armorNameParams{0}; UnkGameEventStruct_t weaponNameParams{0}; UnkGameEventStruct_t dmg_healthNameParams{0}; @@ -23,9 +23,9 @@ auto OnPlayerHurtEvent(IGameEvent* event) -> void { static const auto dmg_armorStr = "dmg_armor"; static const auto hitgroupStr = "hitgroup"; - // healthNameParams.m_Unk = Offset::FnServerHashFunction( - // healthStr, sizeof healthStr, SERVER_HASH_FUCNTION_KEY); - // healthNameParams.m_Key = healthStr; + healthNameParams.m_Unk = Offset::FnServerHashFunction( + healthStr, sizeof healthStr, SERVER_HASH_FUCNTION_KEY); + healthNameParams.m_Key = healthStr; armorNameParams.m_Unk = Offset::FnServerHashFunction( armorStr, sizeof armorStr, SERVER_HASH_FUCNTION_KEY); diff --git a/csgo2/native_sdk.cpp b/csgo2/native_sdk.cpp index 68ac29b..c605ef7 100644 --- a/csgo2/native_sdk.cpp +++ b/csgo2/native_sdk.cpp @@ -100,8 +100,7 @@ static bool InitSchemaFieldsForClass(SchemaTableMap_t* tableMap, for (int i = 0; i < fieldsSize; ++i) { SchemaClassFieldData_t& field = pFields[i]; - // LOG("%s::%s found at -> 0x%X - %llx\n", className, field.m_name, - // field.m_offset, &field); + LOG("%s::%s found at -> 0x%X - %llx\n", className, field.m_name, field.m_offset, &field); keyValueMap->Insert(hash_32_fnv1a_const(field.m_name), {field.m_offset, IsFieldNetworked(field)}); diff --git a/csgo2/native_sdk.h b/csgo2/native_sdk.h index 248b0c3..3a81c94 100644 --- a/csgo2/native_sdk.h +++ b/csgo2/native_sdk.h @@ -85,7 +85,7 @@ extern auto SetStateChanged(Z_CBaseEntity* pEntity, int offset) -> void; static constexpr auto prop_hash = hash_32_fnv1a_const(#varName); \ \ static const auto m_key = \ - schema::GetOffset(ThisClass, datatable_hash, #varName, prop_hash); \ + schema::GetOffset(datatableName, datatable_hash, #varName, prop_hash); \ \ return *reinterpret_cast>( \ (uintptr_t)(this) + m_key.offset + extra_offset); \ @@ -96,7 +96,7 @@ extern auto SetStateChanged(Z_CBaseEntity* pEntity, int offset) -> void; static constexpr auto prop_hash = hash_32_fnv1a_const(#varName); \ \ static const auto m_key = \ - schema::GetOffset(ThisClass, datatable_hash, #varName, prop_hash); \ + schema::GetOffset(datatableName, datatable_hash, #varName, prop_hash); \ \ static const auto m_chain = schema::FindChainOffset(ThisClass); \ \ @@ -111,7 +111,7 @@ extern auto SetStateChanged(Z_CBaseEntity* pEntity, int offset) -> void; middle of a class will need to have their this pointer \ corrected by the offset .*/ \ LOG("Attempting to call SetStateChanged on on %s::%s\n", \ - ThisClass, #varName); \ + datatableName, #varName); \ if (!OffsetIsStruct) \ SetStateChanged((Z_CBaseEntity*)this, \ m_key.offset + extra_offset); \ @@ -380,13 +380,7 @@ class CGlowProperty { SCHEMA_FIELD(bool, m_bFlashing) SCHEMA_FIELD(bool, m_bGlowing) }; -class CBaseModelEntity { - public: - DECLARE_CLASS(CBaseModelEntity); - SCHEMA_FIELD(CCollisionProperty, m_Collision) - SCHEMA_FIELD(CGlowProperty, m_Glow) -}; class CBaseEntity : public CEntityInstance { public: DECLARE_CLASS(CBaseEntity); @@ -396,11 +390,17 @@ class CBaseEntity : public CEntityInstance { // SCHEMA_FIELD(Vector, m_vecBaseVelocity) SCHEMA_FIELD(CCollisionProperty*, m_pCollision) SCHEMA_FIELD(Vector, m_vecBaseVelocity) - SCHEMA_FIELD_EX(CGlowProperty, "CBaseModelEntity", m_Glow); + //SCHEMA_FIELD_EX(CGlowProperty, "CBaseModelEntity", m_Glow); auto IsBasePlayerController() -> bool; auto SpawnClientEntity() -> void; }; +class CBaseModelEntity : public CBaseEntity { +public: + DECLARE_CLASS(CBaseModelEntity); + SCHEMA_FIELD(CCollisionProperty, m_Collision) + SCHEMA_FIELD(CGlowProperty, m_Glow) +}; class CBasePlayerController : public CBaseEntity { public: DECLARE_CLASS(CBasePlayerController); diff --git a/csgo2/script_apis.cpp b/csgo2/script_apis.cpp index 2d63416..ce0dcc6 100644 --- a/csgo2/script_apis.cpp +++ b/csgo2/script_apis.cpp @@ -660,7 +660,7 @@ auto luaApi_SetPlayerGlowColor(lua_State* luaVm) -> int { const auto b = lua_tonumber(luaVm, 4); ExcutePlayerAction(playerIndex, [&](CCSPlayerController* playerController) { playerController->m_hPawn() - .Get() + .Get() ->m_Glow() .m_glowColorOverride(Color(r, g, b, 230)); }); @@ -672,14 +672,24 @@ auto luaApi_SetPlayerGlowEnable(lua_State* luaVm) -> int { const auto playerIndex = lua_tointeger(luaVm, 1); const auto isEnable = lua_toboolean(luaVm, 2); ExcutePlayerAction(playerIndex, [&](CCSPlayerController* playerController) { - playerController->m_hPawn().Get()->m_Glow().m_bGlowing( + LOG("glow set %d to %d \n", playerController->m_hPawn().Get()->m_Glow().m_bGlowing(), isEnable); + playerController->m_hPawn().Get()->m_Glow().m_bGlowing( isEnable); - playerController->m_hPawn().Get()->m_Glow().m_iGlowType( - 3); + playerController->m_hPawn().Get()->m_Glow().m_iGlowType(3); + playerController->m_hPawn() + .Get() + ->m_Glow() + .m_glowColorOverride(Color(201, 0, 118, 230)); }); lua_pop(luaVm, 2); return 0; } +auto luaApi_RunServerCommand(lua_State* luaVm) -> int { + const auto command = lua_tostring(luaVm, 1); + Offset::InterFaces::IVEngineServer->ServerCommand(command); + lua_pop(luaVm, 1); + return 0; +} auto luaApi_GetAllPlayerIndex(lua_State* luaVm) -> int { // param: playerIndex:int, style:int lua_newtable(luaVm); @@ -693,10 +703,10 @@ auto luaApi_GetAllPlayerIndex(lua_State* luaVm) -> int { auto player = EntitySystem->GetBaseEntity(i); if (player == nullptr) { - break; + continue; } if (player->IsBasePlayerController() == false) { - break; + continue; } lua_pushinteger(luaVm, player->GetRefEHandle().GetEntryIndex()); lua_rawseti(luaVm, -2, index++); @@ -704,6 +714,7 @@ auto luaApi_GetAllPlayerIndex(lua_State* luaVm) -> int { } while (false); return 1; } + auto initFunciton(lua_State* luaVm) -> void { lua_register(luaVm, "ListenToGameEvent", luaApi_ListenToGameEvent); lua_register(luaVm, "luaApi_SetPlayerCurrentWeaponAmmo", @@ -745,6 +756,7 @@ auto initFunciton(lua_State* luaVm) -> void { luaApi_SetPlayerGlowEnable); lua_register(luaVm, "luaApi_SetPlayerGlowColor", luaApi_SetPlayerGlowColor); lua_register(luaVm, "luaApi_GetAllPlayerIndex", luaApi_GetAllPlayerIndex); + lua_register(luaVm, "luaApi_RunServerCommand", luaApi_RunServerCommand); luabridge::getGlobalNamespace(luaVm) .beginClass<_luaApi_WeaponInfo>("WeaponInfo") diff --git a/csgo2/sdk/gameevent/IGameEvent.h b/csgo2/sdk/gameevent/IGameEvent.h index 0a25ed4..3579092 100644 --- a/csgo2/sdk/gameevent/IGameEvent.h +++ b/csgo2/sdk/gameevent/IGameEvent.h @@ -36,9 +36,9 @@ class IGameEvent { bool defaultValue = false) = 0; virtual int GetInt(UnkGameEventStruct_t* keyName = NULL, int defaultValue = 0) = 0; - virtual uint64_t GetUint64(const char* keyName = NULL, + virtual uint64_t GetUint64(UnkGameEventStruct_t* keyName = NULL, uint64_t defaultValue = 0) = 0; - virtual float GetFloat(const char* keyName = NULL, + virtual float GetFloat(UnkGameEventStruct_t* keyName = NULL, float defaultValue = 0.0f) = 0; virtual const char* GetString(UnkGameEventStruct_t* keyName = NULL, const char* defaultValue = "") = 0; diff --git a/csgo2/sdk/public/eiface.h b/csgo2/sdk/public/eiface.h index afc5bb7..dbabd48 100644 --- a/csgo2/sdk/public/eiface.h +++ b/csgo2/sdk/public/eiface.h @@ -313,6 +313,7 @@ class ISource2Server : public IAppSystem virtual void ServerConVarChanged(const char* pVarName, const char* pValue) = 0; }; + //----------------------------------------------------------------------------- // Purpose: Interface the engine exposes to the game DLL //----------------------------------------------------------------------------- @@ -326,6 +327,7 @@ class IVEngineServer2 : public ISource2Engine virtual void unk003() = 0; virtual void unk004() = 0; virtual void unk005() = 0; + virtual void unk006() = 0; // Tell engine to change level ( "changelevel s1\n" or "changelevel2 s1 s2\n" ) @@ -417,7 +419,7 @@ class IVEngineServer2 : public ISource2Engine virtual void SetTimescale(float flTimescale) = 0; - virtual uint32_t GetAppID() = 0; + virtual uint32 GetAppID() = 0; // Returns the SteamID of the specified player. It'll be NULL if the player hasn't authenticated yet. virtual const CSteamID* GetClientSteamID(CPlayerSlot clientIndex) = 0; @@ -451,7 +453,7 @@ class IVEngineServer2 : public ISource2Engine virtual bool GetPlayerInfo(CPlayerSlot clientIndex, google::protobuf::Message& info) = 0; // Returns the XUID of the specified player. It'll be NULL if the player hasn't connected yet. - virtual uint64_t GetClientXUID(CPlayerSlot clientIndex) = 0; + virtual uint64 GetClientXUID(CPlayerSlot clientIndex) = 0; virtual void* GetPVSForSpawnGroup(SpawnGroupHandle_t spawnGroup) = 0; virtual SpawnGroupHandle_t FindSpawnGroupByName(const char* szName) = 0; @@ -463,45 +465,57 @@ class IVEngineServer2 : public ISource2Engine virtual bool IsClientLowViolence(CEntityIndex clientIndex) = 0; -#if 0 // Don't really match the binary + // Kicks the slot with the specified NetworkDisconnectionReason virtual void DisconnectClient(CEntityIndex clientIndex, /* ENetworkDisconnectionReason */ int reason) = 0; +#if 0 // Don't really match the binary virtual void GetAllSpawnGroupsWithPVS(CUtlVector* spawnGroups, CUtlVector* pOut) = 0; virtual void P2PGroupChanged() = 0; #endif - virtual void unk006() = 0; - virtual void unk007() = 0; - virtual void unk008() = 0; - virtual void unk009() = 0; - virtual void unk010() = 0; - virtual void unk011() = 0; - virtual void unk012() = 0; - virtual void unk013() = 0; + virtual void unk101() = 0; + virtual void unk102() = 0; + virtual void unk103() = 0; + virtual void unk104() = 0; + virtual void unk105() = 0; + virtual void unk106() = 0; + virtual void unk107() = 0; virtual void OnKickClient(const CCommandContext& context, const CCommand& cmd) = 0; - // Kicks the slot with the specified NetworkDisconnectionReason. + // Kicks and bans the slot. // Note that the internal reason is never displayed to the user. + // ENetworkDisconnectionReason reason is ignored, client is always kicked with ENetworkDisconnectionReason::NETWORK_DISCONNECT_KICKBANADDED // // AM TODO: add header ref for ENetworkDisconnectReason from proto header - virtual void KickClient(CPlayerSlot slot, const char* szInternalReason, /*ENetworkDisconnectionReason*/ char reason) = 0; - - virtual void unk015() = 0; - virtual void unk016() = 0; - virtual void unk017() = 0; - virtual void unk018() = 0; - virtual void unk019() = 0; - virtual void unk020() = 0; - virtual void unk021() = 0; - virtual void unk022() = 0; - virtual void unk023() = 0; + virtual void BanClient(CPlayerSlot slot, const char* szInternalReason, /*ENetworkDisconnectionReason*/ char reason) = 0; + + virtual void unk200() = 0; + virtual void unk201() = 0; + virtual void unk202() = 0; + virtual void unk203() = 0; + virtual void unk204() = 0; + virtual void unk205() = 0; + virtual void unk206() = 0; + virtual void unk207() = 0; + virtual void unk208() = 0; virtual void SetClientUpdateRate(CEntityIndex clientIndex, float flUpdateRate) = 0; - virtual void unk024() = 0; - virtual void unk025() = 0; + virtual void unk300() = 0; + virtual void unk301() = 0; +}; + +class IServerGCLobby +{ +public: + virtual bool HasLobby() const = 0; + virtual bool SteamIDAllowedToConnect(const CSteamID& steamId) const = 0; + virtual void UpdateServerDetails(void) = 0; + virtual bool ShouldHibernate() = 0; + virtual bool SteamIDAllowedToP2PConnect(const CSteamID& steamId) const = 0; + virtual bool LobbyAllowsCheats(void) const = 0; }; //----------------------------------------------------------------------------- // Purpose: Player / Client related functions