Skip to content

Instantly share code, notes, and snippets.

@Python1320
Created October 16, 2015 19:52
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Python1320/db89301cc87bac4db8a6 to your computer and use it in GitHub Desktop.
Save Python1320/db89301cc87bac4db8a6 to your computer and use it in GitHub Desktop.
if SERVER then
return
end
local function MenuPopulate()
local t = file.Find("lua/sprops/spawnlist/*.lua", "GAME")
if #t == 0 then
return
end
local l = file.Find("settings/spawnlist/*rops.txt", 'MOD')
for _, v in next, l do
if v:lower():find("%-sprops%.txt$") then
Msg '[SProps Hack] ' print("Found ", v, ", not reloading")
return
end
end
Msg '[SProps Hack] ' print("Loading ", #t, "spawnlists")
for k, f in next, t do
local path = "lua/sprops/spawnlist/" .. f
local data = file.Read(path, 'GAME')
local pos = data:find("TableToKeyValues", 1, true)
if not pos or data:sub(-2, -1) ~= ']]' then
ErrorNoHalt("Sprops unparseable list " .. f .. '\n')
continue
end
data = data:sub(pos - 1, -3)
data = util.KeyValuesToTable(data)
spawnmenu.AddPropCategory("settings/spawnlist/" .. f, data.name, data.contents, data.icon, data.id, data.parentid)
end
end
hook.Add('Initialize', 'sprops', function()
hook.Add("PopulatePropMenu", "StopStealingMahDamnedHooks", MenuPopulate)
end)
hook.Add("PopulatePropMenu", "StopStealingMahDamnedHooks", MenuPopulate)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment