Skip to content

Developer Guide ​

API Reference v3.0.0

For Developers

This guide covers all exports and events available in IF Subtitle. Perfect for integrating with your custom scripts.

Client Export ​

Use this export in any client-side script to show a subtitle.

lua
exports['if-subtitle']:ShowSubtitle(speaker, text, color, icon, persistent, avatar, animation)

Arguments ​

ArgumentTypeDescription
speakerstringName of the character speaking.
textstringThe dialogue text content.
colorstring(Optional) Hex color for speaker name (e.g., '#ff0000').
iconstring(Optional) Emoji/icon to display next to name.
persistentboolean(Optional) If true, subtitle won't auto-hide.
avatarstring(Optional) URL to an image for the avatar.
animationstring(Optional) 'fade', 'slide', 'bounce', 'glow'.

Example ​

lua
exports['if-subtitle']:ShowSubtitle(
    'John',
    'Hello! This is a test subtitle message.',
    '#ff0000',
    '👤',
    false,
    'https://example.com/avatar.png',
    'fade'
)

Clear Subtitles ​

Remove all subtitles from the screen.

lua
exports['if-subtitle']:ClearSubtitles()

Server Exports ​

Show to All Players ​

lua
exports['if-subtitle']:ShowSubtitleToAll(speaker, text, color, icon, persistent, avatar, animation)

Show to Specific Player ​

lua
exports['if-subtitle']:ShowSubtitleToPlayer(targetId, speaker, text, color, icon, persistent, avatar, animation)

Show to Nearby Players ​

lua
exports['if-subtitle']:ShowSubtitleNearby(coords, radius, speaker, text, color, icon, persistent, avatar, animation)
ArgumentTypeDescription
coordsvector3The center coordinates.
radiusnumberDistance in units to broadcast.

Clear Subtitles ​

lua
exports['if-subtitle']:ClearAllSubtitles()        -- Clear for all players
exports['if-subtitle']:ClearPlayerSubtitles(targetId)  -- Clear for specific player

Server Events ​

You can also use events instead of exports:

lua
-- Show to all players
TriggerEvent('subtitle:showToAll', speaker, text, color, icon, persistent, avatar, animation)

-- Show to specific player
TriggerEvent('subtitle:showToPlayer', targetId, speaker, text, color, icon, persistent, avatar, animation)

-- Show to nearby players
TriggerEvent('subtitle:showNearby', coords, radius, speaker, text, color, icon, persistent, avatar, animation)

-- Clear subtitles
TriggerEvent('subtitle:clearAll')
TriggerEvent('subtitle:clearPlayer', targetId)

Best Practices

  • ✅ Keep subtitle text concise (under 60 characters per line)
  • ✅ Use appropriate display durations (3000-7000ms recommended)
  • ✅ Use persistent = true only when necessary (e.g., mission objectives)
  • ✅ Call ClearSubtitles() when done with persistent subtitles
  • ❌ Avoid showing too many subtitles at once

📝 Complete Example ​

Here's a real-world example integrating IF Subtitle with a cutscene:

lua
-- Client-side cutscene dialogue
RegisterNetEvent('cutscene:dialogue', function(dialogues)
    for _, dialogue in ipairs(dialogues) do
        exports['if-subtitle']:ShowSubtitle(
            dialogue.speaker,
            dialogue.text,
            dialogue.color,
            '',
            false,
            dialogue.avatar,
            'fade'
        )
        Wait(dialogue.duration or 3000)
    end
end)

Released under proprietary license.