Compare commits

...

1 Commits

Author SHA1 Message Date
Roflmuffin
8cda8d9a50 feat: wrap ExecuteClientCommand and add sound example 2023-11-29 20:10:45 +10:00
2 changed files with 15 additions and 0 deletions

View File

@@ -144,4 +144,10 @@ public partial class CCSPlayerController
/// Gets the active pawns button state. Will work even if the player is dead or observing.
/// </summary>
public PlayerButtons Buttons => (PlayerButtons)Pawn.Value.MovementServices!.Buttons.ButtonStates[0];
public void ExecuteClientCommand(string command)
{
var entityIndex = this.EntityIndex;
if (entityIndex != null) NativeAPI.IssueClientCommand((int)entityIndex.Value.Value - 1, command);
}
}

View File

@@ -481,6 +481,15 @@ namespace TestPlugin
command.ReplyToCommand($" {(char)i}Color 0x{i:x}");
}
}
[ConsoleCommand("css_sound", "Play a sound to client")]
public void OnCommandSound(CCSPlayerController? player, CommandInfo command)
{
if (player == null) return;
if (!player.PlayerPawn.IsValid) return;
player.ExecuteClientCommand($"play sounds/ui/counter_beep.vsnd");
}
[ConsoleCommand("css_pause", "Pause Game")]
public void OnCommandPause(CCSPlayerController? player, CommandInfo command)