blob: 820f05599a2fa1816366cb9c4434592af82bde9d (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
|
print("Loading structures!")
GMS = GMS or {}
GMS.Structures = GMS.Structures or {}
GMS.UniqueStructures = {}
function registerStructure(tbl)
assert(tbl.Name != nil, "Structure's name is nil!")
GMS.Structures[tbl.Name] = tbl
end
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[structname]
if tbl.uniquedata then
tbl = table.Copy(tbl)
GMS.UniqueStructures[e:EntIndex()] = tbl
end
for k,v in pairs(tbl) do
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)
|