Changing a native admin command to chat?
I am trying to make a plugin that lets players use the growableentity.growall command, here is the method that the command uses 

[ServerVar(ServerAdmin = true)]
  public static void GrowAll(ConsoleSystem.Arg arg)
  {
    BasePlayer basePlayer = arg.Player();
    if (!basePlayer.IsAdmin)
      return;
    List<GrowableEntity> list = Facepunch.Pool.GetList<GrowableEntity>();
    Vis.Entities<GrowableEntity>(basePlayer.ServerPosition, 6f, list, -1, QueryTriggerInteraction.Collide);
    foreach (GrowableEntity growableEntity in list)
    {
      if (growableEntity.isServer)
        growableEntity.ChangeState(growableEntity.currentStage.nextState, false, false);
    }
    Facepunch.Pool.FreeList<GrowableEntity>(ref list);
  }

I've tried removing the is player admin checks and putting a ChatCommand above it but I've had no luck, how would I change this to a chat command that non admins can use?

if you want to completely override the command, you can do the following:

object OnServerCommand(ConsoleSystem.Arg arg) { //oxide hook
	if (arg.cmd.Name == "growall") { //check if the command is growall
		//call your custom GrowAll method here: GrowAll(arg);
		return true; //prevents default method execution
	} else {
		return null; //default behavior
	}
}
5e8210c5f386b.jpg Rurido

if you want to completely override the command, you can do the following:

I would register it as a new command instead of just intercepting it:

[ChatCommand("growall")]
private void GrowAll(BasePlayer basePlayer, string command, string[] args)
{
    List<GrowableEntity> list = Facepunch.Pool.GetList<GrowableEntity>();
    Vis.Entities<GrowableEntity>(basePlayer.ServerPosition, 6f, list, -1, QueryTriggerInteraction.Collide);
    foreach (GrowableEntity growableEntity in list)
    {
        if (growableEntity.isServer)
            growableEntity.ChangeState(growableEntity.currentStage.nextState, false, false);
    }
    Facepunch.Pool.FreeList<GrowableEntity>(ref list);
}


That would provide a chat command, but you could override the console command too if desired.

If you use Covalence (universal), you can do both a chat and console command with the same.

ya i got it, just had to remove the admin check, and change the BasePlayer thing to the regular BasePlayer basePlayer