2022-07-01 17:00:42 +08:00
<!DOCTYPE html>
<!-- [if IE]><![endif] -->
< html >
< head >
< meta charset = "utf-8" >
< meta http-equiv = "X-UA-Compatible" content = "IE=edge,chrome=1" >
< title > Getting started | RageCoop resource documentation < / title >
< meta name = "viewport" content = "width=device-width" >
< meta name = "title" content = "Getting started | RageCoop resource documentation " >
< meta name = "generator" content = "docfx 2.59.2.0" >
< link rel = "shortcut icon" href = "favicon.ico" >
< link rel = "stylesheet" href = "styles/docfx.vendor.css" >
< link rel = "stylesheet" href = "styles/docfx.css" >
< link rel = "stylesheet" href = "styles/main.css" >
< meta property = "docfx:navrel" content = "toc.html" >
< meta property = "docfx:tocrel" content = "toc.html" >
< meta property = "docfx:rel" content = "" >
< / head >
< body data-spy = "scroll" data-target = "#affix" data-offset = "120" >
< div id = "wrapper" >
< header >
< nav id = "autocollapse" class = "navbar navbar-inverse ng-scope" role = "navigation" >
< div class = "container" >
< div class = "navbar-header" >
< button type = "button" class = "navbar-toggle" data-toggle = "collapse" data-target = "#navbar" >
< span class = "sr-only" > Toggle navigation< / span >
< span class = "icon-bar" > < / span >
< span class = "icon-bar" > < / span >
< span class = "icon-bar" > < / span >
< / button >
< a class = "navbar-brand" href = "index.html" >
< img id = "logo" class = "svg" src = "logo.svg" alt = "" >
< / a >
< / div >
< div class = "collapse navbar-collapse" id = "navbar" >
< form class = "navbar-form navbar-right" role = "search" id = "search" >
< div class = "form-group" >
< input type = "text" class = "form-control" id = "search-query" placeholder = "Search" autocomplete = "off" >
< / div >
< / form >
< / div >
< / div >
< / nav >
< div class = "subnav navbar navbar-default" >
< div class = "container hide-when-search" id = "breadcrumb" >
< ul class = "breadcrumb" >
< li > < / li >
< / ul >
< / div >
< / div >
< / header >
< div class = "container body-content" >
< div id = "search-results" >
< div class = "search-list" > Search Results for < span > < / span > < / div >
< div class = "sr-items" >
< p > < i class = "glyphicon glyphicon-refresh index-loading" > < / i > < / p >
< / div >
< ul id = "pagination" data-first = "First" data-prev = "Previous" data-next = "Next" data-last = "Last" > < / ul >
< / div >
< / div >
< div role = "main" class = "container body-content hide-when-search" >
< div class = "article row grid" >
< div class = "col-md-10" >
< article class = "content wrap" id = "_content" data-uid = "" >
< h1 id = "getting-started" > Getting started< / h1 >
2022-07-02 11:23:12 +08:00
< h2 id = "resources-and-scripts" > Resources and Scripts< / h2 >
< p > A < strong > Script< / strong > stands for class that inherits from RageCoop's script class ( < a href = "api/RageCoop.Server.Scripting.ServerScript.html" > ServerScript< / a > and < a href = "api/RageCoop.Client.Scripting.ClientScript.html" > ClientScript< / a > ) and will be loaded at runtime, one assembly can have multiple scripts in it.< / p >
< p > A < strong > Resource< / strong > consists of one or more assemblies and other files. Server-side resource will be loaded at startup and is isolated from other resources, while client-side resource will be sent to each client and loaded after they connected to the server. A < strong > Resource< / strong > can either be in a folder or packed inside a zip archive.< / p >
2022-07-01 17:00:42 +08:00
< h2 id = "directory-structure" > Directory structure< / h2 >
< p > Below is the server's directory structure< / p >
< pre > < code > ServerRoot
│ Settings.xml
2022-07-02 11:23:12 +08:00
| RageCoop.Server.exe
2022-07-01 17:00:42 +08:00
│
└───Resources
└───Server
│ │ RageCoop.Resources.Management.zip
│ │ RageCoop.Resources.FreeRoam.Server.zip
│ │
│
│───Client
│ │ RageCoop.Resources.FreeRoam.Client.zip
│ │
│
└───Temp
< / code > < / pre >
< h3 id = "settingsxml" > Settings.xml< / h3 >
2022-07-02 11:23:12 +08:00
< p > This file will be generated first time you started the server, you can then change the server's configuration option by editing it, refer to < a href = "api/RageCoop.Server.ServerSettings.html" > ServerSettings< / a > for detailed description.< / p >
2022-07-01 17:00:42 +08:00
< h2 id = "server-reource" > Server Reource< / h2 >
2022-07-02 11:23:12 +08:00
< p > To create a server resource:< / p >
2022-07-01 17:00:42 +08:00
< ol >
< li > Create a C# class library project targeting .NET 6.0.< / li >
< li > Add reference to < strong > RageCoop.Server.dll< / strong > and < strong > RageCoop.Core.dll< / strong > .< / li >
2022-07-02 11:23:12 +08:00
< li > Add following namespace(s):
2022-07-01 17:00:42 +08:00
< pre > < code > using RageCoop.Server.Scripting;
// Optional
using RageCoop.Server;
using RageCoop.Core.Scripting;
using RageCoop.Core;
< / code > < / pre >
2022-07-02 11:23:12 +08:00
< / li >
2022-07-01 17:00:42 +08:00
< li > Inherit a class from < a href = "api/RageCoop.Server.Scripting.ServerScript.html" > ServerScript< / a > .< / li >
2022-07-02 11:23:12 +08:00
< li > Implement < code > OnStart()< / code > and < code > OnStop()< / code > , your cs file should look like this:
< pre > < code > using RageCoop.Server.Scripting;
namespace NiceGuy.MyFirstResource
2022-07-01 17:00:42 +08:00
{
2022-07-02 11:23:12 +08:00
public class Main : ServerScript
{
public override void OnStart()
{
// Initiate your script here
}
public override void OnStop()
{
// Free all resources and perform cleanup
}
}
2022-07-01 17:00:42 +08:00
}
< / code > < / pre >
2022-07-02 11:23:12 +08:00
< / li >
< li > Now you can have some fun by using the < a href = "api/RageCoop.Server.Scripting.API.html" > API< / a > instance, please refer to the < a href = "https://github.com/RAGECOOP/GTAV-RESOURCES" > GitHub repo< / a > for more examples.< / li >
< li > For convenience, you can create a symlink in < code > ServerRoot/Resources/Server/NiceGuy.MyFirstResource< / code > targeting your output folder:
< pre > < code > mklink /d ServerRoot/Resources/Server/NiceGuy.MyFirstResource C:/MyRepos/NiceGuy.MyFirstResource/bin/Debug
< / code > < / pre >
< / li >
< li > That's it! Start your server and you should see your resource loading.< / li >
2022-07-01 17:00:42 +08:00
< / ol >
< / article >
< / div >
< div class = "hidden-sm col-md-2" role = "complementary" >
< div class = "sideaffix" >
< div class = "contribution" >
< ul class = "nav" >
< / ul >
< / div >
< nav class = "bs-docs-sidebar hidden-print hidden-xs hidden-sm affix" id = "affix" >
< h5 > In This Article< / h5 >
< div > < / div >
< / nav >
< / div >
< / div >
< / div >
< / div >
< footer >
< div class = "grad-bottom" > < / div >
< div class = "footer" >
< div class = "container" >
< span class = "pull-right" >
< a href = "#top" > Back to top< / a >
< / span >
< span > Generated by < strong > DocFX< / strong > < / span >
< / div >
< / div >
< / footer >
< / div >
< script type = "text/javascript" src = "styles/docfx.vendor.js" > < / script >
< script type = "text/javascript" src = "styles/docfx.js" > < / script >
< script type = "text/javascript" src = "styles/main.js" > < / script >
< / body >
< / html >