{"id":93579,"date":"2024-02-05T09:21:58","date_gmt":"2024-02-05T08:21:58","guid":{"rendered":"https:\/\/fivem-mods.net\/?p=93579"},"modified":"2026-08-16T13:42:41","modified_gmt":"2026-08-16T11:42:41","slug":"come-ridurre-la-densita-degli-npc","status":"publish","type":"post","link":"https:\/\/fivemx.com\/it\/come-ridurre-la-densita-degli-npc\/","title":{"rendered":"How to Reduce NPC Density in FiveM Safely"},"content":{"rendered":"<!-- fivemx-content-rework-remaining:2026-07-20:how-to-reduce-npcs-density -->\n<section class=\"fivemx-content-rework-remaining\">\n<p><strong>Risposta rapida:<\/strong> reduce ambient NPCs and traffic with a small client resource that calls the density multiplier natives every frame. Include both <code data-no-translation=\"\">fxmanifest.lua<\/code> and the client Lua file, start with a moderate value on staging, and measure the same route before and after. Do not promise an FPS gain: the result depends on the wider client resource and asset workload.<\/p>\n<\/section>\n\n\n<p class=\"wp-block-paragraph\">A volte, potresti voler ridurre il numero di personaggi non giocabili (PNG) o la loro densit\u00e0 nel mondo di gioco per migliorare le prestazioni del server o creare scenari di gioco specifici. In questo tutorial, ti mostreremo come ridurre il numero di PNG in FiveM.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Nota<\/strong>: Ridurre la densit\u00e0 degli NPC potrebbe richiedere una certa conoscenza dello scripting lato server in FiveM. Assicurati di avere accesso amministrativo al tuo server FiveM e di avere una conoscenza di base dello scripting Lua.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Prerequisiti<\/strong>:<\/p>\n\n\n\n<ol class=\"wp-block-list\">\n<li>Un server FiveM. (<a href=\"https:\/\/fivemx.com\/it\/come-creare-un-server-fivem\/\" target=\"_blank\" data-type=\"link\" data-id=\"https:\/\/fivemx.com\/how-to-create-a-fivem-server\/\" rel=\"noreferrer noopener\">Come impostare<\/a>)<\/li>\n\n\n\n<li>Accesso amministrativo al server.<\/li>\n\n\n\n<li>Un editor di testo (ad esempio, <a href=\"https:\/\/notepad-plus-plus.org\/downloads\/\" target=\"_blank\" data-type=\"link\" data-id=\"https:\/\/notepad-plus-plus.org\/downloads\/\" rel=\"noreferrer noopener\">Blocco note++<\/a>) per modificare gli script Lua.<\/li>\n\n\n\n<li>Conoscenza di base dello scripting Lua.<\/li>\n<\/ol>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Passi<\/strong>:<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>1. Accedi al tuo server FiveM:<\/strong><\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Assicurati di avere accesso SSH o RDP al tuo server FiveM oppure di avere accesso al suo pannello di controllo.<\/li>\n<\/ul>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>2. Individua la cartella delle risorse:<\/strong><\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Vai alla directory principale del tuo server FiveM.<\/li>\n\n\n\n<li>Trova la cartella &quot;risorse&quot;: qui si trovano gli script e le risorse del tuo server.<\/li>\n<\/ul>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>3. Crea un nuovo script Lua:<\/strong><\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>All&#039;interno della cartella &quot;resources&quot;, se necessario, crea una nuova directory, ad esempio &quot;npc_reducer&quot;.<\/li>\n\n\n\n<li>Dentro <code data-no-translation=\"\">npc_reducer<\/code>, creare <code data-no-translation=\"\">fxmanifest.lua<\/code> and a client script such as <code data-no-translation=\"\">reduce_npc_density.lua<\/code>. The manifest must declare the Lua file as a <code data-no-translation=\"\">client_script<\/code> or FiveM will not detect and load it as described below.<\/li>\n<\/ul>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>4. Modifica lo script Lua:<\/strong><\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Apri il file \u201creduce_npc_density.lua\u201d con il tuo editor di testo preferito.<\/li>\n\n\n\n<li>Aggiungere il seguente codice Lua al file:<\/li>\n<\/ul>\n\n\n\n<pre data-no-translation=\"\" class=\"EnlighterJSRAW\" data-enlighter-language=\"lua\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\"> Citizen.CreateThread(function()\n while true do\n Citizen.Wait(0)\n -- Adjust the number below to set the desired NPC density.\n local newDensity = 0.1 -- Modify this value as needed.\n SetVehicleDensityMultiplierThisFrame(newDensity)\n SetPedDensityMultiplierThisFrame(newDensity)\n SetRandomVehicleDensityMultiplierThisFrame(newDensity)\n SetParkedVehicleDensityMultiplierThisFrame(newDensity)\n SetScenarioPedDensityMultiplierThisFrame(newDensity, newDensity)\n end\n end)<\/pre>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Nel codice sopra, puoi modificare il <code data-no-translation=\"\">newDensity<\/code> variabile per controllare la densit\u00e0 di vari tipi di PNG e veicoli nel mondo di gioco. Un valore di <code data-no-translation=\"\">1.0<\/code> rappresenta la densit\u00e0 predefinita, mentre valori pi\u00f9 piccoli la riducono.<\/li>\n<\/ul>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>5. Salvare e chiudere lo script Lua:<\/strong><\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Salva le modifiche apportate allo script Lua e chiudi l&#039;editor di testo.<\/li>\n<\/ul>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>6. Configura il tuo server.cfg:<\/strong><\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Vai alla directory principale del tuo server FiveM.<\/li>\n\n\n\n<li>Aprire il file \u201cserver.cfg\u201d con un editor di testo.<\/li>\n\n\n\n<li>Aggiungere la seguente riga al file:<\/li>\n<\/ul>\n\n\n\n<pre data-no-translation=\"\" class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\"> ensure npc_reducer<\/pre>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Questa riga garantisce che lo script \u201creduce_npc_density.lua\u201d venga caricato all&#039;avvio del server.<\/li>\n<\/ul>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>7. Riavvia il tuo server FiveM:<\/strong><\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Salva il <a href=\"https:\/\/fivemx.com\/it\/configurazione-del-server-fivem\/\" title=\"FiveM server.cfg \u2013 Guida completa\" data-wpil-monitor-id=\"1578\">file \u201cserver.cfg\u201d<\/a> e riavvia il server FiveM per applicare le modifiche.<\/li>\n<\/ul>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>8. Regola la densit\u00e0 degli NPC in tempo reale:<\/strong><\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Una volta che il server \u00e8 di nuovo attivo, puoi regolare la densit\u00e0 degli NPC in tempo reale modificando il <code data-no-translation=\"\">newDensity<\/code> variabile nello script Lua. Valori pi\u00f9 bassi ridurranno la densit\u00e0 dei PNG, mentre valori pi\u00f9 alti la aumenteranno.<\/li>\n<\/ul>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<p class=\"wp-block-paragraph\">Hai imparato a ridurre la densit\u00e0 dei PNG in FiveM creando uno script Lua e configurando il server per caricarlo. Questo pu\u00f2 aiutarti a ottimizzare le prestazioni del server o a creare scenari di gioco specifici con meno PNG sul tuo server FiveM di GTA V.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Se ti \u00e8 stato utile, metti &quot;Mi piace&quot;, condividi e commenta. :)<\/strong><\/p>\n\n\n<!-- fivemx-quality-enrichment-v2 -->\n<h2>Risorse correlate<\/h2><!-- fivemx-quality-depth-v3 -->\n<h2>Add the required resource manifest<\/h2>\n<p>Cfx.re&#8217;s Lua resource guide states that a resource folder needs a manifest to be detected and that <code data-no-translation=\"\">client_script<\/code> tells the client runtime which file to load. Add this beside <code data-no-translation=\"\">reduce_npc_density.lua<\/code>:<\/p>\n<pre data-no-translation=\"\"><code data-no-translation=\"\">fx_version 'cerulean'\ngame 'gta5'\n\nclient_script 'reduce_npc_density.lua'<\/code><\/pre>\n<p>The example uses <code data-no-translation=\"\">SetPedDensityMultiplierThisFrame<\/code>, <code data-no-translation=\"\">SetScenarioPedDensityMultiplierThisFrame<\/code>, <code data-no-translation=\"\">SetVehicleDensityMultiplierThisFrame<\/code>, <code data-no-translation=\"\">SetRandomVehicleDensityMultiplierThisFrame<\/code> E <code data-no-translation=\"\">SetParkedVehicleDensityMultiplierThisFrame<\/code>. Keep the loop client-side and yield every frame as shown. Test populated interiors, emergency traffic, missions and job scripts before rollout because reduced ambient populations can change gameplay as well as load.<\/p>\n<p>Do not combine this approach with undocumented <code data-no-translation=\"\">popcycle.dat<\/code> edits during the same test. Change one control at a time, record the value, compare client performance and restore the previous resource if behavior regresses.<\/p>\n<p>Primary references: <a href=\"https:\/\/docs.fivem.net\/docs\/scripting-manual\/introduction\/creating-your-first-script\/\" rel=\"nofollow noopener\" target=\"_blank\">Cfx.re Lua resource guide<\/a> e il <a href=\"https:\/\/github.com\/citizenfx\/natives\" rel=\"nofollow noopener\" target=\"_blank\">official CitizenFX native documentation repository<\/a>.<\/p>\n<\/section>","protected":false},"excerpt":{"rendered":"<p>Fast answer: reduce ambient NPCs and traffic with a small client resource that calls the density multiplier natives every frame. Include both fxmanifest.lua and the client Lua file, start with a moderate value on staging, and measure the same route before and after. Do not promise an FPS gain: the result depends on the wider [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":93580,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1899],"tags":[],"class_list":["post-93579","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-tutorials"],"_links":{"self":[{"href":"https:\/\/fivemx.com\/it\/wp-json\/wp\/v2\/posts\/93579","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/fivemx.com\/it\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/fivemx.com\/it\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/fivemx.com\/it\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/fivemx.com\/it\/wp-json\/wp\/v2\/comments?post=93579"}],"version-history":[{"count":3,"href":"https:\/\/fivemx.com\/it\/wp-json\/wp\/v2\/posts\/93579\/revisions"}],"predecessor-version":[{"id":217304,"href":"https:\/\/fivemx.com\/it\/wp-json\/wp\/v2\/posts\/93579\/revisions\/217304"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/fivemx.com\/it\/wp-json\/wp\/v2\/media\/93580"}],"wp:attachment":[{"href":"https:\/\/fivemx.com\/it\/wp-json\/wp\/v2\/media?parent=93579"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/fivemx.com\/it\/wp-json\/wp\/v2\/categories?post=93579"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/fivemx.com\/it\/wp-json\/wp\/v2\/tags?post=93579"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}