Hooks
Utility Objectify uses hooks to define and control the lifecycle of object scripts and to support plugin-style behaviors. Hooks are executed at specific moments in an entity’s lifecycle and can be overridden or extended.
OnRegister(coords, rotation)
CLIENT
Triggered when an entity is registered (even if not rendered), this can be used for purposes such as blip creation.
At this stage of execution, the entity and classes instances do not yet exist and so any UtilityNet. function will not work as expected.
The first and second parameters are the coords and rotation of the entity
OnUnregister(coords, rotation)
CLIENT
Triggered when an entity is about to be unregistered or removed from the system. Utilize this hook to execute any necessary cleanup of resources or de-initialization processes. This ensures that no residual data or active references remain that could lead to memory leaks or unexpected behavior.
The first and second parameters are the coords and rotation of the entity
OnAwake
CLIENT SERVER
Triggered just before an entity is spawned. this is useful for initialization or setup before OnSpawn.
OnSpawn
CLIENT SERVER
Triggered right after the entity is rendered/spawned. This occurs following the OnAwake event.
AfterSpawn
CLIENT SERVER
Triggered after all scripts and plugins have been loaded. Ideal for logic that relies on complete initialization.
OnDestroy
CLIENT SERVER
Triggered when the entity is no longer rendered/deleted. Here you can run cleanup processes such as disabling listeners, removing UI components, and any other teardown logic.
OnStateChange(key, value)
CLIENT
Triggered whenever ANY state value changes. Provides the key and value of the changed state as arguments
🧰 Hook Execution Order
OnRegisterCLIENT ONLYOnAwakeOnSpawnAfterSpawnOnDestroy(on unrender or deletion)OnUnregisterCLIENT ONLY
Plugins follow the same order but are initialized after the main script.
Last updated