feature(iw5: gsc): use preprocessor to deduplicate code (#308)
This commit is contained in:
parent
41efe26a48
commit
dc707f75b3
@ -8,7 +8,7 @@ Init()
|
|||||||
Setup()
|
Setup()
|
||||||
{
|
{
|
||||||
level endon( "game_ended" );
|
level endon( "game_ended" );
|
||||||
|
|
||||||
// setup default vars
|
// setup default vars
|
||||||
level.eventBus = spawnstruct();
|
level.eventBus = spawnstruct();
|
||||||
level.eventBus.inVar = "sv_iw4madmin_in";
|
level.eventBus.inVar = "sv_iw4madmin_in";
|
||||||
@ -16,7 +16,7 @@ Setup()
|
|||||||
level.eventBus.failKey = "fail";
|
level.eventBus.failKey = "fail";
|
||||||
level.eventBus.timeoutKey = "timeout";
|
level.eventBus.timeoutKey = "timeout";
|
||||||
level.eventBus.timeout = 30;
|
level.eventBus.timeout = 30;
|
||||||
|
|
||||||
level.commonFunctions = spawnstruct();
|
level.commonFunctions = spawnstruct();
|
||||||
level.commonFunctions.setDvar = "SetDvarIfUninitialized";
|
level.commonFunctions.setDvar = "SetDvarIfUninitialized";
|
||||||
level.commonFunctions.getPlayerFromClientNum = "GetPlayerFromClientNum";
|
level.commonFunctions.getPlayerFromClientNum = "GetPlayerFromClientNum";
|
||||||
@ -46,12 +46,12 @@ Setup()
|
|||||||
level.commonKeys.busDir = "sv_iw4madmin_integration_busdir";
|
level.commonKeys.busDir = "sv_iw4madmin_integration_busdir";
|
||||||
level.eventBus.inLocation = "";
|
level.eventBus.inLocation = "";
|
||||||
level.eventBus.outLocation = "";
|
level.eventBus.outLocation = "";
|
||||||
|
|
||||||
level.notifyTypes = spawnstruct();
|
level.notifyTypes = spawnstruct();
|
||||||
level.notifyTypes.gameFunctionsInitialized = "GameFunctionsInitialized";
|
level.notifyTypes.gameFunctionsInitialized = "GameFunctionsInitialized";
|
||||||
level.notifyTypes.sharedFunctionsInitialized = "SharedFunctionsInitialized";
|
level.notifyTypes.sharedFunctionsInitialized = "SharedFunctionsInitialized";
|
||||||
level.notifyTypes.integrationBootstrapInitialized = "IntegrationBootstrapInitialized";
|
level.notifyTypes.integrationBootstrapInitialized = "IntegrationBootstrapInitialized";
|
||||||
|
|
||||||
level.clientDataKey = "clientData";
|
level.clientDataKey = "clientData";
|
||||||
|
|
||||||
level.eventTypes = spawnstruct();
|
level.eventTypes = spawnstruct();
|
||||||
@ -61,9 +61,9 @@ Setup()
|
|||||||
level.eventTypes.setClientDataRequested = "SetClientDataRequested";
|
level.eventTypes.setClientDataRequested = "SetClientDataRequested";
|
||||||
level.eventTypes.setClientDataCompleted = "SetClientDataCompleted";
|
level.eventTypes.setClientDataCompleted = "SetClientDataCompleted";
|
||||||
level.eventTypes.executeCommandRequested = "ExecuteCommandRequested";
|
level.eventTypes.executeCommandRequested = "ExecuteCommandRequested";
|
||||||
|
|
||||||
level.iw4madminIntegrationDebug = 0;
|
level.iw4madminIntegrationDebug = 0;
|
||||||
|
|
||||||
// map the event type to the handler
|
// map the event type to the handler
|
||||||
level.eventCallbacks = [];
|
level.eventCallbacks = [];
|
||||||
level.eventCallbacks[level.eventTypes.clientDataReceived] = ::OnClientDataReceived;
|
level.eventCallbacks[level.eventTypes.clientDataReceived] = ::OnClientDataReceived;
|
||||||
@ -76,14 +76,14 @@ Setup()
|
|||||||
|
|
||||||
level.iw4madminIntegrationDebug = GetDvarInt( "sv_iw4madmin_integration_debug" );
|
level.iw4madminIntegrationDebug = GetDvarInt( "sv_iw4madmin_integration_debug" );
|
||||||
InitializeLogger();
|
InitializeLogger();
|
||||||
|
|
||||||
wait ( 0.05 * 2 ); // needed to give script engine time to propagate notifies
|
wait ( 0.05 * 2 ); // needed to give script engine time to propagate notifies
|
||||||
|
|
||||||
level notify( level.notifyTypes.integrationBootstrapInitialized );
|
level notify( level.notifyTypes.integrationBootstrapInitialized );
|
||||||
level waittill( level.notifyTypes.gameFunctionsInitialized );
|
level waittill( level.notifyTypes.gameFunctionsInitialized );
|
||||||
|
|
||||||
LogDebug( "Integration received notify that game functions are initialized" );
|
LogDebug( "Integration received notify that game functions are initialized" );
|
||||||
|
|
||||||
_SetDvarIfUninitialized( level.eventBus.inVar, "" );
|
_SetDvarIfUninitialized( level.eventBus.inVar, "" );
|
||||||
_SetDvarIfUninitialized( level.eventBus.outVar, "" );
|
_SetDvarIfUninitialized( level.eventBus.outVar, "" );
|
||||||
_SetDvarIfUninitialized( level.commonKeys.enabled, 1 );
|
_SetDvarIfUninitialized( level.commonKeys.enabled, 1 );
|
||||||
@ -93,12 +93,12 @@ Setup()
|
|||||||
_SetDvarIfUninitialized( "GroupSeparatorChar", "" );
|
_SetDvarIfUninitialized( "GroupSeparatorChar", "" );
|
||||||
_SetDvarIfUninitialized( "RecordSeparatorChar", "" );
|
_SetDvarIfUninitialized( "RecordSeparatorChar", "" );
|
||||||
_SetDvarIfUninitialized( "UnitSeparatorChar", "" );
|
_SetDvarIfUninitialized( "UnitSeparatorChar", "" );
|
||||||
|
|
||||||
if ( GetDvarInt( level.commonKeys.enabled ) != 1 )
|
if ( GetDvarInt( level.commonKeys.enabled ) != 1 )
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// start long running tasks
|
// start long running tasks
|
||||||
thread MonitorEvents();
|
thread MonitorEvents();
|
||||||
thread MonitorBus();
|
thread MonitorBus();
|
||||||
@ -113,7 +113,7 @@ MonitorEvents()
|
|||||||
level waittill( level.eventTypes.eventAvailable, event );
|
level waittill( level.eventTypes.eventAvailable, event );
|
||||||
|
|
||||||
LogDebug( "Processing Event " + event.type + "-" + event.subtype );
|
LogDebug( "Processing Event " + event.type + "-" + event.subtype );
|
||||||
|
|
||||||
eventHandler = level.eventCallbacks[event.type];
|
eventHandler = level.eventCallbacks[event.type];
|
||||||
|
|
||||||
if ( IsDefined( eventHandler ) )
|
if ( IsDefined( eventHandler ) )
|
||||||
@ -161,11 +161,13 @@ _SetDvarIfUninitialized( dvarName, dvarValue )
|
|||||||
|
|
||||||
_GetPlayerFromClientNum( clientNum )
|
_GetPlayerFromClientNum( clientNum )
|
||||||
{
|
{
|
||||||
|
assertEx( clientNum >= 0, "clientNum cannot be negative" );
|
||||||
|
|
||||||
if ( clientNum < 0 )
|
if ( clientNum < 0 )
|
||||||
{
|
{
|
||||||
return undefined;
|
return undefined;
|
||||||
}
|
}
|
||||||
|
|
||||||
for ( i = 0; i < level.players.size; i++ )
|
for ( i = 0; i < level.players.size; i++ )
|
||||||
{
|
{
|
||||||
if ( level.players[i] getEntityNumber() == clientNum )
|
if ( level.players[i] getEntityNumber() == clientNum )
|
||||||
@ -329,7 +331,7 @@ BuildEventRequest( responseExpected, eventType, eventSubtype, entOrId, data )
|
|||||||
{
|
{
|
||||||
data = "";
|
data = "";
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( !IsDefined( eventSubtype ) )
|
if ( !IsDefined( eventSubtype ) )
|
||||||
{
|
{
|
||||||
eventSubtype = "None";
|
eventSubtype = "None";
|
||||||
@ -344,9 +346,9 @@ BuildEventRequest( responseExpected, eventType, eventSubtype, entOrId, data )
|
|||||||
{
|
{
|
||||||
entOrId = entOrId getEntityNumber();
|
entOrId = entOrId getEntityNumber();
|
||||||
}
|
}
|
||||||
|
|
||||||
request = "0";
|
request = "0";
|
||||||
|
|
||||||
if ( responseExpected )
|
if ( responseExpected )
|
||||||
{
|
{
|
||||||
request = "1";
|
request = "1";
|
||||||
@ -355,14 +357,14 @@ BuildEventRequest( responseExpected, eventType, eventSubtype, entOrId, data )
|
|||||||
data = BuildDataString( data );
|
data = BuildDataString( data );
|
||||||
groupSeparator = GetSubStr( GetDvar( "GroupSeparatorChar" ), 0, 1 );
|
groupSeparator = GetSubStr( GetDvar( "GroupSeparatorChar" ), 0, 1 );
|
||||||
request = request + groupSeparator + eventType + groupSeparator + eventSubtype + groupSeparator + entOrId + groupSeparator + data;
|
request = request + groupSeparator + eventType + groupSeparator + eventSubtype + groupSeparator + entOrId + groupSeparator + data;
|
||||||
|
|
||||||
return request;
|
return request;
|
||||||
}
|
}
|
||||||
|
|
||||||
MonitorBus()
|
MonitorBus()
|
||||||
{
|
{
|
||||||
level endon( level.eventTypes.gameEnd );
|
level endon( level.eventTypes.gameEnd );
|
||||||
|
|
||||||
level.eventBus.inLocation = level.eventBus.inVar + "_" + GetDvar( "net_port" );
|
level.eventBus.inLocation = level.eventBus.inVar + "_" + GetDvar( "net_port" );
|
||||||
level.eventBus.outLocation = level.eventBus.outVar + "_" + GetDvar( "net_port" );
|
level.eventBus.outLocation = level.eventBus.outVar + "_" + GetDvar( "net_port" );
|
||||||
|
|
||||||
@ -372,7 +374,7 @@ MonitorBus()
|
|||||||
for( ;; )
|
for( ;; )
|
||||||
{
|
{
|
||||||
wait ( 0.1 );
|
wait ( 0.1 );
|
||||||
|
|
||||||
// check to see if IW4MAdmin is ready to receive more data
|
// check to see if IW4MAdmin is ready to receive more data
|
||||||
inVal = [[level.busMethods[level.commonFunctions.getInboundData]]]( level.eventBus.inLocation );
|
inVal = [[level.busMethods[level.commonFunctions.getInboundData]]]( level.eventBus.inLocation );
|
||||||
|
|
||||||
@ -380,19 +382,19 @@ MonitorBus()
|
|||||||
{
|
{
|
||||||
level notify( "bus_ready" );
|
level notify( "bus_ready" );
|
||||||
}
|
}
|
||||||
|
|
||||||
eventString = [[level.busMethods[level.commonFunctions.getOutboundData]]]( level.eventBus.outLocation );
|
eventString = [[level.busMethods[level.commonFunctions.getOutboundData]]]( level.eventBus.outLocation );
|
||||||
|
|
||||||
if ( !IsDefined( eventString ) || eventString == "" )
|
if ( !IsDefined( eventString ) || eventString == "" )
|
||||||
{
|
{
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
LogDebug( "-> " + eventString );
|
LogDebug( "-> " + eventString );
|
||||||
|
|
||||||
groupSeparator = GetSubStr( GetDvar( "GroupSeparatorChar" ), 0, 1 );
|
groupSeparator = GetSubStr( GetDvar( "GroupSeparatorChar" ), 0, 1 );
|
||||||
NotifyEvent( strtok( eventString, groupSeparator ) );
|
NotifyEvent( strtok( eventString, groupSeparator ) );
|
||||||
|
|
||||||
[[level.busMethods[level.commonFunctions.SetOutboundData]]]( level.eventBus.outLocation, "" );
|
[[level.busMethods[level.commonFunctions.SetOutboundData]]]( level.eventBus.outLocation, "" );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -404,7 +406,7 @@ QueueEvent( request, eventType, notifyEntity )
|
|||||||
start = GetTime();
|
start = GetTime();
|
||||||
maxWait = level.eventBus.timeout * 1000; // 30 seconds
|
maxWait = level.eventBus.timeout * 1000; // 30 seconds
|
||||||
timedOut = "";
|
timedOut = "";
|
||||||
|
|
||||||
while ( [[level.busMethods[level.commonFunctions.getInboundData]]]( level.eventBus.inLocation ) != "" && ( GetTime() - start ) < maxWait )
|
while ( [[level.busMethods[level.commonFunctions.getInboundData]]]( level.eventBus.inLocation ) != "" && ( GetTime() - start ) < maxWait )
|
||||||
{
|
{
|
||||||
level [[level.overrideMethods[level.commonFunctions.waittillNotifyOrTimeout]]]( "bus_ready", 1 );
|
level [[level.overrideMethods[level.commonFunctions.waittillNotifyOrTimeout]]]( "bus_ready", 1 );
|
||||||
@ -415,10 +417,10 @@ QueueEvent( request, eventType, notifyEntity )
|
|||||||
timedOut = "set";
|
timedOut = "set";
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
timedOut = "unset";
|
timedOut = "unset";
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( timedOut == "set" )
|
if ( timedOut == "set" )
|
||||||
{
|
{
|
||||||
LogDebug( "Timed out waiting for response..." );
|
LogDebug( "Timed out waiting for response..." );
|
||||||
@ -432,9 +434,9 @@ QueueEvent( request, eventType, notifyEntity )
|
|||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
LogDebug( "<- " + request );
|
LogDebug( "<- " + request );
|
||||||
|
|
||||||
[[level.busMethods[level.commonFunctions.setInboundData]]]( level.eventBus.inLocation, request );
|
[[level.busMethods[level.commonFunctions.setInboundData]]]( level.eventBus.inLocation, request );
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -445,10 +447,10 @@ ParseDataString( data )
|
|||||||
LogDebug( "No data to parse" );
|
LogDebug( "No data to parse" );
|
||||||
return [];
|
return [];
|
||||||
}
|
}
|
||||||
|
|
||||||
dataParts = strtok( data, GetSubStr( GetDvar( "RecordSeparatorChar" ), 0, 1 ) );
|
dataParts = strtok( data, GetSubStr( GetDvar( "RecordSeparatorChar" ), 0, 1 ) );
|
||||||
dict = [];
|
dict = [];
|
||||||
|
|
||||||
for ( i = 0; i < dataParts.size; i++ )
|
for ( i = 0; i < dataParts.size; i++ )
|
||||||
{
|
{
|
||||||
part = dataParts[i];
|
part = dataParts[i];
|
||||||
@ -458,7 +460,7 @@ ParseDataString( data )
|
|||||||
dict[key] = value;
|
dict[key] = value;
|
||||||
dict[i] = key;
|
dict[i] = key;
|
||||||
}
|
}
|
||||||
|
|
||||||
return dict;
|
return dict;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -495,14 +497,14 @@ NotifyEvent( eventInfo )
|
|||||||
{
|
{
|
||||||
origin = [[level.overrideMethods[level.commonFunctions.getPlayerFromClientNum]]]( int( eventInfo[3] ) );
|
origin = [[level.overrideMethods[level.commonFunctions.getPlayerFromClientNum]]]( int( eventInfo[3] ) );
|
||||||
target = [[level.overrideMethods[level.commonFunctions.getPlayerFromClientNum]]]( int( eventInfo[4] ) );
|
target = [[level.overrideMethods[level.commonFunctions.getPlayerFromClientNum]]]( int( eventInfo[4] ) );
|
||||||
|
|
||||||
event = spawnstruct();
|
event = spawnstruct();
|
||||||
event.type = eventInfo[1];
|
event.type = eventInfo[1];
|
||||||
event.subtype = eventInfo[2];
|
event.subtype = eventInfo[2];
|
||||||
event.data = ParseDataString( eventInfo[5] );
|
event.data = ParseDataString( eventInfo[5] );
|
||||||
event.origin = origin;
|
event.origin = origin;
|
||||||
event.target = target;
|
event.target = target;
|
||||||
|
|
||||||
if ( int( eventInfo[3] ) != -1 && !IsDefined( origin ) )
|
if ( int( eventInfo[3] ) != -1 && !IsDefined( origin ) )
|
||||||
{
|
{
|
||||||
LogDebug( "origin is null but the slot id is " + int( eventInfo[3] ) );
|
LogDebug( "origin is null but the slot id is " + int( eventInfo[3] ) );
|
||||||
@ -529,7 +531,7 @@ AddClientCommand( commandName, shouldRunAsTarget, callback, shouldOverwrite )
|
|||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
level.clientCommandCallbacks[commandName] = callback;
|
level.clientCommandCallbacks[commandName] = callback;
|
||||||
level.clientCommandRusAsTarget[commandName] = shouldRunAsTarget == true; //might speed up things later in case someone gives us a string or number instead of a boolean
|
level.clientCommandRusAsTarget[commandName] = shouldRunAsTarget == true; //might speed up things later in case someone gives us a string or number instead of a boolean
|
||||||
}
|
}
|
||||||
@ -540,6 +542,7 @@ AddClientCommand( commandName, shouldRunAsTarget, callback, shouldOverwrite )
|
|||||||
|
|
||||||
OnClientDataReceived( event )
|
OnClientDataReceived( event )
|
||||||
{
|
{
|
||||||
|
assertEx( isDefined( self ), "player entity is not defined");
|
||||||
clientData = self.pers[level.clientDataKey];
|
clientData = self.pers[level.clientDataKey];
|
||||||
|
|
||||||
if ( event.subtype == "Fail" )
|
if ( event.subtype == "Fail" )
|
||||||
@ -555,15 +558,15 @@ OnClientDataReceived( event )
|
|||||||
{
|
{
|
||||||
clientData.meta = [];
|
clientData.meta = [];
|
||||||
}
|
}
|
||||||
|
|
||||||
metaKey = event.data[0];
|
metaKey = event.data[0];
|
||||||
clientData.meta[metaKey] = event.data[metaKey];
|
clientData.meta[metaKey] = event.data[metaKey];
|
||||||
|
|
||||||
LogDebug( "Meta Key=" + CoerceUndefined( metaKey ) + ", Meta Value=" + CoerceUndefined( event.data[metaKey] ) );
|
LogDebug( "Meta Key=" + CoerceUndefined( metaKey ) + ", Meta Value=" + CoerceUndefined( event.data[metaKey] ) );
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
clientData.permissionLevel = event.data["level"];
|
clientData.permissionLevel = event.data["level"];
|
||||||
clientData.clientId = event.data["clientId"];
|
clientData.clientId = event.data["clientId"];
|
||||||
clientData.lastConnection = event.data["lastConnection"];
|
clientData.lastConnection = event.data["lastConnection"];
|
||||||
@ -577,7 +580,7 @@ OnExecuteCommand( event )
|
|||||||
{
|
{
|
||||||
data = event.data;
|
data = event.data;
|
||||||
response = "";
|
response = "";
|
||||||
|
|
||||||
command = level.clientCommandCallbacks[event.subtype];
|
command = level.clientCommandCallbacks[event.subtype];
|
||||||
runAsTarget = level.clientCommandRusAsTarget[event.subtype];
|
runAsTarget = level.clientCommandRusAsTarget[event.subtype];
|
||||||
executionContextEntity = event.origin;
|
executionContextEntity = event.origin;
|
||||||
@ -586,7 +589,7 @@ OnExecuteCommand( event )
|
|||||||
{
|
{
|
||||||
executionContextEntity = event.target;
|
executionContextEntity = event.target;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( IsDefined( command ) )
|
if ( IsDefined( command ) )
|
||||||
{
|
{
|
||||||
if ( IsDefined( executionContextEntity ) )
|
if ( IsDefined( executionContextEntity ) )
|
||||||
@ -602,7 +605,7 @@ OnExecuteCommand( event )
|
|||||||
{
|
{
|
||||||
LogDebug( "Unknown Client command->" + event.subtype );
|
LogDebug( "Unknown Client command->" + event.subtype );
|
||||||
}
|
}
|
||||||
|
|
||||||
// send back the response to the origin, but only if they're not the target
|
// send back the response to the origin, but only if they're not the target
|
||||||
if ( IsDefined( response ) && response != "" && IsPlayer( event.origin ) && event.origin != event.target )
|
if ( IsDefined( response ) && response != "" && IsPlayer( event.origin ) && event.origin != event.target )
|
||||||
{
|
{
|
||||||
|
@ -1,5 +1,7 @@
|
|||||||
#include common_scripts\utility;
|
#include common_scripts\utility;
|
||||||
|
|
||||||
|
#inline scripts\_integration_utility;
|
||||||
|
|
||||||
Init()
|
Init()
|
||||||
{
|
{
|
||||||
thread Setup();
|
thread Setup();
|
||||||
@ -9,12 +11,12 @@ Setup()
|
|||||||
{
|
{
|
||||||
level endon( "game_ended" );
|
level endon( "game_ended" );
|
||||||
waittillframeend;
|
waittillframeend;
|
||||||
|
|
||||||
level waittill( level.notifyTypes.sharedFunctionsInitialized );
|
level waittill( level.notifyTypes.sharedFunctionsInitialized );
|
||||||
level.eventBus.gamename = "IW5";
|
level.eventBus.gamename = "IW5";
|
||||||
|
|
||||||
scripts\_integration_base::RegisterLogger( ::Log2Console );
|
scripts\_integration_base::RegisterLogger( ::Log2Console );
|
||||||
|
|
||||||
level.overrideMethods[level.commonFunctions.getTotalShotsFired] = ::GetTotalShotsFired;
|
level.overrideMethods[level.commonFunctions.getTotalShotsFired] = ::GetTotalShotsFired;
|
||||||
level.overrideMethods[level.commonFunctions.setDvar] = ::SetDvarIfUninitializedWrapper;
|
level.overrideMethods[level.commonFunctions.setDvar] = ::SetDvarIfUninitializedWrapper;
|
||||||
level.overrideMethods[level.commonFunctions.waittillNotifyOrTimeout] = ::WaitillNotifyOrTimeoutWrapper;
|
level.overrideMethods[level.commonFunctions.waittillNotifyOrTimeout] = ::WaitillNotifyOrTimeoutWrapper;
|
||||||
@ -22,7 +24,7 @@ Setup()
|
|||||||
level.overrideMethods[level.commonFunctions.getXuid] = ::GetXuidWrapper;
|
level.overrideMethods[level.commonFunctions.getXuid] = ::GetXuidWrapper;
|
||||||
level.overrideMethods[level.commonFunctions.waitTillAnyTimeout] = ::WaitTillAnyTimeout;
|
level.overrideMethods[level.commonFunctions.waitTillAnyTimeout] = ::WaitTillAnyTimeout;
|
||||||
RegisterClientCommands();
|
RegisterClientCommands();
|
||||||
|
|
||||||
level notify( level.notifyTypes.gameFunctionsInitialized );
|
level notify( level.notifyTypes.gameFunctionsInitialized );
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -82,45 +84,36 @@ WaitTillAnyTimeout( timeOut, string1, string2, string3, string4, string5 )
|
|||||||
|
|
||||||
GiveWeaponImpl( event, data )
|
GiveWeaponImpl( event, data )
|
||||||
{
|
{
|
||||||
if ( !IsAlive( self ) )
|
_IS_ALIVE( self );
|
||||||
{
|
|
||||||
return self.name + "^7 is not alive";
|
|
||||||
}
|
|
||||||
|
|
||||||
self IPrintLnBold( "You have been given a new weapon" );
|
self IPrintLnBold( "You have been given a new weapon" );
|
||||||
self GiveWeapon( data["weaponName"] );
|
self GiveWeapon( data["weaponName"] );
|
||||||
self SwitchToWeapon( data["weaponName"] );
|
self SwitchToWeapon( data["weaponName"] );
|
||||||
|
|
||||||
return self.name + "^7 has been given ^5" + data["weaponName"];
|
return self.name + "^7 has been given ^5" + data["weaponName"];
|
||||||
}
|
}
|
||||||
|
|
||||||
TakeWeaponsImpl()
|
TakeWeaponsImpl()
|
||||||
{
|
{
|
||||||
if ( !IsAlive( self ) )
|
_IS_ALIVE( self );
|
||||||
{
|
|
||||||
return self.name + "^7 is not alive";
|
|
||||||
}
|
|
||||||
|
|
||||||
self TakeAllWeapons();
|
self TakeAllWeapons();
|
||||||
self IPrintLnBold( "All your weapons have been taken" );
|
self IPrintLnBold( "All your weapons have been taken" );
|
||||||
|
|
||||||
return "Took weapons from " + self.name;
|
return "Took weapons from " + self.name;
|
||||||
}
|
}
|
||||||
|
|
||||||
TeamSwitchImpl()
|
TeamSwitchImpl()
|
||||||
{
|
{
|
||||||
if ( !IsAlive( self ) )
|
_IS_ALIVE( self );
|
||||||
{
|
|
||||||
return self + "^7 is not alive";
|
|
||||||
}
|
|
||||||
|
|
||||||
team = level.allies;
|
team = level.allies;
|
||||||
|
|
||||||
if ( self.team == "allies" )
|
if ( self.team == "allies" )
|
||||||
{
|
{
|
||||||
team = level.axis;
|
team = level.axis;
|
||||||
}
|
}
|
||||||
|
|
||||||
self IPrintLnBold( "You are being team switched" );
|
self IPrintLnBold( "You are being team switched" );
|
||||||
wait( 2 );
|
wait( 2 );
|
||||||
self [[team]]();
|
self [[team]]();
|
||||||
@ -130,10 +123,7 @@ TeamSwitchImpl()
|
|||||||
|
|
||||||
LockControlsImpl()
|
LockControlsImpl()
|
||||||
{
|
{
|
||||||
if ( !IsAlive( self ) )
|
_IS_ALIVE( self );
|
||||||
{
|
|
||||||
return self.name + "^7 is not alive";
|
|
||||||
}
|
|
||||||
|
|
||||||
if ( !IsDefined ( self.isControlLocked ) )
|
if ( !IsDefined ( self.isControlLocked ) )
|
||||||
{
|
{
|
||||||
@ -149,11 +139,11 @@ LockControlsImpl()
|
|||||||
info = [];
|
info = [];
|
||||||
info[ "alertType" ] = "Alert!";
|
info[ "alertType" ] = "Alert!";
|
||||||
info[ "message" ] = "You have been frozen!";
|
info[ "message" ] = "You have been frozen!";
|
||||||
|
|
||||||
self AlertImpl( undefined, info );
|
self AlertImpl( undefined, info );
|
||||||
|
|
||||||
self.isControlLocked = true;
|
self.isControlLocked = true;
|
||||||
|
|
||||||
return self.name + "\'s controls are locked";
|
return self.name + "\'s controls are locked";
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@ -170,11 +160,13 @@ LockControlsImpl()
|
|||||||
|
|
||||||
NoClipImpl()
|
NoClipImpl()
|
||||||
{
|
{
|
||||||
|
_VERIFY_PLAYER_ENT( self );
|
||||||
|
|
||||||
if ( !IsAlive( self ) )
|
if ( !IsAlive( self ) )
|
||||||
{
|
{
|
||||||
self IPrintLnBold( "You are not alive" );
|
self IPrintLnBold( "You are not alive" );
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( !IsDefined ( self.isNoClipped ) )
|
if ( !IsDefined ( self.isNoClipped ) )
|
||||||
{
|
{
|
||||||
self.isNoClipped = false;
|
self.isNoClipped = false;
|
||||||
@ -184,29 +176,29 @@ NoClipImpl()
|
|||||||
{
|
{
|
||||||
SetDvar( "sv_cheats", 1 );
|
SetDvar( "sv_cheats", 1 );
|
||||||
self SetClientDvar( "cg_thirdperson", 1 );
|
self SetClientDvar( "cg_thirdperson", 1 );
|
||||||
|
|
||||||
self God();
|
self God();
|
||||||
self Noclip();
|
self Noclip();
|
||||||
self Hide();
|
self Hide();
|
||||||
SetDvar( "sv_cheats", 0 );
|
SetDvar( "sv_cheats", 0 );
|
||||||
|
|
||||||
self.isNoClipped = true;
|
self.isNoClipped = true;
|
||||||
|
|
||||||
self IPrintLnBold( "NoClip enabled" );
|
self IPrintLnBold( "NoClip enabled" );
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
SetDvar( "sv_cheats", 1 );
|
SetDvar( "sv_cheats", 1 );
|
||||||
self SetClientDvar( "cg_thirdperson", 0 );
|
self SetClientDvar( "cg_thirdperson", 0 );
|
||||||
|
|
||||||
self God();
|
self God();
|
||||||
self Noclip();
|
self Noclip();
|
||||||
self Hide();
|
self Hide();
|
||||||
|
|
||||||
SetDvar( "sv_cheats", 0 );
|
SetDvar( "sv_cheats", 0 );
|
||||||
|
|
||||||
self.isNoClipped = false;
|
self.isNoClipped = false;
|
||||||
|
|
||||||
self IPrintLnBold( "NoClip disabled" );
|
self IPrintLnBold( "NoClip disabled" );
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -215,12 +207,13 @@ NoClipImpl()
|
|||||||
|
|
||||||
HideImpl()
|
HideImpl()
|
||||||
{
|
{
|
||||||
|
_VERIFY_PLAYER_ENT( self );
|
||||||
|
|
||||||
if ( !IsAlive( self ) )
|
if ( !IsAlive( self ) )
|
||||||
{
|
{
|
||||||
self IPrintLnBold( "You are not alive" );
|
self IPrintLnBold( "You are not alive" );
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( !IsDefined ( self.isHidden ) )
|
if ( !IsDefined ( self.isHidden ) )
|
||||||
{
|
{
|
||||||
self.isHidden = false;
|
self.isHidden = false;
|
||||||
@ -230,26 +223,26 @@ HideImpl()
|
|||||||
{
|
{
|
||||||
SetDvar( "sv_cheats", 1 );
|
SetDvar( "sv_cheats", 1 );
|
||||||
self SetClientDvar( "cg_thirdperson", 1 );
|
self SetClientDvar( "cg_thirdperson", 1 );
|
||||||
|
|
||||||
self God();
|
self God();
|
||||||
self Hide();
|
self Hide();
|
||||||
SetDvar( "sv_cheats", 0 );
|
SetDvar( "sv_cheats", 0 );
|
||||||
|
|
||||||
self.isHidden = true;
|
self.isHidden = true;
|
||||||
|
|
||||||
self IPrintLnBold( "Hide enabled" );
|
self IPrintLnBold( "Hide enabled" );
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
SetDvar( "sv_cheats", 1 );
|
SetDvar( "sv_cheats", 1 );
|
||||||
self SetClientDvar( "cg_thirdperson", 0 );
|
self SetClientDvar( "cg_thirdperson", 0 );
|
||||||
|
|
||||||
self God();
|
self God();
|
||||||
self Show();
|
self Show();
|
||||||
SetDvar( "sv_cheats", 0 );
|
SetDvar( "sv_cheats", 0 );
|
||||||
|
|
||||||
self.isHidden = false;
|
self.isHidden = false;
|
||||||
|
|
||||||
self IPrintLnBold( "Hide disabled" );
|
self IPrintLnBold( "Hide disabled" );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -274,6 +267,8 @@ GotoImpl( event, data )
|
|||||||
|
|
||||||
GotoCoordImpl( data )
|
GotoCoordImpl( data )
|
||||||
{
|
{
|
||||||
|
_VERIFY_PLAYER_ENT( self );
|
||||||
|
|
||||||
if ( !IsAlive( self ) )
|
if ( !IsAlive( self ) )
|
||||||
{
|
{
|
||||||
self IPrintLnBold( "You are not alive" );
|
self IPrintLnBold( "You are not alive" );
|
||||||
@ -287,6 +282,8 @@ GotoCoordImpl( data )
|
|||||||
|
|
||||||
GotoPlayerImpl( target )
|
GotoPlayerImpl( target )
|
||||||
{
|
{
|
||||||
|
_VERIFY_PLAYER_ENT( self );
|
||||||
|
|
||||||
if ( !IsAlive( target ) )
|
if ( !IsAlive( target ) )
|
||||||
{
|
{
|
||||||
self IPrintLnBold( target.name + " is not alive" );
|
self IPrintLnBold( target.name + " is not alive" );
|
||||||
@ -299,10 +296,7 @@ GotoPlayerImpl( target )
|
|||||||
|
|
||||||
PlayerToMeImpl( event )
|
PlayerToMeImpl( event )
|
||||||
{
|
{
|
||||||
if ( !IsAlive( self ) )
|
_IS_ALIVE( self );
|
||||||
{
|
|
||||||
return self.name + " is not alive";
|
|
||||||
}
|
|
||||||
|
|
||||||
self SetOrigin( event.origin GetOrigin() );
|
self SetOrigin( event.origin GetOrigin() );
|
||||||
return "Moved here " + self.name;
|
return "Moved here " + self.name;
|
||||||
@ -310,10 +304,7 @@ PlayerToMeImpl( event )
|
|||||||
|
|
||||||
KillImpl()
|
KillImpl()
|
||||||
{
|
{
|
||||||
if ( !IsAlive( self ) )
|
_IS_ALIVE( self );
|
||||||
{
|
|
||||||
return self.name + " is not alive";
|
|
||||||
}
|
|
||||||
|
|
||||||
self Suicide();
|
self Suicide();
|
||||||
self IPrintLnBold( "You were killed by " + self.name );
|
self IPrintLnBold( "You were killed by " + self.name );
|
||||||
@ -323,13 +314,15 @@ KillImpl()
|
|||||||
|
|
||||||
SetSpectatorImpl()
|
SetSpectatorImpl()
|
||||||
{
|
{
|
||||||
|
_VERIFY_PLAYER_ENT( self );
|
||||||
|
|
||||||
if ( self.pers["team"] == "spectator" )
|
if ( self.pers["team"] == "spectator" )
|
||||||
{
|
{
|
||||||
return self.name + " is already spectating";
|
return self.name + " is already spectating";
|
||||||
}
|
}
|
||||||
|
|
||||||
self [[level.spectator]]();
|
self [[level.spectator]]();
|
||||||
self IPrintLnBold( "You have been moved to spectator" );
|
self IPrintLnBold( "You have been moved to spectator" );
|
||||||
|
|
||||||
return self.name + " has been moved to spectator";
|
return self.name + " has been moved to spectator";
|
||||||
}
|
}
|
||||||
|
40
GameFiles/GameInterface/_integration_utility.gsh
Normal file
40
GameFiles/GameInterface/_integration_utility.gsh
Normal file
@ -0,0 +1,40 @@
|
|||||||
|
/*
|
||||||
|
* This file contains reusable preprocessor directives meant to be used on
|
||||||
|
* Plutonium & AlterWare clients that are up to date with the latest version.
|
||||||
|
* Older versions of Plutonium or other clients do not have support for loading
|
||||||
|
* or parsing "gsh" files.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Turn off assertions by removing the following define
|
||||||
|
* gsc-tool will only emit assertions if developer_script dvar is set to 1
|
||||||
|
* In short, you should not need to remove this define. Just turn them off
|
||||||
|
* by using the dvar
|
||||||
|
*/
|
||||||
|
|
||||||
|
#define _INTEGRATION_DEBUG
|
||||||
|
|
||||||
|
#ifdef _INTEGRATION_DEBUG
|
||||||
|
|
||||||
|
#define _VERIFY( cond, msg ) \
|
||||||
|
assertEx( cond, msg )
|
||||||
|
|
||||||
|
#else
|
||||||
|
|
||||||
|
// This works as an "empty" define here with gsc-tool
|
||||||
|
#define _VERIFY( cond, msg )
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
// This function is meant to be used inside "client commands"
|
||||||
|
// If the client is not alive it shall return an error message
|
||||||
|
#define _IS_ALIVE( ent ) \
|
||||||
|
_VERIFY( ent, "player entity is not defined" ); \
|
||||||
|
if ( !IsAlive( ent ) ) \
|
||||||
|
{ \
|
||||||
|
return ent.name + "^7 is not alive"; \
|
||||||
|
}
|
||||||
|
|
||||||
|
// This function should be used to verify if a player entity is defined
|
||||||
|
#define _VERIFY_PLAYER_ENT( ent ) \
|
||||||
|
_VERIFY( ent, "player entity is not defined" )
|
@ -3,14 +3,7 @@
|
|||||||
Allows integration of IW4M-Admin to GSC, mainly used for special commands that need to use GSC in order to work.
|
Allows integration of IW4M-Admin to GSC, mainly used for special commands that need to use GSC in order to work.
|
||||||
But can also be used to read / write metadata from / to a profile and to get the player permission level.
|
But can also be used to read / write metadata from / to a profile and to get the player permission level.
|
||||||
|
|
||||||
|
## Installation Guide
|
||||||
## Installation Plutonium IW5
|
|
||||||
|
|
||||||
|
|
||||||
Move `_integration.gsc` to `%localappdata%\Plutonium\storage\iw5\scripts\`
|
The documentation can be found here: [GameInterface](https://github.com/RaidMax/IW4M-Admin/wiki/GameInterface)
|
||||||
|
|
||||||
|
|
||||||
## Installation IW4x
|
|
||||||
|
|
||||||
|
|
||||||
Move `_integration.gsc` to `IW4x/userraw/scripts`, `IW4x` being the root folder of your game server.
|
|
||||||
|
@ -4,6 +4,7 @@ ECHO "Pluto IW5"
|
|||||||
xcopy /y .\GameInterface\_integration_base.gsc "%LOCALAPPDATA%\Plutonium\storage\iw5\scripts"
|
xcopy /y .\GameInterface\_integration_base.gsc "%LOCALAPPDATA%\Plutonium\storage\iw5\scripts"
|
||||||
xcopy /y .\GameInterface\_integration_shared.gsc "%LOCALAPPDATA%\Plutonium\storage\iw5\scripts"
|
xcopy /y .\GameInterface\_integration_shared.gsc "%LOCALAPPDATA%\Plutonium\storage\iw5\scripts"
|
||||||
xcopy /y .\GameInterface\_integration_iw5.gsc "%LOCALAPPDATA%\Plutonium\storage\iw5\scripts"
|
xcopy /y .\GameInterface\_integration_iw5.gsc "%LOCALAPPDATA%\Plutonium\storage\iw5\scripts"
|
||||||
|
xcopy /y .\GameInterface\_integration_utility.gsh "%LOCALAPPDATA%\Plutonium\storage\iw5\scripts"
|
||||||
xcopy /y .\AntiCheat\IW5\storage\iw5\scripts\_customcallbacks.gsc "%LOCALAPPDATA%\Plutonium\storage\iw5\scripts\mp"
|
xcopy /y .\AntiCheat\IW5\storage\iw5\scripts\_customcallbacks.gsc "%LOCALAPPDATA%\Plutonium\storage\iw5\scripts\mp"
|
||||||
|
|
||||||
ECHO "Pluto T5"
|
ECHO "Pluto T5"
|
||||||
@ -13,8 +14,8 @@ xcopy /y .\GameInterface\_integration_t5.gsc "%LOCALAPPDATA%\Plutonium\storage\t
|
|||||||
xcopy /y .\GameInterface\_integration_t5zm.gsc "%LOCALAPPDATA%\Plutonium\storage\t5\scripts\sp\zom"
|
xcopy /y .\GameInterface\_integration_t5zm.gsc "%LOCALAPPDATA%\Plutonium\storage\t5\scripts\sp\zom"
|
||||||
|
|
||||||
ECHO "Pluto T6"
|
ECHO "Pluto T6"
|
||||||
xcopy /y .\AntiCheat\PT6\storage\t6\scripts\mp\_customcallbacks.gsc "%LOCALAPPDATA%\Plutonium\storage\t6\scripts\mp"
|
|
||||||
xcopy /y .\GameInterface\_integration_base.gsc "%LOCALAPPDATA%\Plutonium\storage\t6\scripts"
|
xcopy /y .\GameInterface\_integration_base.gsc "%LOCALAPPDATA%\Plutonium\storage\t6\scripts"
|
||||||
xcopy /y .\GameInterface\_integration_shared.gsc "%LOCALAPPDATA%\Plutonium\storage\t6\scripts"
|
xcopy /y .\GameInterface\_integration_shared.gsc "%LOCALAPPDATA%\Plutonium\storage\t6\scripts"
|
||||||
xcopy /y .\GameInterface\_integration_t6.gsc "%LOCALAPPDATA%\Plutonium\storage\t6\scripts"
|
xcopy /y .\GameInterface\_integration_t6.gsc "%LOCALAPPDATA%\Plutonium\storage\t6\scripts"
|
||||||
xcopy /y .\GameInterface\_integration_t6zm_helper.gsc "%LOCALAPPDATA%\Plutonium\storage\t6\scripts\zm"
|
xcopy /y .\GameInterface\_integration_t6zm_helper.gsc "%LOCALAPPDATA%\Plutonium\storage\t6\scripts\zm"
|
||||||
|
xcopy /y .\AntiCheat\PT6\storage\t6\scripts\mp\_customcallbacks.gsc "%LOCALAPPDATA%\Plutonium\storage\t6\scripts\mp"
|
||||||
|
Loading…
Reference in New Issue
Block a user