Skip to content

Commit 066990a

Browse files
authored
Fix a bug where Spawn Function/Admin Only did not work if they were set only on an entity base (#3594)
I found this bug when testing my system of purchased items in the spawnmenu
1 parent 8b98252 commit 066990a

1 file changed

Lines changed: 4 additions & 4 deletions

File tree

  • lua/entities/gmod_wire_expression2/core/custom

lua/entities/gmod_wire_expression2/core/custom/prop.lua

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -316,11 +316,11 @@ function PropCore.CreateSent(self, class, pos, angles, freeze, data)
316316
return self:throw("Failed to spawn '" .. class .. "'. (Internal error). Traceback: " .. tostring(errMessage), NULL) -- Not sure, if we should provide tracebacks to scare people.
317317
end
318318
elseif sent then -- Spawning an entity from entity tab.
319-
if sent.AdminOnly and not self.player:IsAdmin() then return self:throw("You do not have permission to spawn '" .. class .. "' (admin-only)!", NULL) end
319+
if scripted_ents.GetMember(class, "AdminOnly") and not self.player:IsAdmin() then return self:throw("You do not have permission to spawn '" .. class .. "' (admin-only)!", NULL) end
320320

321-
local stored_sent = scripted_ents.GetStored(class)
321+
local spawn_function = scripted_ents.GetMember(class, "SpawnFunction")
322322

323-
if stored_sent and stored_sent.t.SpawnFunction then
323+
if spawn_function then
324324
local mockTrace = {
325325
FractionLeftSolid = 0,
326326
HitNonWorld = true,
@@ -338,7 +338,7 @@ function PropCore.CreateSent(self, class, pos, angles, freeze, data)
338338
WorldToLocal = Vector(0, 0, 0),
339339
}
340340

341-
entity = stored_sent.t.SpawnFunction(stored_sent.t, self.player, mockTrace, class)
341+
entity = spawn_function(scripted_ents.GetStored(class).t, self.player, mockTrace, class)
342342
else
343343
entity = ents.Create( class )
344344
if IsValid(entity) then

0 commit comments

Comments
 (0)