Resource
A resource is a collection of script files that enables interaction with the game. It can be started and stopped at any time during server operation.
Structure
The structure is represented by a folder within the resources directory in the server files, accompanied by a meta file (meta.xml). The meta file specifies the essential details about the resource. Inside this folder, you should organize all resource files as outlined in the meta file. The internal structure of the folder is flexible, allowing you to arrange files in a way that makes sense to you.
HappinessMP.Server.exe
resources/
├── my-resource-01/
│ ├── bank/
│ │ ├── cl_bank.lua
│ │ └── sv_bank.lua
│ ├── client.lua
│ ├── server.lua
│ └── meta.xml
├── my-resource-02/
│ ├── meta.xml
│ └── ...
addons/
settings.xml
Meta File
The meta file is the configuration file of a resource. It defines which files are loaded and how they should be handled.
<meta type="lua">
<script type="client" src="cl_main.lua" />
<script type="server" src="sv_main.lua" />
<export type="client" function="myClientFunc" />
<export type="server" function="myServerFunc" />
<file src="UI/test.html" />
<file src="UI/script.js" />
</meta>
Both <script> and <file> support glob patterns such as *, **, and ?.
This allows you to include multiple files or entire directories without listing each file individually.
- The
<meta>element is used to specify the scripting language of the resource (lua/squirrel). - Use
<script>elements to specify the scripts to be loaded and define them asclient/serverorsharedscript.- Client scripts are stored encrypted in the server cache and are downloaded and executed by each connecting player.
- Server scripts are executed exclusively by the server.
- Shared scripts do both.
- Use
<export>elements to export functions from this resource, so other resources can use them. - With
<file>elements, you can define files that are to be downloaded by the client in their raw version and are required at a later time. This is necessary for WebUIs, for example.