IPL e Interior
INFO
Gli IPL (Item Placement) e gli interior controllano quali ambienti interni (bagni, uffici, garage sotterranei) sono caricati e accessibili. Con MLO custom la gestione diventa fondamentale.
| Obiettivo | Dettagli |
|---|---|
| Cosa imparerai | • Cos’è un IPL • Caricare e scaricare interior • MLO e entity sets • Pattern con distanza |
| Prerequisiti | • Mappe/MLO (modulo 02) |
1. Cos’è un IPL
In GTA V gli interni non sono sempre caricati: vengono attivati da IPL quando il giocatore è vicino. Su FiveM molti MLO vengono caricati automaticamente via stream/ + .ytyp, ma alcuni richiedono IPL.
2. Caricare/Scaricare un Interior
-- client.lua
local interiorId = GetInteriorAtCoords(x, y, z)
if IsValidInterior(interiorId) then
LoadInterior(interiorId) -- Carica
-- ... opzionale: entity sets
RefreshInterior(interiorId) -- Applica le modifiche
UnloadInterior(interiorId) -- Scarica
end3. Pattern con Distanza
-- client.lua
local interiorCoords = vec3(250.0, -800.0, 30.0)
local radius = 40.0
CreateThread(function()
local loaded = false
while true do
Wait(500)
local coords = GetEntityCoords(PlayerPedId())
local dist = #(coords - interiorCoords)
if dist < radius and not loaded then
local interiorId = GetInteriorAtCoords(interiorCoords.x, interiorCoords.y, interiorCoords.z)
if IsValidInterior(interiorId) then
LoadInterior(interiorId)
loaded = true
end
elseif dist >= radius and loaded then
local interiorId = GetInteriorAtCoords(interiorCoords.x, interiorCoords.y, interiorCoords.z)
if IsValidInterior(interiorId) then
UnloadInterior(interiorId)
loaded = false
end
end
end
end)WARNING
Caricare/scaricare interior in un loop stretto (
Wait(0)) è inutile e costoso. ConWait(500)e una variabile di stato (loaded) è efficiente e pulito. Vedi il pattern usato in fxmanifest per Mappe.
4. Entity Sets negli MLO
Gli entity sets attivano/disattivano parti di un MLO (es. luci, mobili).
-- client.lua
local interiorId = GetInteriorAtCoords(x, y, z)
-- Lista entity set disponibili
local sets = GetEntitySetCount(interiorId) -- numero
-- ... per nome:
if IsInteriorEntitySetEnabled(interiorId, 'set_bank_lights') then
-- già attivo
end
EnableInteriorProp(interiorId, 'set_bank_lights')
RefreshInterior(interiorId)| Funzione | Ruolo |
|---|---|
EnableInteriorProp(id, set) | Attiva un entity set |
DisableInteriorProp(id, set) | Disattiva |
IsInteriorPropEnabled(id, set) | Controlla lo stato |
RefreshInterior(id) | Applica le modifiche |
NOTE
EnableInteriorPropeDisableInteriorPropsono l’API moderna (a volte chiamateEnableInteriorEntitySet/DisableInteriorEntitySetnelle build recenti). Verifica il nome nella tua versione.
5. Collegamento col Modulo Mappe
Gli MLO creati nel modulo Mappe (.ytyp + .ymap) vengono caricati automaticamente. Gli entity set e i portali si gestiscono via script (come sopra). Per interni creati da zero vedi anche Convertire Mappe e MLO.
Verifica
- Interior caricato quando il giocatore si avvicina
- Entity set attivati correttamente
-
RefreshInteriorchiamato dopo le modifiche - Loop con
Wait(500)+ flag di stato
TIP
Prossimo passo: 06 - Discord Webhook
Torna alla: Indice Generale