Skip to content

alt:V Python Module

Logo

alt:V Python Module, fast and simple Python alt:V implementation

alt:V Python Module adds server-side language support for Python

By installing Python Module you will be able to fully use alt:V server-side API from your Python code

This documentation only explains the Python module itself and assumes you are familiar with alt:V and how to use it.


Let's create your first alt:V Python resource

Requirements

  • Already working alt:V server
  • Basic Python knowledge
  • Basic knowledge of command prompts
  • An IDE or any other code editor

Installation

Installation of the Python Module is really easy

  • Download the latest version of the module for your desired platform
  • Create modules/python-module folder in your alt:V server folder
  • Move all the files from the zip file you downloaded into the folder you created
  • Add into your server.cfg modules column "python-module"
modules: ['python-module']

Now start the server, if you see this message in the console

Python module successfully loaded

Then Python module was installed successfully, and you are good to go

Creating a resource

Creating a resource is identical to creating JavaScript resource

Let's start by creating required files of our resource

For this tutorial we are going to call our resource python

resources/python

resources/python/resource.cfg

resources/python/main.py
Note

Python is currently only supported on server-side, so in this documentation we are only going to create server files, your gamemode will probably have some client files in order to function

There will be few places where we will need to have some client code, in that case we are going to use JavaScript

resource.cfg
type: py
main: main.py
main.py
import alt

alt.log("My First Python Resource Started!")

Now only thing left to do is add the resource into your server.cfg

resources: ['python']

And now when you start your server you should see this message in the console

My First Python Resource Started!

Congratulations, you have just created your first alt:V Python Resource

What's next

In the next few articles you are going to learn how the Python module works and how can you use it

After you read through this documentation you should have solid understanding of how the module works and how to use it.