ConsoleOutput

From GTA Network Wiki
Jump to: navigation, search

ConsoleOutput
Server-Side Function

utilities-terminal.png Server-Side csharp.png C#

This function returns a specified text in server's console.

Syntax

Non-Colored

void NAPI.Util.ConsoleOutput(string text);
void NAPI.Util.ConsoleOutput(string text, params object[] arguments);

Colored

void NAPI.Util.ConsoleOutput(string text, ConsoleColor consoleColor);
void NAPI.Util.ConsoleOutput(string text, IEnumerable<ColoredText> coloredText);
void NAPI.Util.ConsoleOutput(string text, Color textColor, IEnumerable<ColoredText> coloredText);

Required Arguments

  • text: the text that should be displayed in the console. Of string type.

Please refer to String.Format for more information about the formatting.

Usage example

Non-Colored

NAPI.Util.ConsoleOutput("You should see me!");

Result: You should see me!

Colored line

NAPI.Util.ConsoleOutput("You should see me!", ConsoleColor.Blue);

Result: You should see me!

Colored words (non-colored line)

NAPI.Util.ConsoleOutput("You should see me!", new []
{
    new ColoredText { Text = "You", Color = Color.Red },
    new ColoredText { Text = "should", Color = Color.Green },
    new ColoredText { Text = "see", Color = Color.Blue },
    new ColoredText { Text = "me!", Color = Color.Orange }
});

Result: You should see me!

Colored words (colored line)

NAPI.Util.ConsoleOutput("You should see me!", Color.Blue, new []
{
    new ColoredText { Text = "You", Color = Color.Red },
    new ColoredText { Text = "see", Color = Color.Green },
});

Result: You should see me!

Additional example

If you find this useful then you should really go start watching some CSharp learning courses

var list = new List<ColoredText>();
    list.Add(new ColoredText { Text = "You", Color = Color.Red });
    list.Add(new ColoredText { Text = "should", Color = Color.Green });
    list.Add(new ColoredText { Text = "see", Color = Color.Blue });
    list.Add(new ColoredText { Text = "me!", Color = Color.Orange });
NAPI.Util.ConsoleOutput("You should see me!", list);

var list2 = new List<ColoredText>
{
    new ColoredText {Text = "You", Color = Color.Red}, 
    new ColoredText {Text = "should", Color = Color.Green}, 
    new ColoredText {Text = "see", Color = Color.Blue}, 
    new ColoredText {Text = "me!", Color = Color.Orange}
};
NAPI.Util.ConsoleOutput("You should see me!", list2);

var arr = new []
{
    new ColoredText {Text = "You", Color = Color.Red}, 
    new ColoredText {Text = "should", Color = Color.Green}, 
    new ColoredText {Text = "see", Color = Color.Blue}, 
    new ColoredText {Text = "me!", Color = Color.Orange}
};
NAPI.Util.ConsoleOutput("You should see me!", arr);

Result: You should see me!

Changelog

Version Description
1.0 Release.

References