aboutsummaryrefslogtreecommitdiff
path: root/NorthstarDedicatedTest/scriptservertoclientstringcommand.cpp
diff options
context:
space:
mode:
authorBobTheBob <32057864+BobTheBob9@users.noreply.github.com>2022-03-06 18:58:55 +0000
committerBobTheBob <32057864+BobTheBob9@users.noreply.github.com>2022-03-06 18:58:55 +0000
commit6a9fae96aeab36a9a9a32af7cd8d6b0c700d2f2b (patch)
treea12afb79844f7074a7d7124b8867c35b8f75d231 /NorthstarDedicatedTest/scriptservertoclientstringcommand.cpp
parent17aaab6f250cd4d576fce78392596762e2a09142 (diff)
downloadNorthstarLauncher-6a9fae96aeab36a9a9a32af7cd8d6b0c700d2f2b.tar.gz
NorthstarLauncher-6a9fae96aeab36a9a9a32af7cd8d6b0c700d2f2b.zip
add support for server=>client script stringcommands
Diffstat (limited to 'NorthstarDedicatedTest/scriptservertoclientstringcommand.cpp')
-rw-r--r--NorthstarDedicatedTest/scriptservertoclientstringcommand.cpp25
1 files changed, 25 insertions, 0 deletions
diff --git a/NorthstarDedicatedTest/scriptservertoclientstringcommand.cpp b/NorthstarDedicatedTest/scriptservertoclientstringcommand.cpp
new file mode 100644
index 00000000..58d92ec6
--- /dev/null
+++ b/NorthstarDedicatedTest/scriptservertoclientstringcommand.cpp
@@ -0,0 +1,25 @@
+#include "pch.h"
+#include "scriptservertoclientstringcommand.h"
+#include "squirrel.h"
+#include "convar.h"
+#include "concommand.h"
+#include "dedicated.h"
+
+void ConCommand_ns_script_servertoclientstringcommand(const CCommand& arg)
+{
+ if (g_ClientSquirrelManager->sqvm && g_ClientSquirrelManager->setupfunc("NSClientCodeCallback_RecievedServerToClientStringCommand") != SQRESULT_ERROR)
+ {
+ g_ClientSquirrelManager->pusharg(arg.ArgS());
+ g_ClientSquirrelManager->call(1); // todo: doesn't throw or log errors from within this, probably not great behaviour
+ }
+}
+
+void InitialiseScriptServerToClientStringCommands(HMODULE baseAddress)
+{
+ if (IsDedicated())
+ return;
+
+ RegisterConCommand(
+ "ns_script_servertoclientstringcommand", ConCommand_ns_script_servertoclientstringcommand, "",
+ FCVAR_CLIENTDLL | FCVAR_SERVER_CAN_EXECUTE);
+} \ No newline at end of file