summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--entities/entities/gms_generic_structure.lua3
-rw-r--r--gamemode/structuresystem/loadstructures.lua16
-rw-r--r--gamemode/structuresystem/structures/aaaStructureExample.lua5
3 files changed, 15 insertions, 9 deletions
diff --git a/entities/entities/gms_generic_structure.lua b/entities/entities/gms_generic_structure.lua
index d76ed30..9617da8 100644
--- a/entities/entities/gms_generic_structure.lua
+++ b/entities/entities/gms_generic_structure.lua
@@ -7,7 +7,8 @@ ENT.Base = "gms_base_entity"
function ENT:Initialize()
print("Initalize called!")
util.PrecacheModel(self.Model)
- if self.Model then self:SetModel(self.Model) end
+ --For some reason this bugs out if run client side
+ if SERVER then if self.Model then self:SetModel(self.Model) end end
if self.onInitialize then self:onInitialize() end
if CLIENT then return end
self:PhysicsInit( SOLID_VPHYSICS )
diff --git a/gamemode/structuresystem/loadstructures.lua b/gamemode/structuresystem/loadstructures.lua
index 858d976..820f055 100644
--- a/gamemode/structuresystem/loadstructures.lua
+++ b/gamemode/structuresystem/loadstructures.lua
@@ -8,27 +8,29 @@ function registerStructure(tbl)
GMS.Structures[tbl.Name] = tbl
end
-concommand.Add("gms_spawnstructure",function(ply,cmd,args)
- if !ply:IsDeveloper() then return end
- assert(args[1] != "","Failed to find structure name")
- assert(GMS.Structures[args[1]] != nil, "Structure \"" .. args[1] .. "\" does not exist!")
+function SpawnStructure(structname, ply)
+ assert(structname != "","Failed to find structure name")
+ assert(GMS.Structures[structname] != nil, "Structure \"" .. structname .. "\" does not exist!")
local tr = ply:GetEyeTrace()
local e = ents.Create("gms_generic_structure")
- local tbl = GMS.Structures[args[1]]
+ local tbl = GMS.Structures[structname]
if tbl.uniquedata then
tbl = table.Copy(tbl)
GMS.UniqueStructures[e:EntIndex()] = tbl
end
for k,v in pairs(tbl) do
- print("Setting " .. k .. " to")
- print(v)
e[k] = v
end
e:Spawn()
e:SetPos(tr.HitPos)
SPropProtection.PlayerMakePropOwner( ply, e )
--e:SetNWString("Owner",ply:Nick())
+end
+
+concommand.Add("gms_spawnstructure",function(ply,cmd,args)
+ if !ply:IsDeveloper() then return end
+ SpawnStructure(args[1],ply)
end)
diff --git a/gamemode/structuresystem/structures/aaaStructureExample.lua b/gamemode/structuresystem/structures/aaaStructureExample.lua
index abe91ba..060eba8 100644
--- a/gamemode/structuresystem/structures/aaaStructureExample.lua
+++ b/gamemode/structuresystem/structures/aaaStructureExample.lua
@@ -6,7 +6,7 @@ STRUCT = {}
STRUCT.Name = "Example Structure"
--The model for this structure.
-STRUCT.Model = "models/props/de_inferno/ClayOven.mdl"
+STRUCT.Model = "models/props_combine/breendesk.mdl"
--The initalize method. Called on both the server and the client
STRUCT.onInitialize = function(self)
@@ -20,3 +20,6 @@ STRUCT.uniquedata = false
STRUCT.onUse = function(self,ply)
print("onUse called!")
end
+
+--Don't forget to register the structure when you're done!
+registerStructure(STRUCT)