Permalink
Cannot retrieve contributors at this time
Name already in use
A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
GTAVDeveloperConsole/gtav_console/Example.cs /
Go to fileThis commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
34 lines (27 sloc)
1.01 KB
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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) { | |
| } | |
| } |