Command for sending message to a specific player?Solved
How can we use the console to send a message to a player only command?
using Say, sends to everyone on the server. I want to be able to execute a command to send to specific player thru command line but not sure how?
You'd need to use or make a plugin to handle that.
@Wulf - Do you know of a way to pass a string or var to a console command that's the part I am stuck on
ConsoleCommand("cmdreply")]
		void cmdDisCommand(ConsoleSystem.Arg arg)
		{
			SendReply(player, arg, player);
		
		}​

I don't think that's right I want to pass the message thru the command so It can display it to the player and not everyone

A Rust-specific method (this will be obsolete soon):

        [ConsoleCommand("reply")]
        private void CommandReply(ConsoleSystem.Arg arg)
        {
            // Check if a command arguments are provided (message and name/ID)
            if (arg.Args.Length >= 2)
            {
                // Try to find a player by name or ID
                BasePlayer target = RustCore.FindPlayer(arg.Args[1]); // This is not accounting for spaces in names, use quotation marks

                // Check if target player was found, or not
                if (target != null)
                {
                    // Send message to the target player
                    PrintToChat(target, arg.Args[0]); // This is not accounting for spaces in messages, use quotation marks
                }
            }
            else
            {
                // Show a message if arguments weren't provided, if you'd like
            }
        }​


A universal method:

        [Command("reply")]
        private void CommandReply(IPlayer player, string command, string[] args)
        {
            // Check if a command arguments are provided (message and name/ID)
            if (arg.Length >= 2)
            {
                // Try to find a player by name or ID
                IPlayer target = players.FindPlayer(args[1]); // This is not accounting for spaces in names, use quotation marks

                // Check if target player was found, or not
                if (target != null)
                {
                    // Send message to the target player
                    target.Message(args[0]); // This is not accounting for spaces in messages, use quotation marks
                }
            }
            else
            {
                // Show a message if arguments weren't provided, if you'd like
            }
        }​
@Wulf _ having issues trying to use either method,
first one sasyy 'RustCore' does not exist in the current context
Universal says 'players' does not exist in the current context

when trying to compile.
You'd need to add the using statements for those. The Univeral method example would require the plugin type set to CovalencePlugin instead of RustPlugin.
@Wulf Got the Rust on to work using the "using Oxide.Game.Rust;" wasnt able to get the  Universal to work though

Merged post

Awww okay that make sense then. SO I can either make a universal plugin using the CovalencePlugin or make a one that stricktly uses RustPlugin. I see I see.
There are ways of mixing, just depends on what is used. I'd focus on the universal example though.
question with the Universal just want to verify this is ONLY sending to the player intended correct?
Yes, the target is the player object.
Sweet I got it working now thank you for all the help.
Locked automatically