-
-
Notifications
You must be signed in to change notification settings - Fork 10
RegisterClientAssets
Jérôme Leclercq edited this page Dec 8, 2020
·
1 revision
API: RegisterClientAssets
Registers an asset that can then be used client-side.
When a player joins the server, they will download all assets they don't have, either from FastDL or from the server itself.
RegisterClientAssets(asset: string)
-
asset: Path to the asset (relative to the resource directory).
- All calls to RegisterClientAssets should be done at initialization, before any player joins.
- Only server-registered assets can be used client-side. If a client script tries to use a non-registered asset it will not be found by the game (independently from the file existence on the dive).
The server and map editor don't have this restriction. - This function exists client-side only for convenience and does nothing when called, as it's commonly called in shared element scripts.
A simple shared.lua entity using a custom asset
-- Registers the script client-side
RegisterClientScript()
-- Registers box.png as a client-side asset
RegisterClientAssets("box.png")
if (CLIENT) then
entity:On("init", function (self)
self:AddSprite({
-- Using the asset
TexturePath = "box.png"
})
end)
end