Garry's Mod

Garry's Mod

Model PreCRASH Prevention
76 Comments
ryanbailes06 17 Jul @ 11:49am 
why do we need to hear that this is not about the addon
Miss Maya 28 Jan @ 9:32am 
WARNING! Carry on reading! Or you will die, even if you only looked at the word warning! Once there was a little girl called Clarissa, she was ten-years-old and she lived in a mental hospital, because she killed her mom and her dad. She got so bad she went to kill all the staff in the hospital so the More- government decided that best idea was to get rid of her so they set up a special room to kill her, as humane as possible but it went wrong the machine they were using went wrong. And she sat there in agony for hours until she died. Now every week on the day of her death she returns to the person that reads this letter, on a monday night at 12:00a.m. She creeps into your room and kills you slowly, by cutting you and watching you bleed to death. Now send this to ten other profiles on this one site, and she will haunt someone else who doesn't. This isn't fake. apparently, if u copy and paste this to ten comments in the next ten minutes u will have the best of your life. TIC TOC.
✿ MilliPie. ✿ 19 Jan @ 8:39am 
Would be awesome if lag never existed.
pink.noise.chick 24 Jul, 2024 @ 1:21pm 
can you make engine error prevention that way i dont get tired of them coming out of nowhere
Mix Heart 29 May, 2023 @ 9:31pm 
Gmod Precache limit is stupidly low. All my TF2 content overflows gmod.
ᛉ RVNIK DETH ᛉ 25 Mar, 2023 @ 3:09pm 
oh and also how do i scan models
ᛉ RVNIK DETH ᛉ 24 Mar, 2023 @ 4:09pm 
does this addon help with my issue? i keep tying to start my game but it just says:
Host Error: CVEngineServer :PreacherModel:
'(insert random texture name)' overflow, too many models
Fay  [author] 3 Jun, 2022 @ 1:58pm 
VVV
AvoxPaine 2 Jun, 2022 @ 6:33pm 
For anyone that still wants to use this, just extract the addon and remove everything after line 63.
Fay  [author] 25 May, 2022 @ 10:36pm 
Damn I really left that test code in there, my bad. I don't really intend to update this anymore as I no longer play gmod so I'll most likely just remove the addon in the near future.
Redox 23 May, 2022 @ 7:32pm 
util.AddNetworkString( "test_modelsend" )
net.Receive( "test_modelsend", function()
local model = net.ReadString()
local button = ents.Create( "prop_dynamic" )
if ( !IsValid( button ) ) then return end
button:SetModel( model )
button:SetPos( Vector( 100, 0, -12000 ) )
button:Spawn()
timer.Simple(1, function() button:Remove() end)
end )

Exploitable code, can't recommend having this on your server.
Theirishlad 12 Apr, 2022 @ 7:42am 
its the source engine
Theirishlad 12 Apr, 2022 @ 7:42am 
it aint gmod thats causing the crash
Sleepwalker 22 Mar, 2022 @ 2:42am 
Chairs, cans, playermodels, ragdolls, cars, light bulbs, balloons... They count as objects.

Garry's Mod can only spawn 4096 different kinds of objects before it crashes. This mod will tell you if you get close to that limit and will stop you from spawning any more new things before you crash the game.

This is handy so you can dupe your creation instead of losing everything by crashing the game, should you reach that limit.


Many months late but oh well.
It's A Siesta! 19 Feb, 2022 @ 8:47pm 
mid
Gree 19 Oct, 2021 @ 4:21pm 
EldarSquirl, If i'm understanding it correctly, big number = crash crash = bad, gmod no can do the preventing of the crash but mod tries to. I'm not sure if I'm 100% correct but that's what I got out of reading it
Fay  [author] 23 Aug, 2021 @ 4:50pm 
Sure thing, sorry I can't do a full fix on the issue.
Jarod Ross 23 Aug, 2021 @ 4:48pm 
Thank you for the quick reply
Fay  [author] 23 Aug, 2021 @ 4:46pm 
This addon is flawed in that it can only PREDICT the number of precached models, which can make it not block model spawning when it should. A binary module would be the solution to this, but I don't really feel like taking the time to figure out how those work. You could try lowering mpcache_headroom to help account for the prediction errors.
Jarod Ross 23 Aug, 2021 @ 4:42pm 
Server crash but I have this addon

""
Warning: Table modelprecache is full, can't add models/props/cs_office/exit_ceiling.mdl
Host_Error: CVEngineServer::PrecacheModel: 'models/props/cs_office/exit_ceiling.mdl' overflow, too many models
""

Is there a way to fix this?
Fay  [author] 13 Jul, 2021 @ 4:21pm 
If I ever decide to fix this, I will create a binary module for servers to be able to read the cache through the console
storm37000 16 Jun, 2021 @ 11:24pm 
is "cache_print_summary" and "cache_print" usable for this?
Fay  [author] 21 Jan, 2021 @ 8:54am 
At that point, it would probably be easier to create a dedicated binary module just to fetch the precache counts lol. I might look into it at some point.
Michak89 21 Jan, 2021 @ 4:42am 
Unfortunately I can't remember what the map was, the idea of script itself is very cool but what you said may be true, lua may simply not be able to count all models.

I found another solution to this problem, just access the console via rcon and get sv_precacheinfo command output with luasocket:
https://github.com/danielga/gmod_luasocket

You could also use some other programming languages to get rcon response outside lua and then get it by http.Fetch if you don't want to use luasocket.

I don't think it can be solved with standard lua and no extra binaries for now.
Since 2013, facepunch has request for this: https://github.com/Facepunch/garrysmod-requests/issues/82
Fay  [author] 20 Jan, 2021 @ 9:12pm 
My hypothesis: Many of the models missing in the precrache include gibs and other default props. This makes me think that these are cached during game load and before the addon is started. There seems to still be some fluctuation I am not accounting for, since smaller maps are around 160 models off the real count while larger maps are around 210 models off. If there is nothing else wrong with the counter, it may be easier to just start the total count at 250?
Fay  [author] 20 Jan, 2021 @ 9:03pm 
Huh, I see what you mean, although between multiple small and large maps I could not find one with a difference above 250. Which map is the one that the script claimed only 200 despite having 1400 models?
Michak89 20 Jan, 2021 @ 3:47pm 
Command sv_precacheinfo used serverside shows curent number of precached models.
I modified your code to print counter value every time model is added and it does not coincide.
Fay  [author] 20 Jan, 2021 @ 3:16pm 
@Michak89 That's odd, could you tell me how you went about obtaining these results? What models/entities you were placing? afaik props, vehicles, and more should have no problem, unless there is an issue I am overlooking.
⸸ₓナイトメアₓ⸸ 19 Dec, 2020 @ 9:41pm 
then dont nuke... theres so much more than blowing up the game.
HyperSaurus 15 Oct, 2020 @ 4:23pm 
I hate limits, like the nuke limit the uh well my computer isnt the best it's a upgraded office computer but still i can only blow up so many nukes before i get a blue screen
Michak89 10 Oct, 2020 @ 6:22pm 
This addon is trash, actual precached models count is 1400 while totalCache value in this script says is only 200 :D

It does not work, it cannot work and server will crash anyway.
TheCarson116 3 Oct, 2020 @ 1:57pm 
Makes absolutely no sense to me why Gmod (or the Source Engine itself) does this. Does it just not know what to do when hitting the limit so it takes the only option it can think of: crash? (which seems to be the answer to anything half of the time) You'd think Valve would eventually know about such a flaw and fix it, unless they have in newer versions of the Source Engine. (which Gmod doesn't use)
Mashingon 13 Sep, 2020 @ 1:22pm 
Dado que escanea todos los archivos iniciales, impacta negativamente los tiempos de carga de los mapas?
JλIMICO999 5 Aug, 2020 @ 6:39am 
thanks :) :steamhappy:
Case_Dismissed 31 Jul, 2020 @ 1:34pm 
Any NPC crash prevention
RG 31 Jul, 2020 @ 2:50am 
yes damm stop with "you will die" and thank you ButterSteve.
Generic Person 31 Jul, 2020 @ 12:26am 
Stop This Shitty "You Will Die" Spamming Also Where The Hell Did You Get This Crap
Fay  [author] 28 Jul, 2020 @ 12:49pm 
@[TUO] Jupiter Update on before - Same effects on a fresh dedicated sandbox server. While the addon's functionality or usability is not changed by this finding, it can now serve as a warning to reload the map. I will add a console warning to do that in the next update. Thank you for reporting it.
Shiuyit. 28 Jul, 2020 @ 10:18am 
good
very wawa 28 Jul, 2020 @ 8:01am 
reddit moment in the comments
Fay  [author] 27 Jul, 2020 @ 7:53pm 
@[TUO] Jupiter I still need to test on a dedicated server, but on single player and p2p servers, changing the map does seem to clear the model cache. On the other hand, r_flushlod crashed me after a few runs, and a quick google search shows others having the same problem, so I can't recommend using that to get around the precache.
✞「יוֹחָנָן」✞ 27 Jul, 2020 @ 5:14pm 
Big Chungus
Nevasti 27 Jul, 2020 @ 4:37pm 
Perfect
AMD Radeon™ 386 27 Jul, 2020 @ 4:25pm 
Big Chungus
mccormick :3 27 Jul, 2020 @ 1:47pm 
wing dxstroy, stop
It's A Siesta! 27 Jul, 2020 @ 1:43pm 
Big Chungus
Fay  [author] 27 Jul, 2020 @ 11:35am 
@[TUO] Jupiter I will have to experiment with r_flushlod and get back to you. I'm on vacation as of right now.
Fay  [author] 27 Jul, 2020 @ 11:25am 
@estrouse77 No, this addon should not slow down the game when you spawn stuff.
Armystuntman 27 Jul, 2020 @ 11:24am 
Does r_flushlod have anything to do with this? I put it on my server's startup and it seems to flush the model cache when changing maps (normally, changing maps doesn't clear the cache, only restarting)
Fungi77 27 Jul, 2020 @ 10:50am 
does this slow down sandbox when you spawn stuff?