Class Script
A base class for all user scripts to inherit. Only scripts that inherit directly from this class and have a default (parameterless) public constructor will be detected and started.
Inherited Members
Namespace: GTA
Assembly: ScriptHookVDotNet3.dll
Syntax
public abstract class Script
Constructors
| Improve this Doc View SourceScript()
Declaration
public Script()
Properties
| Improve this Doc View SourceBaseDirectory
Gets the Directory where this Script is stored.
Declaration
public string BaseDirectory { get; }
Property Value
Type | Description |
---|---|
String |
Filename
Gets the filename of this Script.
Declaration
public string Filename { get; }
Property Value
Type | Description |
---|---|
String |
Interval
Gets or sets the interval in ms between Tick for this Script. Default value is 0 meaning the event will execute once each frame.
Declaration
protected int Interval { get; set; }
Property Value
Type | Description |
---|---|
Int32 |
IsExecuting
Checks if this Script is executing.
Declaration
public bool IsExecuting { get; }
Property Value
Type | Description |
---|---|
Boolean |
IsPaused
Checks if this Script is paused.
Declaration
public bool IsPaused { get; }
Property Value
Type | Description |
---|---|
Boolean |
IsRunning
Checks if this Script is running.
Declaration
public bool IsRunning { get; }
Property Value
Type | Description |
---|---|
Boolean |
Name
Gets the name of this Script.
Declaration
public string Name { get; }
Property Value
Type | Description |
---|---|
String |
Settings
Gets an INI file associated with this Script. The File will be in the same location as this Script but with an extension of ".ini". Use this to save and load settings for this Script.
Declaration
public ScriptSettings Settings { get; }
Property Value
Type | Description |
---|---|
ScriptSettings |
Methods
| Improve this Doc View SourceAbort()
Aborts execution of this Script.
Declaration
public void Abort()
GetRelativeFilePath(String)
Gets the full file path for a file relative to this Script.
e.g: GetRelativeFilePath("ScriptFiles\texture1.png")
may return "C:\Program Files\Rockstar Games\Grand Theft Auto V\scripts\ScriptFiles\texture1.png"
.
Declaration
public string GetRelativeFilePath(string filePath)
Parameters
Type | Name | Description |
---|---|---|
String | filePath | The file path relative to the location of this Script. |
Returns
Type | Description |
---|---|
String |
InstantiateScript<T>()
Spawns a new Script instance of the specified type.
Declaration
public static T InstantiateScript<T>()
where T : Script
Returns
Type | Description |
---|---|
T |
Type Parameters
Name | Description |
---|---|
T |
Pause()
Pause execution of this Script.
Declaration
public void Pause()
Resume()
Starts execution of this Script after it has been Paused.
Declaration
public void Resume()
ToString()
Returns a string that represents this Script.
Declaration
public override string ToString()
Returns
Type | Description |
---|---|
String |
Overrides
| Improve this Doc View SourceWait(Int32)
Pauses execution of the Script for a specific amount of time. Must be called inside the main script loop (the Tick event or any sub methods called from it).
Declaration
public static void Wait(int ms)
Parameters
Type | Name | Description |
---|---|---|
Int32 | ms | The time in milliseconds to pause for. |
Yield()
Yields the execution of the script for 1 frame.
Declaration
public static void Yield()
Events
| Improve this Doc View SourceAborted
An event that is raised when this Script gets aborted for any reason. This should be used for cleaning up anything created during this Script.
Declaration
public event EventHandler Aborted
Event Type
Type | Description |
---|---|
EventHandler |
KeyDown
An event that is raised when a key is first pressed. The KeyEventArgs contains the key that was pressed.
Declaration
public event KeyEventHandler KeyDown
Event Type
Type | Description |
---|---|
KeyEventHandler |
KeyUp
An event that is raised when a key is lifted. The KeyEventArgs contains the key that was lifted.
Declaration
public event KeyEventHandler KeyUp
Event Type
Type | Description |
---|---|
KeyEventHandler |
Tick
An event that is raised every tick of the script. Put code that needs to be looped each frame in here.
Declaration
public event EventHandler Tick
Event Type
Type | Description |
---|---|
EventHandler |