Hurt a player on command?Solved

I was trying to make a command to hurt a specified player but i'm not sure how to do that because when i run the command it hurts myself.

        [Command("hurt")]
        private void HurtCommand(IPlayer player, string Command, string[] args)
        {
            player.Hurt(50);
        }​

You are using the player object that runs the command, so yes, that will hurt you.

To hurt another player, you would have to specify that via the args and look for that player to hurt.

[Command("hurt")]
private void HurtCommand(IPlayer player, string Command, string[] args)
{
    if (args.Length > 0)
    {
        var target = players.FindPlayer(args[0]);
        if (target != null)
        {
            target.Hurt(50);
        }
    }
}​

Thank you so much!

Locked automatically