Skip to content

Commit

Permalink
Finish tutorial on how to create a resource
Browse files Browse the repository at this point in the history
  • Loading branch information
Micky5991 committed Nov 27, 2018
1 parent b5beba0 commit 807e1c1
Showing 1 changed file with 24 additions and 5 deletions.
29 changes: 24 additions & 5 deletions documentation/first-resource.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,33 @@
Creating your first resource, is very simple.
All you need is a new **.NET Core 2.1 Class library** with a reference to our NuGet package, more information below.

## Step 0 - Prepare solution and project

The simplest way to prepare the project is by using the `dotnet` CLI. You can skip this step, if you use Visual Studio.

We call our resource, in this example, "MyFirstResource".

```
$ dotnet new sln --name MyFirstResource
$ dotnet new classlib --name MyFirstResource --framework netcoreapp2.1
$ dotnet sln MyFirstResource.sln add MyFirstResource
```

## Step 1 - Install NuGet package

To get started, you need to reference the latest [AlternateLife.RageMP.Net NuGet package](https://www.nuget.org/packages/AlternateLife.RageMP.Net).

```text
PM> Install-Package AlternateLife.RageMP.Net
```
$ dotnet add MyFirstResource package AlternateLife.RageMP.Net
```

## Step 2 - Main class

The server is only able to find your resource, if you create a **single** class that implements our interface [IResource](~/api/AlternateLife.RageMP.Net.Scripting.IResource.yml). The class could look like this.

> [!NOTE]
> This class needs to have a parameterless-constructor, otherwise it is not startable.
```cs
using System.Threading.Tasks;
using AlternateLife.RageMP.Net.Scripting;
Expand All @@ -41,9 +56,9 @@ namespace MyFirstResource
}
```

## Step 3 - Prepare gamemode
## Step 3 - Prepare resource

To finish your first gamemode, you need to copy your compiled `.dll` files to the server's resource folder. If you want to create a resource from the example above, the folder structure looks like this:
To finish your first resource, you need to copy your compiled `.dll` files to the server's resource folder. If you want to create a resource from the example above, the folder structure looks like this:

```text
├── ...
Expand All @@ -53,4 +68,8 @@ To finish your first gamemode, you need to copy your compiled `.dll` files to th
| | └── MyFirstResource.dll
| └── ..
├── ...
```
```

## Step 4 - Start server

The resource should be ready and startable. You can now edit the resource even more and implement your own logic.

0 comments on commit 807e1c1

Please sign in to comment.