-
Notifications
You must be signed in to change notification settings - Fork 13
Writing Scripts
This page will provide you with all the information you should know to get started.
For a quick start, have a look at the example scripts.
We highly recommend you to use a Python IDE for writing scripts, like PyCharm (Community Edition).
You can (and should) provide metadata in your script. See metadata.py for an example.
- 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 fromgta.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!
Because each script is an asyncio co-routine, it is highly advised that you read Develop with asyncio before starting.
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.
To run the script in GTA V, copy your .py
script file (or package) into
python/scripts
in your GTA V game folder.
There will be two log files in your GTA V game folder:
-
scripthookvpy3k.log
contains any log output from the Python part of the plugin, including log output from your script. -
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.
Press Ctrl+F12 in game to reload all scripts or Ctrl+Del to just stop them.