Is there a way to restrict sandbox save/dupe system from saving certain entity class?

Hello, Facepunch.

Anyone knows a way to restrict certain entity class from being saved in a dupe/save? I can’t find any hooks that can restrict saving an entity class into a dupe.

I would appreciate any help.

This would need to be done in the entity itself.

And how to to this from the side of an entity then?

[editline]29th July 2017[/editline]

I found a way to do this, by replacing gmsave.ShouldSaveEntity.



local old = gmsave.ShouldSaveEntity
function gmsave.ShouldSaveEntity( ent, ... )
    if ent:GetClass() == "tombstone" then return false end
    return old( ent, ... )
end


Yes, this method sounds horrible, but we are also returning the old function, so the old function also gonna be executed.

Wiremod does this the same way with restricting E2 chips from saving:



function gmsave.ShouldSaveEntity( ent, ... )
    if ent:GetClass() == "gmod_wire_expression2" then return false end
    return old( ent, ... )
end