mirror of
https://github.com/RaidMax/IW4M-Admin.git
synced 2025-06-09 23:00:57 -05:00
Fix Game Interface / AC Callbacks + support for T5ZM, T6MP and T6ZM for the Game Interface. (#288)
* Fix trying to write to a struct before its initialized. Same issue on IW4, IW5 and T5 game modules. * Fix path issues in the scripts + add support for t5zm. * Fix deploy.bat * Change paths inside the gsc scripts used to call functions in other scripts * Remove mp includes from base gsc file. #include maps\mp\_utility; #include maps\mp\gametypes\_hud_util; * Define GetXuid as overrideMethod as t5zm doesn't have it. * Define GetPlayerFromClientNum as getting all players is slightly different on t5zm. * Remove the precompiled gsc file for T6 as PlutoT6 can load uncompiled GSC now. * Fix _customcallbacks.gsc for T6 * Add T6 support to the game interface. * Update _integration_base.gsc use camelCase for functionName * Make sure the Setup functions are always called in the right order. Base -> shared -> game Otherwise we might write to structs before they are created. * Move functions interacting with the game from _base to _shared GetPlayerFromClientNum OnPlayerJoinedTeam OnPlayerJoinedSpectators GenerateJoinTeamString PlayerTrackingOnInterval SaveTrackingMetrics * Block execution until game specific setup is done Block _shared execution until the game specific file finished. This allows the game specific file to override the events in _shared. * Fix setup event flow Move check of sv_iw4madmin_integration_enabled dvar after waittill in _shared so _base has a chance to set it to 1. Move check of sv_iw4madmin_autobalance dvar to OnPlayerConnect in _shared so the game specific script has a chance to set the dvar. * ignore bots * add more spaces
This commit is contained in:
@ -1,6 +1,4 @@
|
||||
#include common_scripts\utility;
|
||||
#include maps\mp\_utility;
|
||||
#include maps\mp\gametypes\_hud_util;
|
||||
|
||||
Init()
|
||||
{
|
||||
@ -19,14 +17,17 @@ Setup()
|
||||
level.eventBus.timeoutKey = "timeout";
|
||||
level.eventBus.timeout = 30;
|
||||
|
||||
level.commonFunctions = spawnstruct();
|
||||
level.commonFunctions.setDvar = "SetDvarIfUninitialized";
|
||||
level.commonFunctions.isBot = "IsBot";
|
||||
level.commonFunctions = spawnstruct();
|
||||
level.commonFunctions.setDvar = "SetDvarIfUninitialized";
|
||||
level.commonFunctions.isBot = "IsBot";
|
||||
level.commonFunctions.getXuid = "GetXuid";
|
||||
level.commonFunctions.getPlayerFromClientNum = "GetPlayerFromClientNum";
|
||||
|
||||
level.commonKeys = spawnstruct();
|
||||
|
||||
level.notifyTypes = spawnstruct();
|
||||
level.notifyTypes.gameFunctionsInitialized = "GameFunctionsInitialized";
|
||||
level.notifyTypes.sharedFunctionsInitialized = "SharedFunctionsInitialized";
|
||||
level.notifyTypes.integrationBootstrapInitialized = "IntegrationBootstrapInitialized";
|
||||
|
||||
level.clientDataKey = "clientData";
|
||||
@ -102,9 +103,6 @@ OnPlayerConnect()
|
||||
}
|
||||
|
||||
player thread OnPlayerSpawned();
|
||||
player thread OnPlayerJoinedTeam();
|
||||
player thread OnPlayerJoinedSpectators();
|
||||
player thread PlayerTrackingOnInterval();
|
||||
}
|
||||
}
|
||||
|
||||
@ -119,30 +117,6 @@ OnPlayerSpawned()
|
||||
}
|
||||
}
|
||||
|
||||
OnPlayerJoinedTeam()
|
||||
{
|
||||
self endon( "disconnect" );
|
||||
|
||||
for( ;; )
|
||||
{
|
||||
self waittill( "joined_team" );
|
||||
// join spec and join team occur at the same moment - out of order logging would be problematic
|
||||
wait( 0.25 );
|
||||
LogPrint( GenerateJoinTeamString( false ) );
|
||||
}
|
||||
}
|
||||
|
||||
OnPlayerJoinedSpectators()
|
||||
{
|
||||
self endon( "disconnect" );
|
||||
|
||||
for( ;; )
|
||||
{
|
||||
self waittill( "joined_spectators" );
|
||||
LogPrint( GenerateJoinTeamString( true ) );
|
||||
}
|
||||
}
|
||||
|
||||
OnGameEnded()
|
||||
{
|
||||
for ( ;; )
|
||||
@ -187,20 +161,6 @@ PlayerSpawnEvents()
|
||||
self RequestClientBasicData();
|
||||
}
|
||||
|
||||
PlayerTrackingOnInterval()
|
||||
{
|
||||
self endon( "disconnect" );
|
||||
|
||||
for ( ;; )
|
||||
{
|
||||
wait ( 120 );
|
||||
if ( IsAlive( self ) )
|
||||
{
|
||||
self SaveTrackingMetrics();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
MonitorClientEvents()
|
||||
{
|
||||
level endon( "game_ended" );
|
||||
@ -344,37 +304,6 @@ DecrementClientMeta( metaKey, decrementValue, clientId )
|
||||
SetClientMeta( metaKey, decrementValue, clientId, "decrement" );
|
||||
}
|
||||
|
||||
GenerateJoinTeamString( isSpectator )
|
||||
{
|
||||
team = self.team;
|
||||
|
||||
if ( IsDefined( self.joining_team ) )
|
||||
{
|
||||
team = self.joining_team;
|
||||
}
|
||||
else
|
||||
{
|
||||
if ( isSpectator || !IsDefined( team ) )
|
||||
{
|
||||
team = "spectator";
|
||||
}
|
||||
}
|
||||
|
||||
guid = self GetXuid();
|
||||
|
||||
if ( guid == "0" )
|
||||
{
|
||||
guid = self.guid;
|
||||
}
|
||||
|
||||
if ( !IsDefined( guid ) || guid == "0" )
|
||||
{
|
||||
guid = "undefined";
|
||||
}
|
||||
|
||||
return "JT;" + guid + ";" + self getEntityNumber() + ";" + team + ";" + self.name + "\n";
|
||||
}
|
||||
|
||||
SetClientMeta( metaKey, metaValue, clientId, direction )
|
||||
{
|
||||
data = "key=" + metaKey + "|value=" + metaValue;
|
||||
@ -400,39 +329,6 @@ SetClientMeta( metaKey, metaValue, clientId, direction )
|
||||
level thread QueueEvent( setClientMetaEvent, level.eventTypes.setClientDataRequested, self );
|
||||
}
|
||||
|
||||
SaveTrackingMetrics()
|
||||
{
|
||||
if ( !IsDefined( self.persistentClientId ) )
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
LogDebug( "Saving tracking metrics for " + self.persistentClientId );
|
||||
|
||||
if ( !IsDefined( self.lastShotCount ) )
|
||||
{
|
||||
self.lastShotCount = 0;
|
||||
}
|
||||
|
||||
currentShotCount = self [[level.overrideMethods["GetTotalShotsFired"]]]();
|
||||
change = currentShotCount - self.lastShotCount;
|
||||
self.lastShotCount = currentShotCount;
|
||||
|
||||
LogDebug( "Total Shots Fired increased by " + change );
|
||||
|
||||
if ( !IsDefined( change ) )
|
||||
{
|
||||
change = 0;
|
||||
}
|
||||
|
||||
if ( change == 0 )
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
IncrementClientMeta( "TotalShotsFired", change, self.persistentClientId );
|
||||
}
|
||||
|
||||
BuildEventRequest( responseExpected, eventType, eventSubtype, entOrId, data )
|
||||
{
|
||||
if ( !IsDefined( data ) )
|
||||
@ -565,8 +461,8 @@ NotifyClientEventTimeout( eventType )
|
||||
|
||||
NotifyClientEvent( eventInfo )
|
||||
{
|
||||
origin = getPlayerFromClientNum( int( eventInfo[3] ) );
|
||||
target = getPlayerFromClientNum( int( eventInfo[4] ) );
|
||||
origin = [[level.overrideMethods[level.commonFunctions.getPlayerFromClientNum]]]( int( eventInfo[3] ) );
|
||||
target = [[level.overrideMethods[level.commonFunctions.getPlayerFromClientNum]]]( int( eventInfo[4] ) );
|
||||
|
||||
event = spawnstruct();
|
||||
event.type = eventInfo[1];
|
||||
@ -608,24 +504,6 @@ NotifyClientEvent( eventInfo )
|
||||
level notify( level.eventTypes.localClientEvent, client );
|
||||
}
|
||||
|
||||
GetPlayerFromClientNum( clientNum )
|
||||
{
|
||||
if ( clientNum < 0 )
|
||||
{
|
||||
return undefined;
|
||||
}
|
||||
|
||||
for ( i = 0; i < level.players.size; i++ )
|
||||
{
|
||||
if ( level.players[i] getEntityNumber() == clientNum )
|
||||
{
|
||||
return level.players[i];
|
||||
}
|
||||
}
|
||||
|
||||
return undefined;
|
||||
}
|
||||
|
||||
AddClientCommand( commandName, shouldRunAsTarget, callback, shouldOverwrite )
|
||||
{
|
||||
if ( IsDefined( level.clientCommandCallbacks[commandName] ) && IsDefined( shouldOverwrite ) && !shouldOverwrite )
|
||||
|
Reference in New Issue
Block a user