{"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":"how-to-reduce-npcs-density","status":"publish","type":"post","link":"https:\/\/fivemx.com\/pl\/how-to-reduce-npcs-density\/","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>Szybka odpowied\u017a:<\/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\">Czasami mo\u017cesz chcie\u0107 zmniejszy\u0107 liczb\u0119 postaci niezale\u017cnych (NPC) lub ich g\u0119sto\u015b\u0107 w \u015bwiecie gry, aby poprawi\u0107 wydajno\u015b\u0107 serwera lub stworzy\u0107 konkretne scenariusze rozgrywki. W tym poradniku poka\u017cemy Ci, jak zmniejszy\u0107 liczb\u0119 NPC w FiveM.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Uwaga<\/strong>: Zmniejszenie g\u0119sto\u015bci NPC mo\u017ce wymaga\u0107 znajomo\u015bci skryptowania po stronie serwera w FiveM. Upewnij si\u0119, \u017ce masz dost\u0119p administracyjny do swojego serwera FiveM oraz podstawow\u0105 znajomo\u015b\u0107 skryptowania w Lua.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Wymagania wst\u0119pne<\/strong>:<\/p>\n\n\n\n<ol class=\"wp-block-list\">\n<li>Serwer FiveM. (<a href=\"https:\/\/fivemx.com\/pl\/how-to-create-a-fivem-server\/\" target=\"_blank\" data-type=\"link\" data-id=\"https:\/\/fivemx.com\/how-to-create-a-fivem-server\/\" rel=\"noreferrer noopener\">Jak skonfigurowa\u0107<\/a>)<\/li>\n\n\n\n<li>Dost\u0119p administracyjny do serwera.<\/li>\n\n\n\n<li>Edytor tekstu (np., <a href=\"https:\/\/notepad-plus-plus.org\/downloads\/\" target=\"_blank\" data-type=\"link\" data-id=\"https:\/\/notepad-plus-plus.org\/downloads\/\" rel=\"noreferrer noopener\">Notepad++<\/a>) do edycji skrypt\u00f3w Lua.<\/li>\n\n\n\n<li>Podstawowa znajomo\u015b\u0107 skryptowania w Lua.<\/li>\n<\/ol>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Kroki<\/strong>:<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>1. Uzyskaj dost\u0119p do swojego serwera FiveM:<\/strong><\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Upewnij si\u0119, \u017ce masz dost\u0119p SSH lub RDP do swojego serwera FiveM lub dost\u0119p do jego panelu sterowania.<\/li>\n<\/ul>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>2. Znajd\u017a folder resources:<\/strong><\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Przejd\u017a do g\u0142\u00f3wnego katalogu swojego serwera FiveM.<\/li>\n\n\n\n<li>Znajd\u017a folder \u201cresources\u201d; to tutaj znajduj\u0105 si\u0119 skrypty i zasoby twojego serwera.<\/li>\n<\/ul>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>3. Utw\u00f3rz nowy skrypt Lua:<\/strong><\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>W folderze \u201cresources\u201d utw\u00f3rz nowy katalog, je\u015bli to konieczne, np. \u201cnpc_reducer\u201d.\u201d<\/li>\n\n\n\n<li>Wewn\u0105trz <code data-no-translation=\"\">npc_reducer<\/code>, utw\u00f3rz <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. Edytuj skrypt Lua:<\/strong><\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Otw\u00f3rz plik \u201creduce_npc_density.lua\u201d za pomoc\u0105 preferowanego edytora tekstu.<\/li>\n\n\n\n<li>Dodaj do pliku nast\u0119puj\u0105cy kod Lua:<\/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>W powy\u017cszym kodzie mo\u017cesz zmodyfikowa\u0107 zmienn\u0105 <code data-no-translation=\"\">newDensity<\/code> , aby kontrolowa\u0107 g\u0119sto\u015b\u0107 r\u00f3\u017cnych typ\u00f3w NPC i pojazd\u00f3w w \u015bwiecie gry. Warto\u015b\u0107 <code data-no-translation=\"\">1.0<\/code> oznacza domy\u015bln\u0105 g\u0119sto\u015b\u0107, podczas gdy mniejsze warto\u015bci j\u0105 zmniejszaj\u0105.<\/li>\n<\/ul>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>5. Zapisz i zamknij skrypt Lua:<\/strong><\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Zapisz zmiany wprowadzone w skrypcie Lua i zamknij edytor tekstu.<\/li>\n<\/ul>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>6. Skonfiguruj sw\u00f3j server.cfg:<\/strong><\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Przejd\u017a do g\u0142\u00f3wnego katalogu swojego serwera FiveM.<\/li>\n\n\n\n<li>Otw\u00f3rz plik \u201cserver.cfg\u201d za pomoc\u0105 edytora tekstu.<\/li>\n\n\n\n<li>Dodaj nast\u0119puj\u0105c\u0105 lini\u0119 do pliku:<\/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>Ta linia zapewnia, \u017ce skrypt \u201creduce_npc_density.lua\u201d zostanie za\u0142adowany podczas uruchamiania serwera.<\/li>\n<\/ul>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>7. Uruchom ponownie sw\u00f3j serwer FiveM:<\/strong><\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Zapisz <a href=\"https:\/\/fivemx.com\/pl\/fivem-server-cfg\/\" title=\"FiveM server.cfg \u2013 Pe\u0142ny przewodnik\" data-wpil-monitor-id=\"1578\">\u201cplik \u201dserver.cfg\u201d<\/a> i uruchom ponownie sw\u00f3j serwer FiveM, aby zastosowa\u0107 zmiany.<\/li>\n<\/ul>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>8. Dostosuj g\u0119sto\u015b\u0107 NPC w czasie rzeczywistym:<\/strong><\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Gdy tw\u00f3j serwer zn\u00f3w dzia\u0142a, mo\u017cesz dostosowa\u0107 g\u0119sto\u015b\u0107 NPC w czasie rzeczywistym, modyfikuj\u0105c <code data-no-translation=\"\">newDensity<\/code> zmienn\u0105 w skrypcie Lua. Ni\u017csze warto\u015bci zmniejsz\u0105 g\u0119sto\u015b\u0107 NPC, a wy\u017csze j\u0105 zwi\u0119ksz\u0105.<\/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\">Pomy\u015blnie nauczy\u0142e\u015b si\u0119, jak zmniejszy\u0107 liczb\u0119 NPC (g\u0119sto\u015b\u0107) w FiveM, tworz\u0105c skrypt Lua i konfiguruj\u0105c serwer do jego \u0142adowania. Mo\u017ce to pom\u00f3c w optymalizacji wydajno\u015bci serwera lub stworzeniu okre\u015blonych scenariuszy rozgrywki z mniejsz\u0105 liczb\u0105 NPC na twoim serwerze GTA V FiveM.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Prosz\u0119, polub, udost\u0119pnij i skomentuj to, je\u015bli ci pomog\u0142o. :)<\/strong><\/p>\n\n\n<!-- fivemx-quality-enrichment-v2 -->\n<h2>Powi\u0105zane zasoby<\/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> I <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> oraz <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\/pl\/wp-json\/wp\/v2\/posts\/93579","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/fivemx.com\/pl\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/fivemx.com\/pl\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/fivemx.com\/pl\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/fivemx.com\/pl\/wp-json\/wp\/v2\/comments?post=93579"}],"version-history":[{"count":3,"href":"https:\/\/fivemx.com\/pl\/wp-json\/wp\/v2\/posts\/93579\/revisions"}],"predecessor-version":[{"id":217304,"href":"https:\/\/fivemx.com\/pl\/wp-json\/wp\/v2\/posts\/93579\/revisions\/217304"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/fivemx.com\/pl\/wp-json\/wp\/v2\/media\/93580"}],"wp:attachment":[{"href":"https:\/\/fivemx.com\/pl\/wp-json\/wp\/v2\/media?parent=93579"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/fivemx.com\/pl\/wp-json\/wp\/v2\/categories?post=93579"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/fivemx.com\/pl\/wp-json\/wp\/v2\/tags?post=93579"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}