Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
43 changes: 24 additions & 19 deletions lua/entities/gmod_wire_expression2/core/custom/prop.lua
Original file line number Diff line number Diff line change
Expand Up @@ -316,24 +316,27 @@ function PropCore.CreateSent(self, class, pos, angles, freeze, data)
elseif sent then -- Spawning an entity from entity tab.
if sent.AdminOnly and not self.player:IsAdmin() then return self:throw("You do not have permission to spawn '" .. class .. "' (admin-only)!", NULL) end

local mockTrace = {
FractionLeftSolid = 0,
HitNonWorld = true,
Fraction = 0,
Entity = NULL,
HitPos = Vector(pos),
HitNormal = Vector(0, 0, 0),
HitBox = 0,
Normal = Vector(1, 0, 0),
Hit = true,
HitGroup = 0,
MatType = 0,
StartPos = Vector(0, 0, 0),
PhysicsBone = 0,
WorldToLocal = Vector(0, 0, 0),
}
if sent.t and sent.t.SpawnFunction then
entity = sent.t.SpawnFunction( sent.t, ply, mockTrace, class )
local stored_sent = scripted_ents.GetStored(class)

if stored_sent and stored_sent.t.SpawnFunction then
local mockTrace = {
FractionLeftSolid = 0,
HitNonWorld = true,
Fraction = 0,
Entity = NULL,
HitPos = Vector(pos),
HitNormal = Vector(0, 0, 0),
HitBox = 0,
Normal = Vector(1, 0, 0),
Hit = true,
HitGroup = 0,
MatType = 0,
StartPos = Vector(0, 0, 0),
PhysicsBone = 0,
WorldToLocal = Vector(0, 0, 0),
}

entity = stored_sent.t.SpawnFunction(stored_sent.t, self.player, mockTrace, class)
else
entity = ents.Create( class )
if IsValid(entity) then
Expand All @@ -344,7 +347,9 @@ function PropCore.CreateSent(self, class, pos, angles, freeze, data)
end
end

gamemode.Call("PlayerSpawnedSENT", self.player, entity)
if IsValid(entity) then
gamemode.Call("PlayerSpawnedSENT", self.player, entity)
end
Comment on lines +350 to +352
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This feels weird to me. Couldn't a custom entity decide that it's not :IsValid() until later?

Is that how PlayerSpawnedSENT works internally by default?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Never heard of that

Copy link
Contributor Author

@Astralcircle Astralcircle Aug 19, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

SpawnFunction can return invalid entity
image

end

if not IsValid( entity ) then return NULL end
Expand Down
Loading