diff --git a/r5dev/squirrel/sqinit.cpp b/r5dev/squirrel/sqinit.cpp index 4ef04926..d8014806 100644 --- a/r5dev/squirrel/sqinit.cpp +++ b/r5dev/squirrel/sqinit.cpp @@ -156,6 +156,21 @@ namespace VSquirrel return SQ_OK; } +#ifndef DEDICATED + //----------------------------------------------------------------------------- + // Purpose: checks whether this SDK build is a client dll + //----------------------------------------------------------------------------- + SQRESULT IsClientDLL(HSQUIRRELVM v) + { +#ifdef CLIENT_DLL + constexpr SQBool bClientOnly = true; +#else + constexpr SQBool bClientOnly = false; +#endif + sq_pushbool(v, bClientOnly); + return SQ_OK; + } +#endif // !DEDICATED } #ifndef CLIENT_DLL namespace SERVER @@ -177,6 +192,15 @@ namespace VSquirrel sq_pushinteger(v, g_pServer->GetNumFakeClients()); return SQ_OK; } + + //----------------------------------------------------------------------------- + // Purpose: checks whether this SDK build is a dedicated server + //----------------------------------------------------------------------------- + SQRESULT IsDedicated(HSQUIRRELVM v) + { + sq_pushbool(v, *s_bDedicated); + return SQ_OK; + } } #endif // !CLIENT_DLL #ifndef DEDICATED diff --git a/r5dev/squirrel/sqinit.h b/r5dev/squirrel/sqinit.h index 4577cca5..4e2cff07 100644 --- a/r5dev/squirrel/sqinit.h +++ b/r5dev/squirrel/sqinit.h @@ -23,6 +23,9 @@ namespace VSquirrel SQRESULT GetAvailableMaps(HSQUIRRELVM v); SQRESULT GetAvailablePlaylists(HSQUIRRELVM v); SQRESULT ShutdownHostGame(HSQUIRRELVM v); +#ifndef DEDICATED + SQRESULT IsClientDLL(HSQUIRRELVM v); +#endif // !DEDICATED #ifndef CLIENT_DLL SQRESULT KickPlayerByName(HSQUIRRELVM v); SQRESULT KickPlayerById(HSQUIRRELVM v); @@ -36,6 +39,7 @@ namespace VSquirrel { SQRESULT GetNumHumanPlayers(HSQUIRRELVM v); SQRESULT GetNumFakeClients(HSQUIRRELVM v); + SQRESULT IsDedicated(HSQUIRRELVM v); } #endif // !CLIENT_DLL #ifndef DEDICATED diff --git a/r5dev/squirrel/sqscript.cpp b/r5dev/squirrel/sqscript.cpp index 86f66bed..9321f702 100644 --- a/r5dev/squirrel/sqscript.cpp +++ b/r5dev/squirrel/sqscript.cpp @@ -76,6 +76,8 @@ void Script_RegisterServerFunctions(CSquirrelVM* s) Script_RegisterFunction(s, "UnbanPlayer", "Script_UnbanPlayer", "Unbans a player from the server by nucleus id or ip address", "void", "string", &VSquirrel::SHARED::UnbanPlayer); Script_RegisterFunction(s, "ShutdownHostGame", "Script_ShutdownHostGame", "Shuts the local host game down", "void", "", &VSquirrel::SHARED::ShutdownHostGame); + + Script_RegisterFunction(s, "IsDedicated", "Script_IsDedicated", "Returns whether this is a dedicated server", "bool", "", &VSquirrel::SERVER::IsDedicated); } #endif // !CLIENT_DLL @@ -137,6 +139,7 @@ void Script_RegisterUIFunctions(CSquirrelVM* s) Script_RegisterFunction(s, "UnbanPlayer", "Script_UnbanPlayer", "Unbans a player from the server by nucleus id or ip address", "void", "string", &VSquirrel::SHARED::UnbanPlayer); #endif // !CLIENT_DLL Script_RegisterFunction(s, "ShutdownHostGame", "Script_ShutdownHostGame", "Shuts the local host game down", "void", "", &VSquirrel::SHARED::ShutdownHostGame); + Script_RegisterFunction(s, "IsClientDLL", "Script_IsClientDLL", "Returns whether this build is client only", "bool", "", &VSquirrel::SHARED::IsClientDLL); } //---------------------------------------------------------------------------------