aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorlaundmo <laurinschmidt2001@gmail.com>2022-02-05 22:54:23 +0100
committerBarichello <artur@barichello.me>2022-02-12 15:45:04 -0300
commit7e11339956c4e51a9d3901e963de0b8d5562f9d8 (patch)
treefd2c96716b474fa9a535dbf4b0a8886265c32722
parentb389be9738dd6c535806dec1ae77e7327d02d5e2 (diff)
downloadNorthstarMods-7e11339956c4e51a9d3901e963de0b8d5562f9d8.tar.gz
NorthstarMods-7e11339956c4e51a9d3901e963de0b8d5562f9d8.zip
Allow for adding a client command notify callback
-rw-r--r--Northstar.CustomServers/mod/scripts/vscripts/_codecallbacks_common.gnut15
-rw-r--r--Northstar.CustomServers/mod/scripts/vscripts/_mapspawn.gnut11
2 files changed, 25 insertions, 1 deletions
diff --git a/Northstar.CustomServers/mod/scripts/vscripts/_codecallbacks_common.gnut b/Northstar.CustomServers/mod/scripts/vscripts/_codecallbacks_common.gnut
index b08fdcf1..d2621db3 100644
--- a/Northstar.CustomServers/mod/scripts/vscripts/_codecallbacks_common.gnut
+++ b/Northstar.CustomServers/mod/scripts/vscripts/_codecallbacks_common.gnut
@@ -35,6 +35,7 @@ global function AddCallback_OnUpdateDerivedPilotLoadout
global function AddCallback_OnUpdateDerivedTitanLoadout
global function AddCallback_OnUpdateDerivedPlayerTitanLoadout
global function AddClientCommandCallback
+global function AddClientCommandNotifyCallback
global function AddPlayerDropScriptedItemsCallback
global function AddCallback_OnPlayerInventoryChanged
@@ -500,6 +501,20 @@ void function AddClientCommandCallback( string commandString, bool functionref(
svGlobal.clientCommandCallbacks[ commandString ] <- callbackFunc
}
+void function AddClientCommandNotifyCallback( string commandString, void functionref( entity player, array<string> args ) callbackFunc )
+{
+ if ( !( commandString in svGlobal.notifyClientCommandCallbacks ) )
+ {
+ svGlobal.notifyClientCommandCallbacks[ commandString ] <- [ callbackFunc ]
+ return
+ }
+ else
+ {
+ Assert( !svGlobal.notifyClientCommandCallbacks.contains( callbackFunc ), "Already added " + string( callbackFunc ) + " with AddClientCommandNotifyCallback" )
+ svGlobal.notifyClientCommandCallbacks[ commandString ].append(callbackFunc)
+ }
+}
+
void function AddPlayerDropScriptedItemsCallback( void functionref(entity player) callbackFunc )
{
Assert( !( svGlobal.onPlayerDropsScriptedItemsCallbacks.contains( callbackFunc ) ), "Already added " + string( callbackFunc ) + " with AddPlayerDropScriptedItemsCallback" )
diff --git a/Northstar.CustomServers/mod/scripts/vscripts/_mapspawn.gnut b/Northstar.CustomServers/mod/scripts/vscripts/_mapspawn.gnut
index 73e76910..1d16b9fa 100644
--- a/Northstar.CustomServers/mod/scripts/vscripts/_mapspawn.gnut
+++ b/Northstar.CustomServers/mod/scripts/vscripts/_mapspawn.gnut
@@ -94,6 +94,8 @@ global struct SvGlobals
table<string, array<void functionref( entity ent )> >onEntityChangedTeamCallbacks
table<string, bool functionref( entity player, array<string>args )> clientCommandCallbacks
+ table<string, array<void functionref( entity player, array<string>args )> > notifyClientCommandCallbacks
+
array<void functionref()>[ eGameState._count_ ] gameStateEnterCallbacks
bool allowPointsOverLimit = false
@@ -204,7 +206,14 @@ var function CodeCallback_ClientCommand( entity player, array<string> args )
//Assert( commandString in svGlobal.clientCommandCallbacks )
if ( commandString in svGlobal.clientCommandCallbacks )
{
- return svGlobal.clientCommandCallbacks[ commandString ]( player, args )
+ var result = svGlobal.clientCommandCallbacks[ commandString ]( player, args )
+ if ( commandString in svGlobal.notifyClientCommandCallbacks )
+ {
+ foreach ( callbackfunc in svGlobal.notifyClientCommandCallbacks[ commandString ]){
+ callbackfunc(player, args)
+ }
+ }
+ return result
}
else
{