EvoLabs
  • 👋Welcome
  • Scripts
    • 🔊evo_sound
      • Installation
      • Config
      • Exports
      • Sync System
    • 🔉evo_sound_player
      • Installation
      • Config
      • Exports
      • Hooks (client-side only)
Powered by GitBook
On this page
  1. Scripts
  2. evo_sound

Sync System

We have included a syncronization system to sync sound status between clients.

It works by requesting a sound 'syncObject' from client A and broadcasting it to the client/s you want to sync. There is a global timer on every client based on server time to ensure seamless syncronization. Sync objects contain the following data:

soundId (sound id)
time (global timer current time)
progress (current progress at given time)
playing (playing status at given time)

Example

  1. Request sync object on client, register response from UI and send it to the server

exports["evo_sound"]:getSoundSync(id)

exports["evo_sound"]:onSoundSync(sound.id, function (syncObject)
    TriggerServerEvent('gotSyncObject', syncObject)
end)
  1. Once we have the object on the server we will broadcast it to all clients. We could also store that object and just send it when needed

RegisterNetEvent('gotSyncObject')
AddEventHandler('gotSyncObject', function(syncObject)
    TriggerClientEvent('setSyncObject', -1, syncObject)
end)
  1. Apply that sync object in the client

RegisterNetEvent('setSyncObject')
AddEventHandler('setSyncObject', function(id, syncObject)
    exports["evo_sound"]:setSoundSync(syncObject.soundId, syncObject)
end)
PreviousExportsNextevo_sound_player

Last updated 8 months ago

🔊