Package Protocol: Difference between revisions

From RAGE Multiplayer Wiki
No edit summary
No edit summary
 
(One intermediate revision by the same user not shown)
Line 1: Line 1:
{{JSContainer|
==Summary==
==Summary==
<code>http://package/</code> is the protocol for the root folder of client_packages, so <code>http://package/</code> returns client_packages, makes it easier for you to require files client-side.
<code>http://package/</code> is the protocol for the root folder of `client_packages`, allowing easy access to files client-side.


When referencing to other files in client_packages, you use <pre>http://package/</pre>
When referencing files in `client_packages`, use <pre>http://package/</pre>. Examples:
For example, a file located in '''client_packages\index.html''' can be referred to with <pre>http://package/index.html</pre>
* A file in `client_packages\index.html` can be accessed as <pre>http://package/index.html</pre>.
A file located in '''client_packages\my-resource\index.html''' can be referred to with <pre>http://package/my-resource/index.html</pre>
* A JSON file in `client_packages\my-resource\beasts.json` can be required as <pre>const beasts = require('http://package/my-resource/beasts.json');</pre>.
You can also require json files with it <code>http://package/my-resource/beasts.json</code>, so it'll be <pre>const beasts = require('http://package/my-resource/beasts.json')</pre>  


*'''NOTE''': JSON Require only works in '''CEF'''.
==Package2==
<pre>http://package2/</pre> functions similarly, caching resources for faster access. Works if CEF files are in `client_packages/package2`.
}}

Latest revision as of 16:53, 8 November 2024

JavaScript Syntax


Summary

http://package/ is the protocol for the root folder of `client_packages`, allowing easy access to files client-side.

When referencing files in `client_packages`, use
http://package/
. Examples:
  • A file in `client_packages\index.html` can be accessed as
    http://package/index.html
    .
  • A JSON file in `client_packages\my-resource\beasts.json` can be required as
    const beasts = require('http://package/my-resource/beasts.json');
    .

Package2

http://package2/
functions similarly, caching resources for faster access. Works if CEF files are in `client_packages/package2`.