-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathExample.cs
More file actions
34 lines (27 loc) · 1.01 KB
/
Example.cs
File metadata and controls
34 lines (27 loc) · 1.01 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
using System;
using DeveloperConsole;
using GTA;
public class Example : Script {
private DeveloperConsole.DeveloperConsole _developerConsole;
public Example() {
//Register our script to use the console
this.RegisterConsoleScript(OnConsoleAttached);
}
private void OnConsoleAttached(DeveloperConsole.DeveloperConsole dc) {
//Initialize console stuff here
_developerConsole = dc;
//Register commands
dc.CommandDispatcher.RegisterCommand(
new CommandDispatcher.Command("ping", "Prints 'pong!' in the console", ExampleCommandEventHandler), true);
//Register Tick/KeyUp/KeyDown events after we have access to the console
Tick += OnTick;
}
private void ExampleCommandEventHandler(CommandDispatcher.CommandEventArgs e) {
//Handle commands
if (e.CommandName == "ping" && e.ArgIndex == 0) {
_developerConsole.PrintLine("pong!");
}
}
private void OnTick(object sender, EventArgs e) {
}
}