Code:class Broadcaster: def __init__(self): self.Title = "Broadcaster" self.Description = "Easy Broadcasting" self.Author = "NoSharp" self.Version = V(0, 1, 0) def Init(self): command.AddChatCommand("Broadcast %s", self.Plugin, "B") def B(self, server, cmd, args): rust.SendChatMessage(server, "%s")
Getting input from player in Python?
Discussion in 'Rust Development' started by Serenity 3, Jul 28, 2016.
-
Wulf Community Admin
First, you'd need to set an actual chat command, as "Broadcast %s" wouldn't be valid. A valid example could be "broadcast" or similar.
Next, you can get the chat from the args, such as args[0] or by joining all the args together (it's a list essentially.) -
so like:
class Broadcaster:
def __init__(self):
self.Title = "Broadcaster"
self.Description = "This example illustrates how to use a basic configuration file"
self.Author = "NoSharp"
self.Version = V(0, 1, 0)
def Init(self):
command.AddChatCommand("Broadcast", self.Plugin, "B")
def B(self, server, cmd, args):
rust.SendChatMessage(server, "args[0]") -
args[0] is not meant to be a string, remove the "". This will not actually send a chat message to the server, for that, you need the rust.BroadcastChat(string chatname, string message) method.
-
but without the "" around args[0]
-
Your "server" variable is actually referencing the BasePlayer that is running the command (you). I'd change it back to player to avoid confusion.
