diff --git a/src/Components/Modules/Bots.cpp b/src/Components/Modules/Bots.cpp index eec80580..9c4509c0 100644 --- a/src/Components/Modules/Bots.cpp +++ b/src/Components/Modules/Bots.cpp @@ -331,7 +331,7 @@ namespace Components { auto* client = &Game::svs_clients[i]; - if (client->state < 3) + if (client->state < Game::CS_CONNECTED) continue; if (!client->isBot) diff --git a/src/Components/Modules/Script.cpp b/src/Components/Modules/Script.cpp index cd2e8b4c..aff300b7 100644 --- a/src/Components/Modules/Script.cpp +++ b/src/Components/Modules/Script.cpp @@ -642,6 +642,21 @@ namespace Components { Script::ScriptStorage.clear(); }); + + Script::AddFunction("DebugCode", [](Game::scr_entref_t) // gsc: DebugCode() + { + if (Game::Scr_GetNumParam() != 1u) + { + Game::Scr_Error("^1DebugCode: Needs one int parameter!\n"); + return; + } + + const auto toggle = Game::Scr_GetInt(0); + + Game::scrVmPub->debugCode = (toggle) + ? true + : false; + }); } Script::Script() @@ -658,7 +673,12 @@ namespace Components int developer = Dvar::Var("developer").get(); if (developer > 0 && Dedicated::IsEnabled()) + { Utils::Hook::Set(0x48D8C7, 0x75); + // Seems to always be false, if set to true + // it will call RuntimeErrorInternal + Game::scrVmPub->debugCode = true; + } }); Utils::Hook(0x612E8D, Script::FunctionError, HOOK_CALL).install()->quick(); diff --git a/src/Game/Functions.cpp b/src/Game/Functions.cpp index 82b63998..1407ab05 100644 --- a/src/Game/Functions.cpp +++ b/src/Game/Functions.cpp @@ -275,6 +275,7 @@ namespace Game Scr_NotifyLevel_t Scr_NotifyLevel = Scr_NotifyLevel_t(0x4D9C30); Scr_Error_t Scr_Error = Scr_Error_t(0x61E8B0); Scr_ObjectError_t Scr_ObjectError = Scr_ObjectError_t(0x42EF40); + Scr_ParamError_t Scr_ParamError = Scr_ParamError_t(0x4FBC70); Scr_GetType_t Scr_GetType = Scr_GetType_t(0x422900); Scr_ClearOutParams_t Scr_ClearOutParams = Scr_ClearOutParams_t(0x4386E0); diff --git a/src/Game/Functions.hpp b/src/Game/Functions.hpp index 93cd0804..4d5228e1 100644 --- a/src/Game/Functions.hpp +++ b/src/Game/Functions.hpp @@ -705,6 +705,9 @@ namespace Game typedef void(__cdecl * Scr_ObjectError_t)(const char*); extern Scr_ObjectError_t Scr_ObjectError; + typedef void(__cdecl * Scr_ParamError_t)(unsigned int paramIndex, const char*); + extern Scr_ParamError_t Scr_ParamError; + typedef script_t* (__cdecl * Script_Alloc_t)(int length); extern Script_Alloc_t Script_Alloc;