small updates for game interface

This commit is contained in:
RaidMax 2022-02-12 21:54:21 -06:00
parent f3c6b10a35
commit 3640d1df54
2 changed files with 20 additions and 11 deletions

View File

@ -33,7 +33,12 @@ init()
level.eventCallbacks[level.eventTypes.clientDataReceived] = ::OnClientDataReceived;
level.eventCallbacks[level.eventTypes.executeCommandRequested] = ::OnExecuteCommand;
level.eventCallbacks[level.eventTypes.setClientDataCompleted] = ::OnSetClientDataCompleted;
if ( GetDvarInt( "sv_iw4madmin_integration_enabled" ) != 1 )
{
return;
}
// start long running tasks
level thread MonitorClientEvents();
level thread MonitorBus();
@ -233,6 +238,7 @@ SaveTrackingMetrics()
currentShotCount = self getPlayerStat( "mostshotsfired" );
change = currentShotCount - self.lastShotCount;
self.lastShotCount = currentShotCount;
if ( level.iw4adminIntegrationDebug == 1 )
{
@ -251,7 +257,6 @@ SaveTrackingMetrics()
IncrementClientMeta( "TotalShotsFired", change, self.persistentClientId );
self.lastShotCount = currentShotCount;
}
BuildEventRequest( responseExpected, eventType, eventSubtype, entOrId, data )

View File

@ -17,12 +17,16 @@ let plugin = {
name: 'Game Interface',
onEventAsync: (gameEvent, server) => {
const eventType = eventTypes[gameEvent.Type];
if (servers[server.EndPoint] != null && !servers[server.EndPoint].enabled) {
return;
}
const eventType = eventTypes[gameEvent.Type];
if (eventType === undefined) {
return;
}
switch (eventType) {
case 'start':
const enabled = initialize(server);
@ -265,6 +269,11 @@ const parseEvent = (input) => {
const initialize = (server) => {
const logger = _serviceResolver.ResolveService('ILogger');
servers[server.EndPoint] = {
enabled: false
}
let enabled = false;
try {
enabled = server.GetServerDvar('sv_iw4madmin_integration_enabled') === '1';
@ -275,9 +284,6 @@ const initialize = (server) => {
logger.WriteInfo(`GSC Integration enabled = ${enabled}`);
if (!enabled) {
servers[server.EndPoint] = {
enabled: false
}
return false;
}
@ -288,10 +294,8 @@ const initialize = (server) => {
// necessary to prevent multi-threaded access to the JS context
timer.SetDependency(_lock);
servers[server.EndPoint] = {
timer: timer,
enabled: true
}
servers[server.EndPoint].timer = timer;
servers[server.EndPoint].enabled = true;
try {
server.SetServerDvar(inDvar, '');