fxmanifest per Suoni Custom

INFO

Configurazione finale della risorsa suoni per FiveM.

ObiettivoDettagli
Cosa imparerai• Configurare il fxmanifest per una risorsa suoni FiveM
• Riprodurre suoni 3D, suoni attaccati a entità e suoni UI in Lua
• Collegare i sound set alle armi custom tramite .weaponanimations.meta
Prerequisiti• File .awd, .dat15 e .rel creati (lezioni precedenti)
• Conoscenza base di Lua

Struttura Finale della Risorsa

custom_sounds/
├── fxmanifest.lua
└── stream/
    ├── weapon_m4a1.awd          ← Audio wave data
    ├── weapon_m4a1.dat15        ← Audio data
    └── weapon_m4a1.rel          ← Sintetizzatore

fxmanifest

-- fxmanifest.lua
fx_version 'cerulean'
game 'gta5'
 
author 'TuoNome'
description 'Suoni Custom - Arma M4A1'
version '1.0.0'
 
-- Registra l'audio wave pack (fondamentale!)
data_file 'AUDIO_WAVEPACK' 'stream/*.awd'
 
-- Se hai anche sintetizzatore e audio data
data_file 'AUDIO_SYNTHESIZER' 'stream/*.rel'
data_file 'AUDIO_DATA' 'stream/*.dat15'
 
client_script 'client.lua'

Client Lua — Riprodurre Suoni

Effetto 3D (posizionato nel mondo)

-- client.lua
 
RegisterCommand('spara', function()
    local playerPed = PlayerPedId()
    local coords = GetEntityCoords(playerPed)
    
    -- Riproduce un suono 3D a una posizione
    PlaySoundFromCoord(
        -1,                     -- Sound ID (-1 = auto)
        'M4A1_FIRE',            -- Nome logico (dal .rel)
        coords.x, coords.y, coords.z,
        'M4A1_SOUNDSET',        -- Sound set (opzionale)
        false,                  -- Se è in loop
        10,                     -- Distanza massima
        false                   -- Se è radio (per veicoli)
    )
end, false)

Suono Attaccato a un Entità

-- Suono che segue un'entità (arma, veicolo)
 
RegisterCommand('sirena', function()
    local vehicle = GetVehiclePedIsIn(PlayerPedId(), false)
    if vehicle ~= 0 then
        PlaySoundFromEntity(
            -1,
            'SIRENE_POLICE',    -- Nome logico
            vehicle,            -- Entità a cui attaccare
            nil,                -- Sound set
            false,              -- Loop
            50                  -- Distanza massima
        )
    end
end, false)

Suono UI (Frontend)

-- Suoni che si sentono nell'HUD (non posizionati)
 
RegisterCommand('notifica', function()
    PlaySoundFrontend(
        -1,
        'NOTIFICATION_ALERT',   -- Nome logico
        'M4A1_SOUNDSET',        -- Sound set
        true                    -- Se può essere interrotto
    )
end, false)

Esempio Completo: Sirena con Loop

-- client.lua
local sirenSound = nil
 
RegisterCommand('sirena_on', function()
    local vehicle = GetVehiclePedIsIn(PlayerPedId(), false)
    if vehicle ~= 0 and sirenSound == nil then
        sirenSound = GetSoundId()
        
        PlaySoundFromEntity(
            sirenSound,
            'SIRENE_POLICE',
            vehicle,
            nil,
            true,   -- Loop
            100
        )
    end
end, false)
 
RegisterCommand('sirena_off', function()
    if sirenSound then
        StopSound(sirenSound)
        ReleaseSoundId(sirenSound)
        sirenSound = nil
    end
end, false)

INFO

Collegamento con Armi

Nel .weaponanimations.meta della tua arma, puoi referenziare il sound set:

<FireAnimFX>
    <FxName>muzzle_flash_m4a1</FxName>
    <SoundSet>M4A1_SOUNDSET</SoundSet>
</FireAnimFX>

E nel .rel devi avere un wave con nome matchato al FireAnim.


WARNING

Errori Comuni

ErroreCausaSoluzione
Nessun suonoAudio data non caricatoAggiungi data_file 'AUDIO_WAVEPACK'
Suono distortoFormato audio erratoUsa WAV 16-bit 44100Hz mono
Suono non si fermaLoop flag erratoControlla loop nel .rel
Suono troppo bassoGain erratoAumenta Gain nel sintetizzatore (0.5 → 1.0)
“Sound not found”Nome logico erratoControlla che Name nel .rel matchi col codice
Click/pop all’inizioTransiente non tagliatoFade In di 0.01s nell’audio

TIP

✅ Modulo Suoni completato! Passa al Modulo 08 — Scripting Lua.


Torna alla: Indice Generale