fxmanifest per Ped Custom
INFO
Configurazione finale per la risorsa ped.
| Obiettivo | Dettagli |
|---|---|
| Cosa imparerai | • Configurare il fxmanifest per un ped custom completo • Usare SetPedComponentVariation per gli outfit • Diagnosticare gli errori più comuni |
| Prerequisiti | • YFT, YTD, YMT e pedvariation.meta pronti • Script client.lua di base già scritto |
Struttura Finale
custom_ped/
├── fxmanifest.lua
├── client.lua
└── stream/
├── u_m_m_custom_npc.yft ← Modello scheletrato
├── u_m_m_custom_npc.ytd ← Texture
├── u_m_m_custom_npc.ymt ← Meta ped
└── u_m_m_custom_npc.pedvariation.meta ← Varianti outfit
fxmanifest
-- fxmanifest.lua
fx_version 'cerulean'
game 'gta5'
author 'TuoNome'
description 'Ped Custom - NPC Custom'
version '1.0.0'
-- .ymt richiede data_file esplicito
data_file 'PED_METADATA_FILE' 'stream/*.ymt'
-- Stream carica automaticamente yft, ytd, variation
-- ma per sicurezza:
files {
'stream/*.pedvariation.meta',
}
client_script 'client.lua'Script Completo per Test
-- client.lua
local pedHash = GetHashKey('u_m_m_custom_npc')
local isLoaded = false
-- Carica il modello
Citizen.CreateThread(function()
RequestModel(pedHash)
while not HasModelLoaded(pedHash) do
Citizen.Wait(100)
end
isLoaded = true
print('^2[PED] Modello caricato: ' .. pedHash)
end)
-- Spawn NPC
RegisterCommand('spawnped', function()
if not isLoaded then
print('^1[PED] Modello non caricato')
return
end
local coords = GetEntityCoords(PlayerPedId())
local ped = CreatePed(0, pedHash, coords.x + 3, coords.y + 3, coords.z, 0.0, true, false)
-- SetComponentVariation per outfit
SetPedComponentVariation(ped, 0, 0, 0, 0) -- Testa
SetPedComponentVariation(ped, 1, 0, 0, 0) -- Capelli
SetPedComponentVariation(ped, 3, 0, 0, 0) -- Torso
SetPedComponentVariation(ped, 4, 0, 0, 0) -- Gambe
SetPedComponentVariation(ped, 6, 0, 0, 0) -- Scarpe
-- Dai un compito
TaskStandStill(ped, -1)
end, false)
-- Cambia il ped del giocatore
RegisterCommand('myped', function()
if not isLoaded then
print('^1[PED] Modello non caricato')
return
end
SetPlayerModel(PlayerId(), pedHash)
SetModelAsNoLongerNeeded(pedHash)
end, false)
-- Comando ped con vestiti casuali
RegisterCommand('randped', function()
if not isLoaded then return end
local coords = GetEntityCoords(PlayerPedId())
local ped = CreatePed(0, pedHash, coords.x + 3, coords.y + 3, coords.z, 0.0, true, false)
-- Outfit random
for id = 0, 11 do
local maxDraw = GetNumberOfPedDrawableVariations(ped, id) - 1
local maxTex = GetNumberOfPedTextureVariations(ped, id, 0) - 1
if maxDraw >= 0 then
SetPedComponentVariation(ped, id, math.random(0, maxDraw), math.random(0, math.max(0, maxTex)), 0)
end
end
TaskWanderStandard(ped, 10.0, 10)
end, false)Risoluzione Problemi
WARNING
Se il ped non funziona, controlla sempre prima la corrispondenza dei nomi tra YFT, YMT e fxmanifest.
| Problema | Causa | Soluzione |
|---|---|---|
| ”Invalid model” | Hash del modello non corrisponde | Controlla nome nello YFT e YMT |
| Ped senza testa | Component 0 mancante | Verifica YFT ha testa separata |
| Outfit non cambia | Variation.meta non letto | Controlla files {} |
| Ped invisibile in rete | Network flag assente | Usa CreatePed(..., true, false) |
| Crash al cambio ped | YFT corrotto | Riesporta da Blender |
TIP
✅ Modulo Ped completato! Passa al EUP Custom.
Torna alla: Indice Generale