Setting Up a Development Environment using Visual Studio Code

From GTA Network Wiki
Jump to: navigation, search

Setting Up a Development Environment using Visual Studio Code

Requirements

  • Basic C# programming knowledge

Introduction

This page will be going over how to set up a server and write your first resource on any Operating system that supports Visual Studio Code and .NET Core 2.1

A resource is a custom script which can be run on the server or the client.

Installation process

The installation of both applications is automated and install like any other application on your Operating system.

.NET Core App has no graphical interface so you will not see it anywhere on your screen after installing.

Setting Up The Project

Before you setup the project in Visual Studio Code, make sure you have an appropriate directory to place your projects in. Also be sure you have extracted the server files somewhere.

For this tutorial, my server files will be extracted to C:\RAGEMP\server-files as you can see in the screenshot bellow.

explorer 2018-04-30 18-18-46.png


Open the bridge folder (C:\RAGEMP\server-files\bridge), right click on settings.xml and Edit with a reliable text exitor (i.e: Notepad++)

explorer 2018-04-30 18-12-59.png


Considering this is a clean setup, right beneath <resource src="welcomemessages" /> add the following line: <resource src="myresourcename" />

notepad++ 2018-04-30 18-07-40.png

Save and close the Text editor window.


Now that we have our resources settings set up, we're now going to create the resource folder to where resources source files will reside in.

Which as you can see, under the C:\RAGEMP\server-files\bridge\resources directory, I have created my myresourcename folder.

214251.png


Go back to C:\RAGEMP\server-files\ directory and launch the server.exe executable so it creates the resource template

explorer 2018-04-30 18-21-45.png


You should see the following yellow line in the console myresourcename: 'meta.xml' is missing, creating a default resource template.., this means you've got everything set up correctly so far.

server 2018-04-30 18-25-38.png


Setting up Visual Studio Code

Launch Visual Studio Code. You will be greeted by a welcome screen with recent projects listed in the left-hand pane.

Code 2018-04-30 20-16-57.png


Click on "Open Folder", navigate to our resources folder in which for this tutorial is C:\RAGEMP\server-files\bridge\resources, select the resource folder, which in our case is myresourcename and finally click on Select Folder.

Code 2018-04-30 20-20-16.png

IMPORTANT: You'll be interrupted by a dialog stating that some that there are some unresolved dependencies, It is very important that you click on Restore!


Finally, if everything went fine, you should see no issues.

Code 2018-04-30 20-24-57.png

Now you're ready to start scripting!


Conclusion

Setting up a development environment using .NET Core 2.1 and Visual Studio Code is fairly simple, and should be straightforward in every Operating System. There are, of course, other ways to go about it such as using a simple text editor and creating .cs files directly. Visual Studio Code is very nice because Intellisense with the library references is extremely convenient when referencing methods in the API.

If you have any questions, feel free to ask in the thread and I will do my best to help. Have fun scripting!