using SharedLibraryCore;
using System.Linq;
using System.Threading.Tasks;
namespace IW4ScriptCommands
{
///
/// Contains basic properties for command information read by gsc
///
class ScriptCommand
{
///
/// Name of the command to execute
///
public string CommandName { get; set; }
///
/// Target client number
///
public int ClientNumber { get; set; }
///
/// Arguments for the script function itself
///
public string[] CommandArguments { get; set; } = new string[0];
public override string ToString() => string.Join(";", new[] { CommandName, ClientNumber.ToString() }.Concat(CommandArguments).Select(_arg => _arg.Replace(";", "")));
///
/// Executes the command
///
/// server to execute the command on
///
public async Task Execute(Server server) => await server.SetDvarAsync("sv_iw4madmin_command", ToString());
}
}