Example Usage

--[[ 
    Even Name: tgiann-sounds:play-sound
    Type: Client
        name = "test1" -- If you want to stop the music and change its data later, set a unique name

        --play your sound on coordinate, player or entity (use one of the 3)
        entity = PlayerPedId() -- Entity ID
        player = GetPlayerServerId(PlayerId()) -- Player Server ID
        coord = vector3(0.0, 0.0, 0.0) -- XYZ Coord

        -- play music/audoi with audio file or youtube url
        soundFile = "alarm" -- tgiann-soundsc\html\sounds
        youtube = "https://www.youtube.com/watch?v=hGtIztv8qno"

        -- Distance settings
        checkDistance = true -- increase in sound with distance
        maxDistance = 4, -- maximum distance that sound can reach

        soundMaxVolume = 0.03 -- Sound volume (max 1.0)
        loop = false -- loop :D
        sync = true -- Sync Full All Player



    Event Name: tgiann-sounds:stop-sound
    Type: Client
        name = "test1" -- the sound name you define
        sync = true -- stop at all players



    Even Name: tgiann-sounds:update-sound-data
    Type: Client
        checkDistance = true -- increase in sound with distance
        maxDistance = 4, -- maximum distance that sound can reach

        soundMaxVolume = 0.03 -- Sound volume (max 1.0)
        loop = false -- loop :D
        sync = true -- update data on all players
]]


RegisterCommand("mute", function(source, args)
    muted = not muted
end)

RegisterCommand("carsync", function()
    local playerPed = PlayerPedId()
    if IsPedInAnyVehicle(playerPed, false) then
        local data = {
            entity = GetVehiclePedIsIn(playerPed, false),
            youtube = "https://www.youtube.com/watch?v=hGtIztv8qno",
            checkDistance = true,
            maxDistance = 10, 
            soundMaxVolume = 1.0,
            loop = false,
            sync = true,
        }
        TriggerEvent("tgiann-sounds:play-sound", data)
    end 
end)

RegisterCommand("playersync", function()
    local playerPed = PlayerPedId()
    local data = {
        player = GetPlayerServerId(PlayerId()),
        youtube = "https://www.youtube.com/watch?v=pEpP_Oo5LSs",
        checkDistance = true,
        maxDistance = 10, 
        soundMaxVolume = 1.0,
        loop = false,
        sync = true,
    }
    TriggerEvent("tgiann-sounds:play-sound", data)
end)

RegisterCommand("coordsync", function()
    local playerPed = PlayerPedId()
    local data = {
        coord = GetEntityCoords(playerPed),
        youtube = "https://www.youtube.com/watch?v=NGVO0MsNqms",
        checkDistance = true,
        maxDistance = 10, 
        soundMaxVolume = 1.0,
        loop = false,
        sync = true,
    }
    TriggerEvent("tgiann-sounds:play-sound", data)
end)

Last updated