a library to speed up the development of Fivem scripts and frameworks
fivem-ts - Documentation v0.7.5 • Docs
fivem-ts - Documentation v0.7.5 / Client / Scaleform
Represents a Scaleform in FiveM.
Scaleforms are graphical elements that can be used to render UI components, notifications, or other visual effects in the game. This class provides methods to manage and render scaleforms in different contexts such as 2D, 3D, or screen-space.
Example usage:
import { Scaleform } from 'fivem-ts/client/ui';
const scaleform = new Scaleform("MIDSIZED_MESSAGE");
scaleform.callFunction("SHOW_MIDSIZED_MESSAGE", ["Title", "Message"]);
setTick(async () => {
await scaleform.render2D();
});
new Scaleform(
name
):Scaleform
Creates a new Scaleform instance.
• name: string
The name of the scaleform movie to be loaded.
get
Handle():number
Gets the handle of the scaleform.
number
The handle of the scaleform.
get
IsLoaded():boolean
Checks if the scaleform is loaded.
boolean
true
if the scaleform is loaded; otherwise false
.
get
IsValid():boolean
Checks if the scaleform handle is valid.
boolean
true
if the handle is not zero, indicating a valid handle; otherwise false
.
callFunction(
name
, …args
):void
Calls a function/method on the scaleform movie.
• name: string
Name of the function to call.
• …args: unknown
[]
Additional arguments to pass to the function.
void
dispose():
void
Disposes of the scaleform, freeing associated memory.
This method should be called when the scaleform is no longer needed.
void
load():
Promise
<boolean
>
Loads the scaleform and waits until it is ready to be rendered.
Promise
<boolean
>
A promise that resolves with true
if the scaleform is successfully loaded; otherwise false
after 5 seconds.
render2D():
Promise
<void
>
Renders the scaleform as a fullscreen 2D element.
This method should be called to draw the scaleform on the screen.
Promise
<void
>
A promise that resolves when the rendering is complete.
render2DScreenSpace(
location
,size
):Promise
<void
>
Renders the scaleform in screen space with specified location and size.
• location: PointF
The location on the screen where the scaleform should be rendered.
• size: PointF
The size of the scaleform on the screen.
Promise
<void
>
A promise that resolves when the rendering is complete.
render3D(
position
,rotation
,scale
):Promise
<void
>
Renders the scaleform in a 3D space.
• position: Vector3
The position in 3D space where the scaleform should be rendered.
• rotation: Vector3
The rotation of the scaleform in 3D space.
• scale: Vector3
The scale of the scaleform in 3D space.
Promise
<void
>
A promise that resolves when the rendering is complete.
render3DAdditive(
position
,rotation
,scale
):Promise
<void
>
Renders the scaleform in a 3D space with additive blending.
• position: Vector3
The position in 3D space where the scaleform should be rendered.
• rotation: Vector3
The rotation of the scaleform in 3D space.
• scale: Vector3
The scale of the scaleform in 3D space.
Promise
<void
>
A promise that resolves when the rendering is complete.
setDuration(
duration
):void
Sets a duration for which the scaleform should be displayed.
This is useful for displaying temporary messages or notifications.
• duration: number
Duration in milliseconds for which the scaleform should be displayed.
void