On_Console

DreTaX

Probably knows the answer...
Administrator
Jun 29, 2014
4,095
4,813
113
At your house.
github.com
Method:
On_Console

Argument(s):
1: Fougerite.Player player
2: ConsoleEvent event

Examples:
Python:

Python:

def On_Console(self, Player, ConsoleEvent):
if ConsoleEvent.Class == "fougerite": #Class MUST be lowercase !!
if ConsoleEvent.Function == "players":
players = ""
for pl in Server.Players:
players += " " + pl.Name
#Reply with Player list
ConsoleEvent.ReplyWith("Players: " + players)
elif ConsoleEvent.Function == "broadcast":
if not ConsoleEvent.Args:
ConsoleEvent.ReplyWith("Specify a name!")
return
message = str.join(' ', ConsoleEvent.Args)
Server.Broadcast(message)
Javascript:
JavaScript:

function On_Console(Player, ConsoleEvent)
{
if (ConsoleEvent.Class == "fougerite") //Class MUST be lowercase !!
{
if (ConsoleEvent.Function == "players")
{
var players = "";
for (var pl in Server.Players) {
players += " " + pl.Name;
}
//Reply with player list
ConsoleEvent.ReplyWith("Players: " + players);
}
}
}

C#:
C#:

public override void Initialize() {
Hooks.OnConsoleReceived += OnConsole;
}

C#:

public override void DeInitialize() {
Hooks.OnConsoleReceived -= OnConsole;
}
C#:

public void OnConsole(ref ConsoleSystem.Arg arg, bool external)
{
// Classname.FunctionName
string PClass = arg.Class;
string Pfunction = arg.Function;
if (PClass == "myclassname" && Pfunction == "myfunction") //Class MUST be lowercase !!
{
if (!external) //If this is false it means It's from game console.
{
NetUser User = arg.argUser;
if (User.admin)
{
var players = "";
foreach (var pl in Server.Players) {
players += " " + pl.Name;
}
//Reply with player list
ConsoleEvent.ReplyWith("Players: " + players);
}
}
}
}