Garry's Mod

Garry's Mod

View Stats:
THROBBING Feb 1, 2023 @ 5:31pm
Cannot spawn any NPCs?
When I spawn any NPC that isn't from VJ Base, the model appears for a second then disappears. The NPC is still there, its shadow is visible and it still acts like an NPC but it's model is gone. In the console it gives this error :

[ERROR] gamemodes/sandbox/entities/effects/propspawn.lua:105: attempt to index field 'SpawnEffect' (a nil value)
1. unknown - gamemodes/sandbox/entities/effects/propspawn.lua:105

It gives this error like 150 times a second and keeps going unless the NPC is deleted. It only does this for NPCs, not props or entities or anything.

It shows no errors in the problems list, and in the Lua Errors screen it shows the same error from console, but it says it can't find where the problem is coming from; meaning it can't figure out if it's coming from an addon or not.

I have reinstalled the game and verified integrity of the game files, has anyone encountered this issue and how can I fix it?
< >
Showing 1-14 of 14 comments
Spheric Feb 2, 2023 @ 2:57pm 
I have the exact same problem, can anyone help?
Flynn Eugene Feb 8, 2023 @ 6:28am 
This has happened to me as well. idk why? Have you guys found any solution?
THROBBING Feb 8, 2023 @ 12:29pm 
no
THROBBING Feb 14, 2023 @ 8:13pm 
ATTENTION: The mod that is causing the error is the ADMIN LONG REVOLVER
Idk why tf that mod is ♥♥♥♥♥♥♥ everything up but it is
I found a fix :)
The long admin revolver is likely the problem for you, but it might be something else - no worries!
The reason this happens is because a script in one of the addons you have installed breaks the SpawnEffect, all you have to do is hold C -> Drawing -> Uncheck the box "Draw Spawn Effect" Or you can fix the addon's script by fixing SpawnEffect :) Hope this helped!

EDIT: If you get any other errors, go to C:\Program Files (x86)\Steam\steamapps\common\GarrysMod\garrysmod\gamemodes\sandbox\entities\effects then open "propspawn.lua" with notepad, in notepad, press ctrl+a, then paste this code instead, then close notepad and it will ask if you want to save, press yes and MAKE SURE TO REJOIN THE GAME IF YOU ARE ALREADY IN A SERVER!

local cl_drawspawneffect = CreateConVar( "cl_drawspawneffect", "1", { FCVAR_ARCHIVE } )

local matRefract = Material( "models/spawn_effect" )

function EFFECT:Init( data )

if ( !cl_drawspawneffect:GetBool() ) then return end

-- This is how long the spawn effect
-- takes from start to finish.
self.Time = 0.5
self.LifeTime = CurTime() + self.Time

local ent = data:GetEntity()

if ( !IsValid( ent ) ) then return end
if ( !ent:GetModel() ) then return end

self.ParentEntity = ent
self:SetModel( ent:GetModel() )
self:SetPos( ent:GetPos() )
self:SetAngles( ent:GetAngles() )
self:SetParent( ent )

self.OldRenderOverride = self.ParentEntity.RenderOverride
self.ParentEntity.RenderOverride = self.RenderParent
self.ParentEntity.SpawnEffect = self


end

function EFFECT:Think()

if ( !cl_drawspawneffect:GetBool() ) then return false end
if ( !IsValid( self.ParentEntity ) ) then return false end

local PPos = self.ParentEntity:GetPos()
self:SetPos( PPos + ( EyePos() - PPos ):GetNormal() )

if ( self.LifeTime > CurTime() ) then
return true
end

-- Remove the override only if our override was not overridden.
if ( self.ParentEntity.RenderOverride == self.RenderParent ) then
self.ParentEntity.RenderOverride = self.OldRenderOverride
end
self.ParentEntity.SpawnEffect = self

return false

end

function EFFECT:Render()
end

function EFFECT:RenderOverlay( entity )

local Fraction = ( self.LifeTime - CurTime() ) / self.Time
local ColFrac = ( Fraction - 0.5 ) * 2

Fraction = math.Clamp( Fraction, 0, 1 )
ColFrac = math.Clamp( ColFrac, 0, 1 )

-- Change our model's alpha so the texture will fade out
--entity:SetColor( 255, 255, 255, 1 + 254 * (ColFrac) )

-- Place the camera a tiny bit closer to the entity.
-- It will draw a big bigger and we will skip any z buffer problems
local EyeNormal = entity:GetPos() - EyePos()
local Distance = EyeNormal:Length()
EyeNormal:Normalize()

local Pos = EyePos() + EyeNormal * Distance * 0.01

-- Start the new 3d camera position
local bClipping = self:StartClip( entity, 1.2 )
cam.Start3D( Pos, EyeAngles() )

-- If our card is DX8 or above draw the refraction effect
if ( render.GetDXLevel() >= 80 ) then

-- Update the refraction texture with whatever is drawn right now
render.UpdateRefractTexture()

matRefract:SetFloat( "$refractamount", Fraction * 0.1 )

-- Draw model with refraction texture
render.MaterialOverride( matRefract )
entity:DrawModel()
render.MaterialOverride( 0 )

end

-- Set the camera back to how it was
cam.End3D()
render.PopCustomClipPlane()
render.EnableClipping( bClipping )

end

function EFFECT:RenderParent()

local bClipping = self.SpawnEffect:StartClip( self, 1 )

self:DrawModel()
render.PopCustomClipPlane()
render.EnableClipping( bClipping )

self.SpawnEffect:RenderOverlay( self )

end

function EFFECT:StartClip( model, spd )

local mn, mx = model:GetRenderBounds()
local Up = ( mx - mn ):GetNormal()
local Bottom = model:GetPos() + mn
local Top = model:GetPos() + mx

local Fraction = (self.LifeTime - CurTime()) / self.Time
Fraction = math.Clamp( Fraction / spd, 0, 1 )

local Lerped = LerpVector( Fraction, Bottom, Top )

local normal = Up
local distance = normal:Dot( Lerped )

local bEnabled = render.EnableClipping( true )
render.PushCustomClipPlane( normal, distance )

return bEnabled

end
Last edited by ⎝⎠⎝⎠⎝⎠⎝⎠⎝; Mar 26, 2023 @ 1:27pm
Originally posted by CatMax:
I found a fix :)
The long admin revolver is likely the problem for you, but it might be something else - no worries!
The reason this happens is because a script in one of the addons you have installed breaks the SpawnEffect, all you have to do is hold C -> Drawing -> Uncheck the box "Draw Spawn Effect" Or you can fix the addon's script by fixing SpawnEffect :) Hope this helped!

EDIT: If you get any other errors, go to C:\Program Files (x86)\Steam\steamapps\common\GarrysMod\garrysmod\gamemodes\sandbox\entities\effects then open "propspawn.lua" with notepad, in notepad, press ctrl+a, then paste this code instead

local cl_drawspawneffect = CreateConVar( "cl_drawspawneffect", "1", { FCVAR_ARCHIVE } )

local matRefract = Material( "models/spawn_effect" )

function EFFECT:Init( data )

if ( !cl_drawspawneffect:GetBool() ) then return end

-- This is how long the spawn effect
-- takes from start to finish.
self.Time = 0.5
self.LifeTime = CurTime() + self.Time

local ent = data:GetEntity()

if ( !IsValid( ent ) ) then return end
if ( !ent:GetModel() ) then return end

self.ParentEntity = ent
self:SetModel( ent:GetModel() )
self:SetPos( ent:GetPos() )
self:SetAngles( ent:GetAngles() )
self:SetParent( ent )

self.OldRenderOverride = self.ParentEntity.RenderOverride
self.ParentEntity.RenderOverride = self.RenderParent
self.ParentEntity.SpawnEffect = self


end

function EFFECT:Think()

if ( !cl_drawspawneffect:GetBool() ) then return false end
if ( !IsValid( self.ParentEntity ) ) then return false end

local PPos = self.ParentEntity:GetPos()
self:SetPos( PPos + ( EyePos() - PPos ):GetNormal() )

if ( self.LifeTime > CurTime() ) then
return true
end

-- Remove the override only if our override was not overridden.
if ( self.ParentEntity.RenderOverride == self.RenderParent ) then
self.ParentEntity.RenderOverride = self.OldRenderOverride
end
self.ParentEntity.SpawnEffect = self

return false

end

function EFFECT:Render()
end

function EFFECT:RenderOverlay( entity )

local Fraction = ( self.LifeTime - CurTime() ) / self.Time
local ColFrac = ( Fraction - 0.5 ) * 2

Fraction = math.Clamp( Fraction, 0, 1 )
ColFrac = math.Clamp( ColFrac, 0, 1 )

-- Change our model's alpha so the texture will fade out
--entity:SetColor( 255, 255, 255, 1 + 254 * (ColFrac) )

-- Place the camera a tiny bit closer to the entity.
-- It will draw a big bigger and we will skip any z buffer problems
local EyeNormal = entity:GetPos() - EyePos()
local Distance = EyeNormal:Length()
EyeNormal:Normalize()

local Pos = EyePos() + EyeNormal * Distance * 0.01

-- Start the new 3d camera position
local bClipping = self:StartClip( entity, 1.2 )
cam.Start3D( Pos, EyeAngles() )

-- If our card is DX8 or above draw the refraction effect
if ( render.GetDXLevel() >= 80 ) then

-- Update the refraction texture with whatever is drawn right now
render.UpdateRefractTexture()

matRefract:SetFloat( "$refractamount", Fraction * 0.1 )

-- Draw model with refraction texture
render.MaterialOverride( matRefract )
entity:DrawModel()
render.MaterialOverride( 0 )

end

-- Set the camera back to how it was
cam.End3D()
render.PopCustomClipPlane()
render.EnableClipping( bClipping )

end

function EFFECT:RenderParent()

local bClipping = self.SpawnEffect:StartClip( self, 1 )

self:DrawModel()
render.PopCustomClipPlane()
render.EnableClipping( bClipping )

self.SpawnEffect:RenderOverlay( self )

end

function EFFECT:StartClip( model, spd )

local mn, mx = model:GetRenderBounds()
local Up = ( mx - mn ):GetNormal()
local Bottom = model:GetPos() + mn
local Top = model:GetPos() + mx

local Fraction = (self.LifeTime - CurTime()) / self.Time
Fraction = math.Clamp( Fraction / spd, 0, 1 )

local Lerped = LerpVector( Fraction, Bottom, Top )

local normal = Up
local distance = normal:Dot( Lerped )

local bEnabled = render.EnableClipping( true )
render.PushCustomClipPlane( normal, distance )

return bEnabled

end
I know I'm not the best problem solver, there should definitely be a better way to do this!
Originally posted by Spheric:
I have the exact same problem, can anyone help?
You can check my solution on this thread!
Originally posted by Flynn Eugene:
This has happened to me as well. idk why? Have you guys found any solution?
You can check my solution on this thread!
Originally posted by i eat people:
ATTENTION: The mod that is causing the error is the ADMIN LONG REVOLVER
Idk why tf that mod is ♥♥♥♥♥♥♥ everything up but it is
You can check my solution on this thread!
tdot_slash May 29, 2023 @ 2:10pm 
I’ll pay anyone who can show me how to fix the NPC spawn ERROR problem I can’t get any npc or most vehicles to appear
minniefinnie May 29, 2023 @ 2:55pm 
try reinstalin system 32
Originally posted by tdot_slash:
I’ll pay anyone who can show me how to fix the NPC spawn ERROR problem I can’t get any npc or most vehicles to appear
please look at the solution I made lol. PayPal: @NameQuality (I doubt anyone will actually gimme mone lol)
Note to self: Never subscribe to a add-ons called "Admin Long Revolver" unless I want a glitchy game.
reeseapearson Apr 21, 2024 @ 9:15am 
im having a problem i cant spawn a npc in single or multiplayer
< >
Showing 1-14 of 14 comments
Per page: 1530 50

Date Posted: Feb 1, 2023 @ 5:31pm
Posts: 14