Skip to content

Commit

Permalink
fix issue with persistent entities
Browse files Browse the repository at this point in the history
  • Loading branch information
GlorifiedPig committed Jun 2, 2020
1 parent 05414ae commit a2d77ed
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
8 changes: 5 additions & 3 deletions lua/glorifiedbanking/libraries/sv_glorifiedbanking_gpe.lua
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@

-- Edited version of GlorifiedPersistentEnts specifically for GlorifiedBanking.

GlorifiedBanking.GlorifiedPersistentEnts = {
TableName = "GlorifiedBanking",
Identifier = "glorifiedbanking_", -- No spaces. For usage in concommands.
Expand Down Expand Up @@ -33,7 +35,7 @@ end

function GlorifiedBanking.GlorifiedPersistentEnts.RemoveEntityFromDB( ent )
if not GlorifiedBanking.GlorifiedPersistentEnts.EntClasses[ent:GetClass()] then return end
if ent.EntID != nil then
if ent.EntID then
print( "[GlorifiedBanking.GlorifiedPersistentEnts] Deleted Entity ID " .. ent.EntID .. " from table `" .. GlorifiedBanking.GlorifiedPersistentEnts.TableName .. "`" )
sql.Query( "DELETE FROM `" .. GlorifiedBanking.GlorifiedPersistentEnts.TableName .. "` WHERE `RowID` = " .. ent.EntID )
end
Expand Down Expand Up @@ -76,9 +78,9 @@ hook.Add( "PhysgunDrop", GlorifiedBanking.GlorifiedPersistentEnts.Identifier ..
end
end )

hook.Add( "OnEntityCreated", GlorifiedBanking.GlorifiedPersistentEnts.Identifier .. ".GPE.OnEntityCreated", function( ent )
hook.Add( "PlayerSpawnedSENT", GlorifiedBanking.GlorifiedPersistentEnts.Identifier .. ".GPE.PlayerSpawnedSENT", function( ply, ent )
if GlorifiedBanking.GlorifiedPersistentEnts.EntClasses[ent:GetClass()] then
timer.Simple( 0, function() GlorifiedBanking.GlorifiedPersistentEnts.SaveEntityInfo( ent ) end )
GlorifiedBanking.GlorifiedPersistentEnts.SaveEntityInfo( ent )
end
end )

Expand Down
1 change: 1 addition & 0 deletions lua/weapons/gmod_tool/stools/gbatmplacer.lua
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,7 @@ function TOOL:LeftClick( tr )
createdATM:SetSignText( self:GetClientInfo( "signtext" ) )
createdATM:Spawn()
createdATM:GetPhysicsObject():EnableMotion( false )
GlorifiedBanking.GlorifiedPersistentEnts.SaveEntityInfo( createdATM )
end
end

Expand Down

0 comments on commit a2d77ed

Please sign in to comment.