• 1 Vote(s) - 5 Average
  • 1
  • 2
  • 3
  • 4
  • 5
How to Compile Your Gamemode in Visual Studio Code
#1
Rainbow 
In this guide, I’ll show you how to compile your gamemode using Visual Studio Code. We’ll start by installing the necessary compiler and setting up everything step-by-step.

To begin, we need to install the Pawn Development Tool extension for VSCode. You can either install it through VSCode directly or via this marketplace link: https://marketplace.visualstudio.com/ite...evelopment

If you want to contribute or dive deeper into the project, here’s the source code link: https://github.com/openmultiplayer/vscode-pawn


1. Open Visual Studio Code

[Image: I79gqXu.png]

2. Go to the Extensions Section

  Click on the extensions icon located on the left-hand toolbar.

  [Image: MHGnLFc.png]

3. Search for "Pawn Development Tool

  Type Pawn Development Tool  in the search bar.

  [Image: BZwbxnH.png]

4. Select the First Option

  The first option that appears will be the correct extension.

 [Image: Gn20bcd.png]
 [Image: ddEGnhD.png]

5. Install the Extension

  Click on the install button.

  [Image: iRPcBpq.png]


Now that we’ve installed the extension, let’s move on to setting up the compiler.

1. Navigate to Your Gamemode Directory

  Open your gamemode folder in VSCode.

  [Image: udEWVTm.png]

2. Initialize the Pawn Task/Compiler

  To set up the compiler, press
Quote:Ctrl + Shift + P
 or
Quote:F1
 or go to View > Command Palette. Then, search for Pawn Development: Initialize Pawn Build Task.

  [Image: 5TJxchV.png]

3. Select the Build Task Option

  Click on the result.

  [Image: bWMiWNx.png]


After initializing the task, you might encounter an error when trying to compile, like this:

[Image: xor8F6J.png]

This happens because the compiler doesn’t know the location of `pawncc.exe`. So, we need to set it manually by editing the `tasks.json` file.

1. Open `tasks.json`

  Find the `tasks.json` file in your `.vscode` folder.

  [Image: CdpZCet.png]

2. Specify the Compiler Path

  In the `command` field of `tasks.json`, you need to set the path to your compiler. If you’re using SA-MP Server, you might be using **pawno**, and for open.mp servers, you’ll likely be using qawno. Here’s how to configure each:


Pawno users:
Set the path to `${workspaceRoot}/pawno/pawncc`
Qawno users: Set the path to `${workspaceRoot}/qawno/pawncc`


  Example setup:

  [Image: W7LTtuB.png]
  [Image: TtP9En9.png]


Now, you can compile your gamemode. If everything is set correctly, the compiler should successfully compile your script.

[Image: RIgcgoU.png]

Update:

(Thanks to edgy and Southclaws they helped me figure this out and learn how to set it up!)

You might notice that errors and warnings aren’t being highlighted yet. This is because we haven't set them up properly. Let's fix that by going back to the `tasks.json` file.

[Image: CdpZCet.png]

Adjust the `problemMatcher` Configuration

First, locate the `"problemMatcher"` section in the `tasks.json` file. We need to modify the `"fileLocation"` property.

 Change `"relative"` to `"autoDetect"` so it can automatically detect your gamemode file location.

[Image: KZ6LQlH.png]
[Image: wAL1PMd.png]

Next, update `"${workspaceRoot}"` to `"${workspaceRoot}/gamemodes"` to ensure it's pointing to your gamemode directory.

[Image: kaF7Bud.png]

After making these changes, errors and warnings should now be properly highlighted in your gamemode.

This guide was based on my own experience compiling gamemodes in VSCode. If you notice any mistakes or have suggestions for improvement, feel free to let me know!


Thanks for reading, and good luck with your gamemode development!
  Reply


Forum Jump: