Hi. I am trying to do something like this on C#:
This should send a message to Reynostrum.Code:SendReply(Reynostrum, "Something");
Is this possible?
Thank you.
Solved SendReply to player
Discussion in 'Rust Development' started by Reynostrum, Jan 24, 2016.
-
Wulf Community Admin
If via a command, this would work:
Code:arg.ReplyWith(player, "message");
-
Thanks again Wulf.
I get this: "error CS0103: The name `arg' does not exist in the current context". -
Wulf Community Admin
Example: Rust -
Thanks Wulf.
I did this and it's working like a charm:
Code:foreach (BasePlayer player in BasePlayer.activePlayerList) { if (player.displayName.ToString() == Defensor) { SendReply(player, "something"); } }
-
you should make the name a variable in the method instead of writing a method that will only ever work on 1 name
Code:void MethodName(string name) { foreach (var player in BasePlayer.activePlayerList) { if (player.displayName.ToLower() == name) SendReply(player, "message"); } }
Code:[ChatCommand("testchat")] void cmdtest(BasePlayer player, string command, string[] args) { if (args.Length == 0) SendReply(player, "You need to enter a name"); if (args.Length == 1) { MethodName(args[0].ToLower()); } }
Code:[ConsoleCommand("testchat")] void consoletest(ConsoleSystem.Arg arg) { if (arg.Args.Length == 0) SendReply(arg, "You need to enter a name"); if (arg.Args.Length == 1) { MethodName(arg.Args[0].ToLower()); } }
also you dont need a .ToString() after displayname as it should already be a stringLast edited by a moderator: Jan 24, 2016