Server: add script function 'GetServerID()'

Allows one to get the current session uuid (will be used for LiveAPI's Init event for session identification).
This commit is contained in:
Kawe Mazidjatari 2024-04-14 14:22:32 +02:00
parent 6a99c1bd5c
commit c3f66e748f
2 changed files with 13 additions and 0 deletions

View File

@ -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", "");
}
//---------------------------------------------------------------------------------

View File

@ -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);
}