API Reference

Client API Reference

Exports

CreateNotification

The main function for creating notifications.

Parameters

{
    type = string,      -- 'success', 'error', 'info', 'warning'
    message = string,   -- The notification message
    title = string,     -- (Optional) Title for advanced style
    position = string,  -- (Optional) Screen position
    duration = number   -- (Optional) Duration in milliseconds
}

Examples

-- Basic usage
exports['b2-sleeknotify']:CreateNotification({
    type = 'success',
    message = 'Basic notification'
})

-- Full options
exports['b2-sleeknotify']:CreateNotification({
    type = 'success',
    title = 'Operation Complete',
    message = 'Action was successful',
    position = 'TOP_RIGHT',
    duration = 5000
})

Events

notifications:create

Event that can be triggered to create a notification.

Usage

TriggerEvent('notifications:create', {
    type = 'success',
    message = 'Event triggered notification'
})

Server API Reference

Exports

SendNotificationToPlayer

Send a notification to a specific player.

exports['b2-sleeknotify']:SendNotificationToPlayer(source, {
    type = 'success',
    message = 'Server notification'
})

SendNotificationToAll

Send a notification to all players.

exports['b2-sleeknotify']:SendNotificationToAll({
    type = 'info',
    title = 'Server Announcement',
    message = 'Server restart in 5 minutes'
})

Events

notifications:server:create

Server event to create notifications.

-- Send to specific player
TriggerClientEvent('notifications:create', playerId, {
    type = 'success',
    message = 'Server message'
})

-- Send to all players
TriggerClientEvent('notifications:create', -1, {
    type = 'info',
    message = 'Broadcast message'
})

Common Use Cases

Server Announcements

-- Restart warning
exports['b2-sleeknotify']:SendNotificationToAll({
    type = 'warning',
    title = 'Server Restart',
    message = 'Server will restart in 5 minutes',
    position = 'TOP_CENTER',
    duration = 10000
})

Player-Specific Notifications

-- Admin action result
exports['b2-sleeknotify']:SendNotificationToPlayer(adminId, {
    type = 'success',
    title = 'Admin Action',
    message = 'Command executed successfully'
})

Last updated