From c3f66e748ffa8358775ed9be88251f8b629f5299 Mon Sep 17 00:00:00 2001 From: Kawe Mazidjatari <48657826+Mauler125@users.noreply.github.com> Date: Sun, 14 Apr 2024 14:22:32 +0200 Subject: [PATCH] Server: add script function 'GetServerID()' Allows one to get the current session uuid (will be used for LiveAPI's Init event for session identification). --- r5dev/game/server/vscript_server.cpp | 11 +++++++++++ r5dev/game/server/vscript_server.h | 2 ++ 2 files changed, 13 insertions(+) diff --git a/r5dev/game/server/vscript_server.cpp b/r5dev/game/server/vscript_server.cpp index 9120f395..0ca711d9 100644 --- a/r5dev/game/server/vscript_server.cpp +++ b/r5dev/game/server/vscript_server.cpp @@ -247,6 +247,15 @@ namespace VScriptCode SCRIPT_CHECK_AND_RETURN(v, SQ_OK); } + //----------------------------------------------------------------------------- + // Purpose: gets the current server id + //----------------------------------------------------------------------------- + SQRESULT GetServerID(HSQUIRRELVM v) + { + sq_pushstring(v, g_LogSessionUUID.c_str(), (SQInteger)g_LogSessionUUID.length()); + SCRIPT_CHECK_AND_RETURN(v, SQ_OK); + } + //----------------------------------------------------------------------------- // Purpose: checks whether the server is active //----------------------------------------------------------------------------- @@ -300,6 +309,8 @@ void Script_RegisterCoreServerFunctions(CSquirrelVM* s) DEFINE_SERVER_SCRIPTFUNC_NAMED(s, DestroyServer, "Shuts the local server down", "void", ""); DEFINE_SERVER_SCRIPTFUNC_NAMED(s, SetAutoReloadState, "Set whether we can auto-reload the server", "void", "bool"); + + DEFINE_SERVER_SCRIPTFUNC_NAMED(s, GetServerID, "Gets the current server ID", "string", ""); } //--------------------------------------------------------------------------------- diff --git a/r5dev/game/server/vscript_server.h b/r5dev/game/server/vscript_server.h index 4bc7a82f..8d811524 100644 --- a/r5dev/game/server/vscript_server.h +++ b/r5dev/game/server/vscript_server.h @@ -20,6 +20,8 @@ namespace VScriptCode SQRESULT GetNumHumanPlayers(HSQUIRRELVM v); SQRESULT GetNumFakeClients(HSQUIRRELVM v); + SQRESULT GetServerID(HSQUIRRELVM v); + SQRESULT IsServerActive(HSQUIRRELVM v); SQRESULT IsDedicated(HSQUIRRELVM v); }