From 0266a48c88be90422539bf82cc69573f715fde69 Mon Sep 17 00:00:00 2001 From: Huoji's <1296564236@qq.com> Date: Tue, 10 Oct 2023 21:15:42 +0800 Subject: [PATCH] add steamid function --- csgo2/hooks.cpp | 3 --- csgo2/script_apis.cpp | 11 +++++++++++ 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/csgo2/hooks.cpp b/csgo2/hooks.cpp index 6950912..5009ad8 100644 --- a/csgo2/hooks.cpp +++ b/csgo2/hooks.cpp @@ -56,9 +56,6 @@ void __fastcall hook_GameFrame(void* rcx, bool simulating, bool bFirstTick, * true | game is ticking * false | game is not ticking */ - if (global::GlobalVars == nullptr) { - global::GlobalVars = GetGameGlobals(); - } if (global::GlobalVars != nullptr) { if (simulating && global::HasTicked) { global::m_flUniversalTime += diff --git a/csgo2/script_apis.cpp b/csgo2/script_apis.cpp index 2425aa6..a50d598 100644 --- a/csgo2/script_apis.cpp +++ b/csgo2/script_apis.cpp @@ -714,6 +714,16 @@ auto luaApi_RunServerCommand(lua_State* luaVm) -> int { lua_pop(luaVm, 1); return 0; } +auto luaApi_GetPlayerSteamId(lua_State* luaVm) -> int { + const auto playerIndex = lua_tointeger(luaVm, 1); + uint64_t steamid; + ExcutePlayerAction(playerIndex, [&](CCSPlayerController* playerController) { + steamid = playerController->m_steamID(); + }); + lua_pop(luaVm, 1); + lua_pushinteger(luaVm, steamid); + return 1; +} auto luaApi_KickPlayer(lua_State* luaVm) -> int { const auto playerIndex = lua_tointeger(luaVm, 1); const auto reason = lua_tostring(luaVm, 2); @@ -827,6 +837,7 @@ auto initFunciton(lua_State* luaVm) -> void { lua_register(luaVm, "luaApi_KickPlayer", luaApi_KickPlayer); lua_register(luaVm, "luaApi_HttpGet", luaApi_HttpGet); lua_register(luaVm, "luaApi_HttpPost", luaApi_HttpPost); + lua_register(luaVm, "luaApi_GetPlayerSteamId", luaApi_GetPlayerSteamId); luabridge::getGlobalNamespace(luaVm) .beginClass<_luaApi_WeaponInfo>("WeaponInfo")