This documentation was generated by ChatGPT.
The GCTV Python API allows script authors to interact with the engine, memory, input devices, GCTV global variables, and more through native Python modules.
- GCT
- GetGCTVersion
- GetGCTStringVersion
- GetGCTFolder
- RunScript
- Restart
- IsScriptsStillWorking
- IsPressedKey
- IsDoubleClickedKey
- ConvertStringToKeyCode
- GetMousePos
- SetMousePos
- New
- NewPointer
- NewPed
- NewVehicle
- NewObject
- NewVector3
- Delete
- DeleteVector3
- GetAllEntities
- GetAllPeds
- GetAllVehicles
- GetAllObjects
- NativeCall
- HashString
- DisplayError
- BindCommand
- UnBindCommand
- IsCommandExist
- Input
- InputFromList
- SetColor
- ResetColor
- printColoured
- GCTOut
- ExternalOut
- help
- Globals
- Game
- Gamepad
Prototype:
GCT.GetGCTVersion() -> intDescription: Returns the version of the GCTV engine as an integer.
Example:
import GCT
version = GCT.GetGCTVersion()
print("GCTV Version:", version)Prototype:
GCT.GetGCTStringVersion() -> strDescription: Returns the current version of the GCTV engine as a formatted string.
Example:
import GCT
version = GCT.GetGCTStringVersion()
print("GCTV String Version:", version)Prototype:
GCT.GetGCTFolder() -> strDescription: Returns the absolute path to the GCT working directory.
Example:
import GCT
path = GCT.GetGCTFolder()
print("GCT root folder:", path)Prototype:
GCT.RunScript(path: str) -> boolDescription:
Runs another script from a given path. Returns True if successful.
Example:
import GCT
if not GCT.RunScript("custom/my_script.py"):
print("Failed to run the script.")Prototype:
GCT.Restart() -> NoneDescription: Restarts all running scripts.
Example:
import GCT
GCT.Restart()Prototype:
GCT.IsScriptsStillWorking() -> boolDescription:
Returns True if scripts are still executing; False if all scripts have stopped.
Prototype:
GCT.IsPressedKey(keyCode: int) -> boolDescription: Checks if a specific key is currently being pressed.
Example:
import GCT
from GTAV import PLAYER, ENTITY
key = GCT.ConvertStringToKeyCode("Space+W")
while GCT.IsScriptsStillWorking():
if GCT.IsPressedKey(key):
# Character Direction
forward_vector = ENTITY.GET_ENTITY_FORWARD_VECTOR(PLAYER.PLAYER_PED_ID())
# Increases the character's speed
ENTITY.SET_ENTITY_VELOCITY(PLAYER.PLAYER_PED_ID(), 20*forward_vector[0], 20*forward_vector[1], 2*forward_vector[2])Prototype:
GCT.IsDoubleClickedKey(keyCode: int) -> intDescription: Checks if a specific key is currently pressed. if it has been pressed only once, returns 1 if it has been pressed twice, returns 2 if it has not been pressed, returns 0.
Example:
import GCT
from GTAV import PLAYER, ENTITY
while GCT.IsScriptsStillWorking():
if not ENTITY.IS_ENTITY_IN_AIR(PLAYER.PLAYER_PED_ID()) and GCT.IsDoubleClickedKey(GCT.ConvertStringToKeyCode("Space")) == 2:
ENTITY.SET_ENTITY_VELOCITY(PLAYER.PLAYER_PED_ID(), 0, 0, 20.0)Prototype:
GCT.ConvertStringToKeyCode(keyName: str) -> intDescription: Converts a key name like "Ctrl+W" into a corresponding key code.
Example:
import GCT
nuclear_missile_launch_keycode = GCT.ConvertStringToKeyCode("Ctrl+1+L+F5")
print("Key code is", nuclearMissileLaunchKeyCode)Prototype:
GCT.GetMousePos() -> tuple[int, int]Description: Retrieves the current mouse position as a table with keys x and y.
Prototype:
GCT.SetMousePos(x: int, y: int) -> NoneDescription: Sets the mouse cursor to the specified (x, y) screen coordinates.
Prototype:
GCT.New(size: int) → intDescription: Allocates memory for a new object and returns its pointer.
Example:
import GCT
PED_STRUCT_SIZE = 4096
ped_struct = GCT.New(PED_STRUCT_SIZE)Prototype:
GCT.New(value: int) → intDescription: Allocates memory for a new pointer.
Example:
import GCT
print(GCT.NewPointer(0x7FF6DC4FADE6))Prototype:
GCT.NewPed(pedID: int) → intDescription: Creates a new pointer to Ped entity and writes the specified value there.
Example:
import GCT
from GTAV import PLAYER
local_player_ped_pointer = GCT.NewPed(PLAYER.PLAYER_PED_ID())Prototype:
GCT.NewVehicle(vehicleID: int) → intDescription: Creates a new pointer to Vehicle entity and writes the specified value there.
Example:
import GCT
from GTAV import PLAYER, PED
local_player_veh = GCT.NewVehicle(PED.GET_VEHICLE_PED_IS_IN(PLAYER.PLAYER_PED_ID(), True))Prototype:
GCT.NewObject(objectID: int) → intDescription: Creates a new pointer to Object entity and writes the specified value there.
Prototype:
GCT.NewVector3(vector: dict) -> intDescription: Allocates memory for a new 3D vector based on a dict with keys x, y, and z, and returns its pointer.
Example:
import GCT
vec_ptr = GCT.NewVector3({"x": 1.0, "y": 2.0, "z": 3.0})Prototype:
GCT.Delete(pointer: int) -> NoneDescription: Frees the memory allocated at the specified pointer.
Example:
import GCT
from GTAV import PLAYER
ped = PLAYER.PLAYER_PED_ID()
ptr = GCT.NewPed(ped)
if ptr:
GCT.Delete(ptr)
else:
print(f"Failed to create pointer to ped: {ped}")Prototype:
GCT.DeleteVector3(pointer: int) -> NoneDescription: Frees memory allocated for a 3D vector.
Example:
import GCT
vec_ptr = GCT.NewVector3({"x": 1.0, "y": 2.0, "z": 3.0})
if vec_ptr:
GCT.DeleteVector3(vec_ptr)Prototype:
GCT.GetAllEntities() -> list[int]Description: Retrieves all game entities as a Python list.
Example:
import GCT
entities = GCT.GetAllEntities()
print(f"Entities count is {len(entities)}")Prototype:
GCT.GetAllPeds() -> list[int]Description: Retrieves all ped entities as a Python list.
Example:
import GCT
from GTAV import PLAYER, ENTITY
peds = GCT.GetAllPeds()
for ped in peds:
if ENTITY.GET_ENTITY_HEALTH(ped) > 0 and ped is not PLAYER.PLAYER_PED_ID():
ENTITY.SET_ENTITY_HEALTH(ped, 0, PLAYER.PLAYER_PED_ID(), 0)Prototype:
GCT.GetAllVehicles() -> list[int]Description: Retrieves all vehicle entities as a Python list.
Example:
import GCT
from GTAV import PLAYER, PED
from random import choice
vehs = GCT.GetAllVehicles()
# Sets the player in a random vehicle in the driver's seat.
PED.SET_PED_INTO_VEHICLE(PLAYER.PLAYER_PED_ID(), choice(vehs), -1) Prototype:
GCT.GetAllObjects() -> list[int]Description: Retrieves all object entities as a Python list.
Prototype:
GCT.NativeCall(functions_hash: int, return_type: str, args: list)Description: Calls a native game function by its hash with the provided arguments. returnType must be: "str|long|int|pointer|float|bool" long -> 32-bit integer int -> 64-bit integer
Example:
import GCT
function_hash = GCT.HashString("SET_RAIN") # MISC.SET_RAIN(intensity: float) -> None
intensity = 0.6
GCT.NativeCall(function_hash, "None", [intensity])Prototype:
GCT.HashString(string: str) -> intDescription: Converts a string to a 64-bit hash.
Example:
import GCT
import Game
# HUD.GET_STREET_NAME_FROM_HASH_KEY(street_hash: int) -> str
function_hash = GCT.HashString("GET_STREET_NAME_FROM_HASH_KEY")
street_hash_ptr = GCT.New(4)
crossing_road = GCT.New(4)
x, y, z = ENTITY.GET_ENTITY_COORDS(PLAYER.PLAYER_PED_ID(), True)
# Returns the hash of the street the player is currently on.
PATHFIND.GET_STREET_NAME_AT_COORD(x, y, z, street_hash_ptr, crossing_road)
street_hash = Game.ReadInt(street_hash_ptr)
GCT.Delete(street_hash_ptr)
GCT.Delete(crossing_road)
# Calling native function GET_STREET_NAME_FROM_HASH_KEY
street_name = GCT.NativeCall(function_hash, "str", [street_hash])
print(f"Player on the {street_name} street")Prototype:
GCT.DisplayError(message: str) -> NoneDescription: Displays an error message with alert formatting in the terminal.
Prototype:
GCT.BindCommand(commandName: str, callback: Callable) -> boolDescription: Binds a Python function to a custom terminal command.
Example:
import GCT
def my_command1():
print("My Command!")
def nocops_mode():
raise NotImplementedError("Soon...")
def blame_lamar():
GCT.Restart()
def summon_chop():
from GTAV import ENTITY, PED, PLAYER, MISC
model = MISC.GET_HASH_KEY("A_C_Chop_02")
# Load model here
coords = ENTITY.GET_ENTITY_COORDS(PLAYER.PLAYER_PED_ID(), True)
chop = PED.CREATE_PED(28, model, coords[0]+3.0, coords[1]+1.0, coords[2]+0.2, 0.0, True, True)
if chop:
print("Created:", chop)
else:
print("Failed to create chop ;(")
# Define a dictionary with commands and their functions
commands = {
"my_command1": my_command1,
"nocops mode" : nocops_mode,
"blame lamar": blame_lamar,
"summon chop": summon_chop
}
for command, function in commands.items():
if not GCT.BindCommand(command, function):
GCT.DisplayError(True, f"Failed to register the command: {command}")Prototype:
GCT.UnBindCommand(commandName: str) -> boolDescription: Removes a command binding.
Example:
import GCT
GCT.UnBindCommand("my_command1")Prototype:
GCT.IsCommandExist(commandName: str) -> boolDescription: Checks if a command with the given name is currently bound.
Example:
import GCT
if GCT.IsCommandExist("my_command1"):
GCT.UnBindCommand("my_command1")Prototype:
GCT.Input(prompt: str) -> strDescription: Displays a prompt and waits for user text input.
Example:
import GCT
name = GCT.Input("Enter your name: ")
print("Hello, " + name)Prototype:
GCT.InputFromList(prompt: str, options: list[str]) -> intDescription: Displays a prompt and a list of options, returns the selected index.
Example:
import GCT
options = ["Apple", "Banana", "Orange", "Lime"]
GCT.printColoured(
"aqua",
"User choice is ",
options[GCT.InputFromList(
"Choose what you want: ",
options
)])Prototype:
GCT.SetColor(color: str) -> NoneDescription: Sets the console text color. Example values: "red", "dark yellow".
Prototype:
GCT.ResetColor() -> NoneDescription: Resets the console color to default.
Prototype:
GCT.printColoured(color: str, message: str) -> NoneParameters:
- color (str): The color name to set the text to. Supported colors are:
- "dark blue"
- "dark green"
- "dark aqua"
- "dark red"
- "dark purple"
- "dark yellow"
- "light gray"
- "dark gray"
- "blue"
- "green"
- "aqua"
- "red"
- "purple"
- "yellow"
- "white"
Description: Prints text in the specified color.
Example:
import GCT
for i in range(10**16):
GCT.printColoured("green", "Hello world!")Prototype:
GCT.GCTOut(text: str) -> NoneDescription: Outputs text to the internal and external GCT console.
Example:
import GCT
GCT.GCTOut("""
_____ _
/ ____| | |
| (___ ___ | |_ ___ _ __
\___ \ / _ \ | __| / _ \ | '__|
____) | | (_) | | |_ | __/ | |
|_____/ \___/ \__| \___| |_|
""")Prototype:
GCT.ExternalOut(*args) -> NoneDescription: Outputs text to the external console (can be redirected or captured).
Example:
import GCT
GCT.ExternalOut("Successfully started!\n")Prototype:
GCT.help() -> NoneDescription: Displays a list of available Python functions in the GCT module.
Prototype:
GCT.Globals.register(name: str, value: Any) -> NoneDescription: Registers a global variable in GCTV's memory space. This global variable becomes accessible to all scripts, including those written in other programming languages supported by the environment. The function supports registering: int, float, str, list[str], list[int], list[float].
Example:
import GCT
# Register an integer
GCT.Global.register("globalInt", 42)
# Register a floating-point number
GCT.Global.register("globalFloat", 3.14159)
# Register a string
GCT.Global.register("globalString", "Hello world")
# Register an array of integers
GCT.Global.register("globalIntArray", [1, 2, 3, 4])
# Register an array of strings
GCT.Global.register("globalStringArray", ["foo", "bar", "baz"])Prototype:
GCT.Globals.get(name: str) -> AnyDescription: Retrieves the value of a global variable previously registered in GCTV's shared memory. The returned value matches the original type of the global variable
Example:
import GCT
int_value : int = GCT.Global.get("globalInt")
str_value : str = GCT.Global.get("globalString")
list_value : list[int] = GCT.Global.get("globalIntArray")Prototype:
GCT.Globals.set(name: str, value: Any) -> NoneDescription: Sets the value of an existing global variable.
Prototype:
GCT.Globals.exists(name: str) -> boolDescription: Checks whether a global variable with the given name exists.
Prototype:
Game.ReadInt(address: int) -> intDescription: Reads a 32-bit integer from memory.
Prototype:
Game.ReadFloat(address: int) -> floatDescription:
Reads a float value from memory.
Prototype:
Game.WriteInt(address: int, value: int) -> NoneDescription:
Writes a 32-bit integer to memory.
Prototype:
Game.WriteFloat(address: int, value: float) -> NoneDescription:
Writes a float value to memory.
Prototype:
Game.ReadByte(address: int) -> intDescription:
Reads a byte (8-bit unsigned int) from memory.
Prototype:
Game.ReadDouble(address: int) -> floatDescription:
Reads a double-precision float from memory.
Prototype:
Game.WriteByte(address: int, value: int) -> NoneDescription:
Writes a byte to memory.
Prototype:
Game.WriteDouble(address: int, value: float) -> NoneDescription:
Writes a double-precision float to memory.
Prototype:
Game.ReadInt64(address: int) -> intDescription:
Reads a 64-bit integer from memory.
Prototype:
Game.WriteInt64(address: int, value: int) -> NoneDescription:
Writes a 64-bit integer to memory.
Prototype:
Game.ReadShort(address: int) -> intDescription:
Reads a 16-bit short from memory.
Prototype:
Game.WriteShort(address: int, value: int) -> NoneDescription:
Writes a 16-bit short to memory.
Prototype:
Game.ReadBytes(address: int, count: int) -> listDescription:
Reads multiple bytes from memory.
Example:
import Game
offset = 0x11ADE6 address = Game.GetBaseAddress() + offset
Prototype:
Game.WriteBytes(address: int, data: list) -> NoneDescription:
Writes multiple bytes to memory.
Prototype:
Game.WriteString(address: int, text: str) -> NoneDescription:
Writes a null-terminated string to memory.
Prototype:
Game.ReadString(address: int, maxLength: int) -> strDescription:
Reads a null-terminated string from memory.
Prototype:
Game.FindValue(start: int, end: int, value: int) -> Optional[int]Description:
Scans memory and returns a list of addresses where the given value is found.
Prototype:
Game.FindPattern(start: int, end: int, pattern: str, mask: str) -> intDescription:
Scans memory for a pattern/signature and returns the first matching address.
Prototype:
Game.GetBaseAddress() -> intDescription:
Returns the base memory address of a loaded module.
Prototype:
Gamepad.Gamepad.select_controller(index: int) -> NoneDescription:
Selects a game controller by index.
Prototype:
Gamepad.Gamepad.get_selected_controller() -> intDescription:
Returns the index of the currently selected controller.
Prototype:
Gamepad.Gamepad.get_pressed_key() -> intDescription:
Returns the last key/button pressed.
Prototype:
Gamepad.Gamepad.get_pressed_keys() -> list[int]Description:
Returns a list of currently pressed keys/buttons.
Prototype:
Gamepad.Gamepad.get_left_stick_state() -> tuple[float, float]Description:
Returns the X and Y axis values of the left analog stick.
Prototype:
Gamepad.Gamepad.get_right_stick_state() -> tuple[float, float]Description:
Returns the X and Y axis values of the right analog stick.
Prototype:
Gamepad.Gamepad.get_triggers_state() -> tuple[float, float]Description:
Returns the current values of the left and right triggers.
Prototype:
Gamepad.Gamepad.send_vibration(left: float, right: float) -> NoneDescription:
Sends vibration feedback to the controller.