Utility Objectify
Take a raw entity and objectify it, make it manageable, programmable, and lifecycle-aware.
Introduction
Utility Objectify is a simple but powerful system that lets you add custom behavior to entities in FiveM.
If you’ve ever worked with Unity’s MonoBehaviour, Unreal Engine Actor classes, or Godot Node scripts, you’ll feel at home, Utility Objectify plays a similar role in making entities scriptable, lifecycle-aware, and easy to manage.
Once you try it, you’ll never want to go back to manually syncing and managing everything, it’s genuinely a game changer.
With it, you can easily attach logic to entities and control their entire lifecycle, from spawning and destruction to handling state changes and more.
Github repo: GitHub - utility-library/utility_objectify: Take this raw entity and objectify it, make it manageable, programmable, lifecycle-aware
Documentation: GitBook | Utility Objectify
Dependencies:
- utility_lib provides
UtilityNetand utility functions. - leap the main preprocessor, makes the magic syntax work
Note:
utility_objectifyis still in development. if it breaks, its probably my fault, not yours.
- Entity-to-Class Binding: Bind any UtilityNet entity to a lua class and manage it with custom logic.
- Lifecycle Hooks: Run functions when entities are spawned, destroyed, or updated.
- State Management: Track and react to changes in an entity’s state.
- Plugins: Bind additional classes to the entity for modular functionality.
The BaseEntity class is the core class that manages the lifecycle of your entities and handles state changes.
It’s designed to be extended by other entity classes, providing basic functionality like OnSpawn, OnDestroy, and state change handling.
@model("mymodel")
@plugin("someplugin")
class MyEntity extends BaseEntity {
OnSpawn = function()
-- Do something when the entity is spawned
end,
OnDestroy = function()
-- Do something when the entity is destroyed
end
}
Yes, this syntax works. no, its not total witchcraft, just leap!
- Simplifies Entity Management: No more messy global variables, scattered functions, manual entity spawning and management.
- Life Cycle Hooks: Automatically handle logic when entities spawn, destroy, or update.
- Modular: Easily add new functionality with plugins making everything reusable.
- State-Driven Logic: Track and respond to changes in your entities states without loops or complex logic.
These are closed source resources, but its just to showcase what can actually be done
i will probably write and share some working examples to showcase also the code, there are already some in the examples/ folder but they are pretty basic
