Is it possible to --> plr.SendConsoleCommand("ent kill")

Hey,

I am still working with the "Discord" Plugin and I am trying to make a specific command for using ent kill.

So this is what I came up with:

 

case "entkill":
			    {
			        if (String.IsNullOrEmpty(param))
			        {
			            Channel.GetChannel(_client, channelid, chan =>
			            {
			                chan.CreateMessage(_client, "Syntax: -entkill <name>");
			            });
			            return;
			        }
			        string[] _param = param.Split(' ');
			        if (_param.Count() < 1)
			        {
			            Channel.GetChannel(_client, channelid, chan =>
			            {
			                chan.CreateMessage(_client, "Syntax: -entkill <name>");
			            });
			            return;
			        }
			        BasePlayer plr = BasePlayer.Find(_param[0]);
			        if (plr == null)
			        {
			            Channel.GetChannel(_client, channelid, chan =>
			            {
			                chan.CreateMessage(_client, "Error: player not found");
			            });
			            return;
			        }

			        timer.Once(2, () =>
			        {
			             Channel.GetChannel(_client, channelid,
			             chan =>
			             {
			             chan.CreateMessage(_client, "In 8 seconds the entity infront of " + _param[0] + " will get destroyed!");
			             });
			         });

                    SendChatMessage(plr, "You will destroy the entity infront of you in 10 seconds be careful! You can destry everything with it!");

                    timer.Once(10, () => plr.SendConsoleCommand("ent kill"));
                       
			        timer.Once(15, () =>
			        {
			            Channel.GetChannel(_client, channelid,
			                chan =>
			                {
			                    chan.CreateMessage(_client, "Entity got destroyed successfully!");
			                });
			        });
                break;
			    }


I tested it and the code works but the point is: It's not destroying the entity in front of me. ---> Reason: Server tried to run the command "kill", but we blocked it. 

Is there any solution to do it?

Best regards,

SkillerFreak

Try to run "ent", "kill" (kill as argument)

Merged post

If it doesn't work, you should use raycast and kill it using the plugin.
In response to misticos ():
Try to run "ent", "kill" (kill as argument)

Merged post

If it doesn't work, yo...
06487595910fc60eea2807c177b5e9b3.png
https://gyazo.com/06487595910fc60eea2807c177b5e9b3
It still shows the same message

Merged post

And I never worked with raycast. So this would be pretty hard for me
No, it's not that hard. As I remember, Physics.Raycast. Specify arguments like point, direction, ...
Then get entity if not null from RaycastHit, and just kill it 
In response to misticos ():
No, it's not that hard. As I remember, Physics.Raycast. Specify arguments like point, direction, ......
Is there any kind of tutorial?
Use JetBrains Rider / MS VS, they will say what to use and what you can get. Google, ask questions here.
If Rust is now blocking "ent kill", the Discord plugin will need to be updated with it's own method for killing entities (as misticos stated).  Here is one method to do that:

object RaycastAll<T> (Ray ray) where T : BaseEntity
{
    var hits = Physics.RaycastAll (ray);
    GamePhysics.Sort (hits);
    var distance = 100f;
    object target = false;
    foreach (var hit in hits) {
        var ent = hit.GetEntity ();
        if (ent is T && hit.distance < distance) {
            target = ent;
            break;
        }
    }

    return target;
}

Then..

object entity = RaycastAll<BaseEntity>(player.eyes.HeadRay());
if(entity is BaseEntity)
{
    ((BaseEntity)entity).Kill();
}​
I don't think you need RaycastAll, only Physics.Raycast, or it works the same way as in your code?
I said it was one method, not the only method.