2022-10-05 10:49:00 -04:00
|
|
|
#include common_scripts\utility;
|
|
|
|
|
2023-07-17 09:28:14 -04:00
|
|
|
#inline scripts\_integration_utility;
|
|
|
|
|
2022-10-05 10:49:00 -04:00
|
|
|
Init()
|
|
|
|
{
|
2023-04-07 21:42:18 -04:00
|
|
|
thread Setup();
|
2022-10-05 10:49:00 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
Setup()
|
|
|
|
{
|
|
|
|
level endon( "game_ended" );
|
2023-06-01 21:45:05 -04:00
|
|
|
waittillframeend;
|
2023-07-17 09:28:14 -04:00
|
|
|
|
2023-06-01 21:45:05 -04:00
|
|
|
level waittill( level.notifyTypes.sharedFunctionsInitialized );
|
2023-05-28 21:15:52 -04:00
|
|
|
level.eventBus.gamename = "IW5";
|
2023-07-17 09:28:14 -04:00
|
|
|
|
2023-05-28 21:15:52 -04:00
|
|
|
scripts\_integration_base::RegisterLogger( ::Log2Console );
|
2023-07-17 09:28:14 -04:00
|
|
|
|
2023-06-01 21:45:05 -04:00
|
|
|
level.overrideMethods[level.commonFunctions.getTotalShotsFired] = ::GetTotalShotsFired;
|
|
|
|
level.overrideMethods[level.commonFunctions.setDvar] = ::SetDvarIfUninitializedWrapper;
|
|
|
|
level.overrideMethods[level.commonFunctions.waittillNotifyOrTimeout] = ::WaitillNotifyOrTimeoutWrapper;
|
|
|
|
level.overrideMethods[level.commonFunctions.isBot] = ::IsBotWrapper;
|
|
|
|
level.overrideMethods[level.commonFunctions.getXuid] = ::GetXuidWrapper;
|
2023-06-04 20:07:52 -04:00
|
|
|
level.overrideMethods[level.commonFunctions.waitTillAnyTimeout] = ::WaitTillAnyTimeout;
|
2022-10-05 10:49:00 -04:00
|
|
|
RegisterClientCommands();
|
2023-07-17 09:28:14 -04:00
|
|
|
|
2022-10-05 10:49:00 -04:00
|
|
|
level notify( level.notifyTypes.gameFunctionsInitialized );
|
|
|
|
}
|
|
|
|
|
|
|
|
RegisterClientCommands()
|
|
|
|
{
|
2023-05-28 21:15:52 -04:00
|
|
|
scripts\_integration_base::AddClientCommand( "GiveWeapon", true, ::GiveWeaponImpl );
|
|
|
|
scripts\_integration_base::AddClientCommand( "TakeWeapons", true, ::TakeWeaponsImpl );
|
|
|
|
scripts\_integration_base::AddClientCommand( "SwitchTeams", true, ::TeamSwitchImpl );
|
|
|
|
scripts\_integration_base::AddClientCommand( "Hide", false, ::HideImpl );
|
|
|
|
scripts\_integration_base::AddClientCommand( "Alert", true, ::AlertImpl );
|
|
|
|
scripts\_integration_base::AddClientCommand( "Goto", false, ::GotoImpl );
|
|
|
|
scripts\_integration_base::AddClientCommand( "Kill", true, ::KillImpl );
|
|
|
|
scripts\_integration_base::AddClientCommand( "SetSpectator", true, ::SetSpectatorImpl );
|
|
|
|
scripts\_integration_base::AddClientCommand( "LockControls", true, ::LockControlsImpl );
|
|
|
|
scripts\_integration_base::AddClientCommand( "PlayerToMe", true, ::PlayerToMeImpl );
|
|
|
|
scripts\_integration_base::AddClientCommand( "NoClip", false, ::NoClipImpl );
|
2022-10-05 10:49:00 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
GetTotalShotsFired()
|
|
|
|
{
|
|
|
|
return maps\mp\_utility::getPlayerStat( "mostshotsfired" );
|
|
|
|
}
|
|
|
|
|
2023-06-01 21:45:05 -04:00
|
|
|
SetDvarIfUninitializedWrapper( dvar, value )
|
2022-10-05 10:49:00 -04:00
|
|
|
{
|
|
|
|
SetDvarIfUninitialized( dvar, value );
|
|
|
|
}
|
|
|
|
|
2023-06-01 21:45:05 -04:00
|
|
|
WaitillNotifyOrTimeoutWrapper( _notify, timeout )
|
2022-10-05 10:49:00 -04:00
|
|
|
{
|
|
|
|
common_scripts\utility::waittill_notify_or_timeout( _notify, timeout );
|
|
|
|
}
|
|
|
|
|
|
|
|
Log2Console( logLevel, message )
|
|
|
|
{
|
|
|
|
Print( "[" + logLevel + "] " + message + "\n" );
|
|
|
|
}
|
|
|
|
|
2023-06-01 21:45:05 -04:00
|
|
|
IsBotWrapper( client )
|
2023-05-28 21:15:52 -04:00
|
|
|
{
|
2023-06-01 21:45:05 -04:00
|
|
|
return client IsTestClient();
|
2023-05-28 21:15:52 -04:00
|
|
|
}
|
|
|
|
|
2023-06-01 21:45:05 -04:00
|
|
|
GetXuidWrapper()
|
2022-10-05 10:49:00 -04:00
|
|
|
{
|
2023-06-01 21:45:05 -04:00
|
|
|
return self GetXUID();
|
2022-10-05 10:49:00 -04:00
|
|
|
}
|
|
|
|
|
2023-06-04 20:07:52 -04:00
|
|
|
WaitTillAnyTimeout( timeOut, string1, string2, string3, string4, string5 )
|
|
|
|
{
|
|
|
|
return common_scripts\utility::waittill_any_timeout( timeOut, string1, string2, string3, string4, string5 );
|
|
|
|
}
|
|
|
|
|
2022-10-05 10:49:00 -04:00
|
|
|
//////////////////////////////////
|
|
|
|
// Command Implementations
|
|
|
|
/////////////////////////////////
|
|
|
|
|
|
|
|
GiveWeaponImpl( event, data )
|
|
|
|
{
|
2023-07-17 09:28:14 -04:00
|
|
|
_IS_ALIVE( self );
|
|
|
|
|
2022-10-05 10:49:00 -04:00
|
|
|
self IPrintLnBold( "You have been given a new weapon" );
|
|
|
|
self GiveWeapon( data["weaponName"] );
|
|
|
|
self SwitchToWeapon( data["weaponName"] );
|
2023-07-17 09:28:14 -04:00
|
|
|
|
2022-10-05 10:49:00 -04:00
|
|
|
return self.name + "^7 has been given ^5" + data["weaponName"];
|
|
|
|
}
|
|
|
|
|
|
|
|
TakeWeaponsImpl()
|
|
|
|
{
|
2023-07-17 09:28:14 -04:00
|
|
|
_IS_ALIVE( self );
|
|
|
|
|
2022-10-05 10:49:00 -04:00
|
|
|
self TakeAllWeapons();
|
|
|
|
self IPrintLnBold( "All your weapons have been taken" );
|
2023-07-17 09:28:14 -04:00
|
|
|
|
2022-10-05 10:49:00 -04:00
|
|
|
return "Took weapons from " + self.name;
|
|
|
|
}
|
|
|
|
|
|
|
|
TeamSwitchImpl()
|
|
|
|
{
|
2023-07-17 09:28:14 -04:00
|
|
|
_IS_ALIVE( self );
|
|
|
|
|
2022-10-05 10:49:00 -04:00
|
|
|
team = level.allies;
|
2023-07-17 09:28:14 -04:00
|
|
|
|
2022-10-05 10:49:00 -04:00
|
|
|
if ( self.team == "allies" )
|
|
|
|
{
|
|
|
|
team = level.axis;
|
|
|
|
}
|
2023-07-17 09:28:14 -04:00
|
|
|
|
2022-10-05 10:49:00 -04:00
|
|
|
self IPrintLnBold( "You are being team switched" );
|
|
|
|
wait( 2 );
|
|
|
|
self [[team]]();
|
|
|
|
|
|
|
|
return self.name + "^7 switched to " + self.team;
|
|
|
|
}
|
|
|
|
|
|
|
|
LockControlsImpl()
|
|
|
|
{
|
2023-07-17 09:28:14 -04:00
|
|
|
_IS_ALIVE( self );
|
2022-10-05 10:49:00 -04:00
|
|
|
|
|
|
|
if ( !IsDefined ( self.isControlLocked ) )
|
|
|
|
{
|
|
|
|
self.isControlLocked = false;
|
|
|
|
}
|
|
|
|
|
|
|
|
if ( !self.isControlLocked )
|
|
|
|
{
|
|
|
|
self freezeControls( true );
|
|
|
|
self God();
|
|
|
|
self Hide();
|
|
|
|
|
|
|
|
info = [];
|
|
|
|
info[ "alertType" ] = "Alert!";
|
|
|
|
info[ "message" ] = "You have been frozen!";
|
2023-07-17 09:28:14 -04:00
|
|
|
|
2022-10-05 10:49:00 -04:00
|
|
|
self AlertImpl( undefined, info );
|
|
|
|
|
|
|
|
self.isControlLocked = true;
|
2023-07-17 09:28:14 -04:00
|
|
|
|
2022-10-05 10:49:00 -04:00
|
|
|
return self.name + "\'s controls are locked";
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
self freezeControls( false );
|
|
|
|
self God();
|
|
|
|
self Show();
|
|
|
|
|
|
|
|
self.isControlLocked = false;
|
|
|
|
|
|
|
|
return self.name + "\'s controls are unlocked";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
NoClipImpl()
|
|
|
|
{
|
2023-07-17 09:28:14 -04:00
|
|
|
_VERIFY_PLAYER_ENT( self );
|
|
|
|
|
2022-10-05 10:49:00 -04:00
|
|
|
if ( !IsAlive( self ) )
|
|
|
|
{
|
|
|
|
self IPrintLnBold( "You are not alive" );
|
|
|
|
}
|
2023-07-17 09:28:14 -04:00
|
|
|
|
2022-10-05 10:49:00 -04:00
|
|
|
if ( !IsDefined ( self.isNoClipped ) )
|
|
|
|
{
|
|
|
|
self.isNoClipped = false;
|
|
|
|
}
|
|
|
|
|
|
|
|
if ( !self.isNoClipped )
|
|
|
|
{
|
|
|
|
SetDvar( "sv_cheats", 1 );
|
|
|
|
self SetClientDvar( "cg_thirdperson", 1 );
|
2023-07-17 09:28:14 -04:00
|
|
|
|
2022-10-05 10:49:00 -04:00
|
|
|
self God();
|
|
|
|
self Noclip();
|
|
|
|
self Hide();
|
|
|
|
SetDvar( "sv_cheats", 0 );
|
2023-07-17 09:28:14 -04:00
|
|
|
|
2022-10-05 10:49:00 -04:00
|
|
|
self.isNoClipped = true;
|
2023-07-17 09:28:14 -04:00
|
|
|
|
2022-10-05 10:49:00 -04:00
|
|
|
self IPrintLnBold( "NoClip enabled" );
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
SetDvar( "sv_cheats", 1 );
|
|
|
|
self SetClientDvar( "cg_thirdperson", 0 );
|
2023-07-17 09:28:14 -04:00
|
|
|
|
2022-10-05 10:49:00 -04:00
|
|
|
self God();
|
|
|
|
self Noclip();
|
|
|
|
self Hide();
|
2023-07-17 09:28:14 -04:00
|
|
|
|
2022-10-05 10:49:00 -04:00
|
|
|
SetDvar( "sv_cheats", 0 );
|
2023-07-17 09:28:14 -04:00
|
|
|
|
2022-10-05 10:49:00 -04:00
|
|
|
self.isNoClipped = false;
|
2023-07-17 09:28:14 -04:00
|
|
|
|
2022-10-05 10:49:00 -04:00
|
|
|
self IPrintLnBold( "NoClip disabled" );
|
|
|
|
}
|
|
|
|
|
|
|
|
self IPrintLnBold( "NoClip enabled" );
|
|
|
|
}
|
|
|
|
|
|
|
|
HideImpl()
|
|
|
|
{
|
2023-07-17 09:28:14 -04:00
|
|
|
_VERIFY_PLAYER_ENT( self );
|
|
|
|
|
2022-10-05 10:49:00 -04:00
|
|
|
if ( !IsAlive( self ) )
|
|
|
|
{
|
|
|
|
self IPrintLnBold( "You are not alive" );
|
|
|
|
}
|
2023-07-17 09:28:14 -04:00
|
|
|
|
2022-10-05 10:49:00 -04:00
|
|
|
if ( !IsDefined ( self.isHidden ) )
|
|
|
|
{
|
|
|
|
self.isHidden = false;
|
|
|
|
}
|
|
|
|
|
|
|
|
if ( !self.isHidden )
|
|
|
|
{
|
|
|
|
SetDvar( "sv_cheats", 1 );
|
|
|
|
self SetClientDvar( "cg_thirdperson", 1 );
|
2023-07-17 09:28:14 -04:00
|
|
|
|
2022-10-05 10:49:00 -04:00
|
|
|
self God();
|
|
|
|
self Hide();
|
|
|
|
SetDvar( "sv_cheats", 0 );
|
2023-07-17 09:28:14 -04:00
|
|
|
|
2022-10-05 10:49:00 -04:00
|
|
|
self.isHidden = true;
|
2023-07-17 09:28:14 -04:00
|
|
|
|
2022-10-05 10:49:00 -04:00
|
|
|
self IPrintLnBold( "Hide enabled" );
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
SetDvar( "sv_cheats", 1 );
|
|
|
|
self SetClientDvar( "cg_thirdperson", 0 );
|
2023-07-17 09:28:14 -04:00
|
|
|
|
2022-10-05 10:49:00 -04:00
|
|
|
self God();
|
|
|
|
self Show();
|
|
|
|
SetDvar( "sv_cheats", 0 );
|
2023-07-17 09:28:14 -04:00
|
|
|
|
2022-10-05 10:49:00 -04:00
|
|
|
self.isHidden = false;
|
2023-07-17 09:28:14 -04:00
|
|
|
|
2022-10-05 10:49:00 -04:00
|
|
|
self IPrintLnBold( "Hide disabled" );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
AlertImpl( event, data )
|
|
|
|
{
|
2023-06-01 21:45:05 -04:00
|
|
|
self thread maps\mp\gametypes\_hud_message::oldNotifyMessage( data["alertType"], data["message"], undefined, ( 1, 0, 0 ), "ui_mp_nukebomb_timer", 7.5 );
|
2022-10-05 10:49:00 -04:00
|
|
|
return "Sent alert to " + self.name;
|
|
|
|
}
|
|
|
|
|
|
|
|
GotoImpl( event, data )
|
|
|
|
{
|
|
|
|
if ( IsDefined( event.target ) )
|
|
|
|
{
|
|
|
|
return self GotoPlayerImpl( event.target );
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
return self GotoCoordImpl( data );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
GotoCoordImpl( data )
|
|
|
|
{
|
2023-07-17 09:28:14 -04:00
|
|
|
_VERIFY_PLAYER_ENT( self );
|
|
|
|
|
2022-10-05 10:49:00 -04:00
|
|
|
if ( !IsAlive( self ) )
|
|
|
|
{
|
|
|
|
self IPrintLnBold( "You are not alive" );
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
position = ( int( data["x"] ), int( data["y"] ), int( data["z"]) );
|
|
|
|
self SetOrigin( position );
|
|
|
|
self IPrintLnBold( "Moved to " + "("+ position[0] + "," + position[1] + "," + position[2] + ")" );
|
|
|
|
}
|
|
|
|
|
|
|
|
GotoPlayerImpl( target )
|
|
|
|
{
|
2023-07-17 09:28:14 -04:00
|
|
|
_VERIFY_PLAYER_ENT( self );
|
|
|
|
|
2022-10-05 10:49:00 -04:00
|
|
|
if ( !IsAlive( target ) )
|
|
|
|
{
|
|
|
|
self IPrintLnBold( target.name + " is not alive" );
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
self SetOrigin( target GetOrigin() );
|
|
|
|
self IPrintLnBold( "Moved to " + target.name );
|
|
|
|
}
|
|
|
|
|
|
|
|
PlayerToMeImpl( event )
|
|
|
|
{
|
2023-07-17 09:28:14 -04:00
|
|
|
_IS_ALIVE( self );
|
2022-10-05 10:49:00 -04:00
|
|
|
|
|
|
|
self SetOrigin( event.origin GetOrigin() );
|
|
|
|
return "Moved here " + self.name;
|
|
|
|
}
|
|
|
|
|
|
|
|
KillImpl()
|
|
|
|
{
|
2023-07-17 09:28:14 -04:00
|
|
|
_IS_ALIVE( self );
|
2022-10-05 10:49:00 -04:00
|
|
|
|
|
|
|
self Suicide();
|
|
|
|
self IPrintLnBold( "You were killed by " + self.name );
|
|
|
|
|
|
|
|
return "You killed " + self.name;
|
|
|
|
}
|
|
|
|
|
|
|
|
SetSpectatorImpl()
|
|
|
|
{
|
2023-07-17 09:28:14 -04:00
|
|
|
_VERIFY_PLAYER_ENT( self );
|
|
|
|
|
2022-10-05 10:49:00 -04:00
|
|
|
if ( self.pers["team"] == "spectator" )
|
|
|
|
{
|
|
|
|
return self.name + " is already spectating";
|
|
|
|
}
|
2023-07-17 09:28:14 -04:00
|
|
|
|
2022-10-05 10:49:00 -04:00
|
|
|
self [[level.spectator]]();
|
|
|
|
self IPrintLnBold( "You have been moved to spectator" );
|
2023-07-17 09:28:14 -04:00
|
|
|
|
2022-10-05 10:49:00 -04:00
|
|
|
return self.name + " has been moved to spectator";
|
|
|
|
}
|