Documentation
  • 👋Introduction
  • 📚Guides
    • Useful Links
  • 🆓boii_utils
    • Installation
    • Configuration
    • Modules
    • API
      • Callbacks
      • Characters
      • Commands
      • Cooldowns
      • Debugging
      • Entities
      • Environment
      • Framework Bridge
      • Geometry
      • Items
      • Keys
      • Licences
      • Maths
      • Methods
      • Player
      • Requests
      • Strings
      • Tables
      • Timestamps
      • UI Bridges
      • Vehicles
      • Version
      • XP
      • UI Elements
Powered by GitBook
On this page
  • Accessing the Module
  • Shared
  • add_method(event_name, cb, options?)
  • remove_method(event_name, id)
  • trigger_method(event_name, response)
  1. boii_utils
  2. API

Methods

The methods module provides a system to register, remove, and trigger custom method callbacks on both the client and server. These are useful for extending resource behavior without modifying the core logic.


Accessing the Module

local METHODS <const> = exports.boii_utils:get("modules.methods")

Shared

add_method(event_name, cb, options?)

Adds a method callback to a specific event.

Parameters

Name
Type
Description

event_name

string

Name of the event to hook into.

cb

function

Function to call when the event triggers.

options?

table

Optional table for method filtering/data.

Returns

Type
Description

number

ID of the method for later removal.

Example

METHODS.add("on_some_event", function(data)
    if data.thing == "important" then
        print("Handled important thing")
    end
end)

remove_method(event_name, id)

Removes a method callback from an event.

Parameters

Name
Type
Description

event_name

string

The event name to remove from.

id

number

ID returned from add_method().

Example

local id = METHODS.add("custom_event", function(data) end)
METHODS.remove("custom_event", id)

trigger_method(event_name, response)

Triggers all registered methods for an event. If any method returns false, execution halts.

Parameters

Name
Type
Description

event_name

string

The event to trigger.

response

table

The table passed to all method callbacks.

Returns

Type
Description

boolean

false if any callback returned false, otherwise true.

Example

local success = METHODS.trigger("custom_event", { player = source })
if not success then return end
PreviousMathsNextPlayer

Last updated 1 month ago

🆓