Skip to content
Lennart Grahl edited this page Jun 6, 2015 · 2 revisions

Writing Scripts

This page will provide you with all the information you should know to get started.

Quick Start

For a quick start, have a look at the example scripts.

IDE

We highly recommend you to use a Python IDE for writing scripts, like PyCharm (Community Edition).

Metadata

You can (and should) provide metadata in your script. See metadata.py for an example.

Modules

  • Use the gta.requires module if you have one or more requirements that need to be fulfilled (e.g. the player needs to exist for a certain action).
  • Use the gta.events module if you need to wait until a requirement from gta.requires is fulfilled or to wait for keys to be pressed.
  • gta.utils provides several utility functions, including an easy access to a logger.
  • Use the gta_native module for access to all functions from the native db.

You will get to the point where you need to poll for a requirement (e.g. waiting until the player has a weapon or something) that does not exist in the gta.requires module. Please, add your poll function(s) into the gta.requires module and make a pull request with your changes, so the whole community benefits from it!

Asynchronous I/O

Because each script is an asyncio co-routine, it is highly advised that you read Develop with asyncio before starting.

Testing

If you want to mock-test your script, you can run simulate.py in the /python directory. It does not simulate any game logic but it allows you to find basic issues before running the script in game.

Running

To run the script in GTA V, copy your .py script file (or package) into python/scripts in your GTA V game folder.

Debugging

There will be two log files in your GTA V game folder:

  1. scripthookvpy3k.log contains any log output from the Python part of the plugin, including log output from your script.
  2. scripthookvpy3k.wrapper.log contains log output from the C++ part of the plugin. If something goes really wrong (e.g. the game crashes), this is the place to look for.

Reloading

Press Ctrl+F12 in game to reload all scripts or Ctrl+Del to just stop them.