add set spectator command for game interface

This commit is contained in:
RaidMax 2022-03-01 12:45:39 -06:00
parent 59d69bd22b
commit ec0f59cdb1
2 changed files with 35 additions and 1 deletions

View File

@ -501,7 +501,7 @@ OnExecuteCommand( event )
}
else
{
response = self GotoImpl( event.data );
response = self GotoImpl( data );
}
break;
case "Kill":
@ -510,6 +510,9 @@ OnExecuteCommand( event )
case "NightMode":
NightModeImpl();
break;
case "SetSpectator":
response = event.target SetSpectatorImpl();
break;
}
// send back the response to the origin, but only if they're not the target
@ -712,3 +715,16 @@ ToggleNightMode()
self SetClientDvar( "fx_draw", fxDraw );
self SetClientDvar( "sv_cheats", 0 );
}
SetSpectatorImpl()
{
if ( self.pers["team"] == "spectator" )
{
return self.name + " is already spectating";
}
self [[level.spectator]]();
self IPrintLnBold( "You have been moved to spectator" );
return self.name + " has been moved to spectator";
}

View File

@ -271,6 +271,24 @@ let commands = [{
}
sendScriptCommand(gameEvent.Owner, 'NightMode', gameEvent.Origin, undefined, undefined);
}
},
{
name: 'setspectator',
description: 'sets a player as spectator',
alias: 'spec',
permission: 'Administrator',
targetRequired: true,
arguments: [{
name: 'player',
required: true
}],
supportedGames: ['IW4'],
execute: (gameEvent) => {
if (!validateEnabled(gameEvent.Owner, gameEvent.Origin)) {
return;
}
sendScriptCommand(gameEvent.Owner, 'SetSpectator', gameEvent.Origin, gameEvent.Target, undefined);
}
}];
const sendScriptCommand = (server, command, origin, target, data) => {