• Trouble Making Effects Save
    1 replies, posted
Hi, I'm editing a plugin for Clockwork (static entities by Kurochi). The plugin doesn't support effects, since they're basically entities with attached entities. I'm trying to fix that. Here's the sv_plugin file, containing most of the important code that I've modified. [CODE]-- A function to load the static props. function cwStaticEnts:LoadStaticEnts() self.staticEnts = Clockwork.kernel:RestoreSchemaData("plugins/entities/"..game.GetMap()); for k, v in pairs(self.staticEnts) do local entity = ents.Create(v.class); entity:SetMaterial(v.material); entity:SetAngles(v.angles); entity:SetColor(v.color); if (!v.class == prop_effect ) then entity:SetModel(v.model); end if ( !v.AttachedEntity == nil ) then self.AttachedEntity = ents.Create( "prop_dynamic" ) self.AttachedEntity:SetModel( v.attachment:GetModel() ) self.AttachedEntity:SetAngles( v.attachment:GetAngles() ) self.AttachedEntity:SetSkin( v.attachment:GetSkin() ) self.AttachedEntity:SetParent( self.Entity ) self.AttachedEntity:DrawShadow( false ) self.AttachedEntity:SetPos( v.position ) self.AttachedEntity:Spawn() end entity:SetPos(v.position); entity:Spawn(); Clockwork.entity:MakeSafe(entity, true, true, v.frozen); self.staticEnts[k] = entity; end; end; -- A function to save the static props. function cwStaticEnts:SaveStaticEnts() local staticEnts = {}; if (type(self.staticEnts) == "table") then for k, v in pairs(self.staticEnts) do if !table.HasValue(cwStaticEnts.blacklistedClasses, v:GetClass()) then if (IsValid(v)) then local frozen = false if IsValid(v:GetPhysicsObject()) then frozen = v:GetPhysicsObject():IsMotionEnabled() end staticEnts[#staticEnts + 1] = { class = v:GetClass(), model = v:GetModel(), color = v:GetColor(), angles = v:GetAngles(), attachment = v.AttachedEntity or nil, position = v:GetPos(), material = v:GetMaterial(), frozen = frozen }; end; else self.staticEnts[k] = nil end end; end; Clockwork.kernel:SaveSchemaData("plugins/entities/"..game.GetMap(), staticEnts); end;[/CODE] As you can see, I've had it stop effects from loading direct models Also, I have the save bit configured so that it'll look at the effects attached entity and save it, then later on get it's model and re-create that attached entity in the loading part. Anyone see anything wrong here?
Honestly, you just need to make a seperate plugin for this, but whatever. [url]http://wiki.garrysmod.com/page/Category:CEffectData[/url] Use that to grab the information when the effect saves. [url]http://wiki.garrysmod.com/page/util/Effect[/url] Use that to load the information that is saved.
Sorry, you need to Log In to post a reply to this thread.