Trigger a chat commandSolved

In my plugin I want to be able to trigger chat commands. For example, lets say another plugin registers a command /backpack. I want to be able to trigger that command from within my plugin and pass a player through that way. So its as if that player has typed the command. Is this possible?

You'd be better off calling the method in the specific plugin rather than the command as commands may change. If you want to listen for when the command is called by a player though, there's a hook for that. To run a command as a player though, you'd essentially just run the say command on the specific player's client with the chat command as the chat.

KoXtQEY29GID2qq.png Wulf

You'd be better off calling the method in the specific plugin rather than the command as commands may change. If you want to listen for when the command is called by a player though, there's a hook for that. To run a command as a player though, you'd essentially just run the say command on the specific player's client with the chat command as the chat.

Is that say command essentially messaging as that player then?

If you have time, can you show an example?

player.SendConsoleCommand("chat.add", 2, player.userID, "say /backpack");
hfeHlRiMretV5h0.png Wulf
player.SendConsoleCommand("chat.add", 2, player.userID, "say /backpack");



I just get this happen when I use:

player.SendConsoleCommand("chat.add", 2, player.userID, "say /back");


player.SendConsoleCommand("chat.say \"/backpack\"");
htNM44KZX8WkE6K.png Wulf
player.SendConsoleCommand("chat.say \"/backpack\"");

This works, Thanks :)

Locked automatically