Does anyone know how to fix this?
FortWars.cs(570,27): error CS0117: `ConsoleSystem' does not contain a definition for `Broadcast'
Want to run Fortwars on a second server.
Solved ConsoleSystem' does not contain a definition for `Broadcast'
Discussion in 'Rust Development' started by UKz RANDALL, Sep 11, 2016.
-
Wulf Community Admin
-
I looked at that last night and had no success (Still a noob with plugins)
This is the original
void BroadcastToChat(string msg)
{
Debug.Log(msg);
ConsoleSystem.Broadcast("chat.add", new object[] { 0, msg });
}
private void SendChatMessage(BasePlayer player, string message)
{
player?.SendConsoleCommand("chat.add", -1, message);
}
This is what i changed it too
void MessageToAll(string message)
{
Debug.Log(message);
PrintToChat(string.Format(Format)+ message);
}
private void MessageToPlayer(BasePlayer player, string message)
{
PrintToChat(player, string.Format(Format)+ message);
}
Now im getting an error error "CS0103: the name 'format' does not exist in the current context" -
Wulf Community Admin
Why are you trying to make your own chat sending methods? Just use PrintToChat directly. The error is from "format" not existing in your code from what I can tell. -
Like i said still a noob trying to understand the codings etc xD I will learn just need help pointing in the right direction. So instead of using ConsoleSystem.Broadcast i should just use PrintToChat?
-
Wulf Community Admin
No worries, and yes, that would be the best option, less code too. -
Think im a little to stupid for this xD changed
"ConsoleSystem.Broadcast("chat.add", new object[] { 0, msg });" >>> "PrintToChat("chat.add", new object[] { 0, msg });"
Now sitting here with an error "error CS1501: No overload for method `Spawn' takes `1' arguments"
Also would i need to change "player?.SendConsoleCommand("chat.add", -1, message);" i dont know how most of you plugin devs find this so easy lol -
Wulf Community Admin
Broadcasting to all would be: PrintToChat("message goes here")
Sending to one player would be: PrintToChat(player, "message goes here")
The spawn message isn't related to anything mentioned in this thread. -
Fixed it was to do with the entity.spawn(true) changed it to entity.spawn() maybe there is hope of me actually learning this stuff after all appreciate your help wulf
-
Off topic wulf but anyway i can add timed chat commands into the plugin? Want messages every 5 minutes saying how long is left
-
Wulf Community Admin
Check out the Timer library in our Docs or on GitHub. My AutoBroadcast plugin is also an example. -
Thanks for the help on that one!
Now trying to fix another plugin "Mind Freeze" im assuming this is the line causing the error
"current.Player.ClientRPCPlayer(null, current.Player, "ForcePositionTo", new object[] { current.FrozenPosition });"
i looked around and see others suggesting using "Player.ClientRPCPlayer" but using that gives me a new error "error cs0103: The name 'Player' does not exist in the current context".
Any idea's? -
You should maybe start a new thread, because its a complete new topic on an already solved thread.
