Stream Objects
This tutorial will show how to add custom objects to your server. For this tutorial we will use the alt:V logo.
Two ways to add object dlc
There are two ways to add objects.
- Simple
- Long
Simple way
Just throw the dlc.rpf as resource (available since v15)
.
├── resources/
│ └── <your name>/
│ └── dlc.rpf
└── server.toml
Note
resource.toml
is not even needed!
Add your resource to resources
in server.toml
like this:
resources = [
"<your resource name>",
# other resources...
]
Long way
Warning
As of the current state (alt:V 13.x) there are several conditions for the resource name which could crash the client. To avoid those crashes, follow those rules for naming the resource:
- All lowercase
- No special characters
- Must begin with a letter
More information regarding this issue can be found at GitHub issue #436
Suggested tools
Creating the resources
- Open the
dlc.rpf
(or however your rpf file is named) archive with one of suggested tools - Extract the archive like below:
- Place all
ydr
,yft
,ytd
and other assets in the folderstream\assets\
. For organizational reasons, these files can be distributed into subfolders - Place all
ytyp
files into the folderstream\assets\
. Like other files can be distributed into subfolder.
- Place all
- You have to specify the ytyp files in the resources stream.toml. More information at the bottom of this article
Note
'DLC_ITYP_REQUEST'/'.ytyp' is a special case in [meta] declaration.
It must be in the files folder like the object data.
If it doesn't load, check the path to the file including upper/lower case in [meta].
Only the auto load is controlled via the [meta] declaration (you save the alt.loadYtyp in the script)
Folder Structure
altvlogo/
|-> stream/
| |-> assets/
| | |-> tw_altv_logo.ydr
| \ \-> tw_altv_logo.ytyp
|-> resource.toml
\-> stream.toml
resource.toml
type = 'dlc'
main = 'stream.toml'
client-files = [ 'stream/*' ]
stream.toml
files = [ 'stream/assets/*' ]
[meta]
'stream/assets/tw_altv_logo.ytyp' = 'DLC_ITYP_REQUEST'
Add the altvlogo
(folder name is your resource name) to the server.toml
file inside the resource section.
Spawning the object
To spawn the object now, use the following snippet:
import alt from 'alt-client';
const pos = new alt.Vector3(0, 3, 72);
const rot = alt.Vector3.zero;
new alt.LocalObject('tw_altv_logo', pos, rot);