Garry's Mod Wiki

AddPropsOfParent

  AddPropsOfParent( panel pnlContent, panel node, number parentid, table customProps )

Description

This function creates a Custom Category in the Spawnlist. Use GenerateSpawnlistFromPath if you want to create a category with the contents of a folder.

Using this function before SANDBOX:PopulateContent has been called will result in an error

Arguments

1 panel pnlContent
The SMContentPanel of the Node
2 panel node
The Node
3 number parentid
The ParentID to use
4 table customProps
The Table with the Contents of the new Category

Example

Creates an Example category with 5 Playermodels

hook.Add("OnSpawnMenuOpen", "Example", function() local contents = { [1] = { ["model"] = "models/player/alyx.mdl", ["type"] = "model", }, [2] = { ["model"] = "models/player/arctic.mdl", ["type"] = "model", }, [3] = { ["model"] = "models/player/barney.mdl", ["type"] = "model", }, [4] = { ["model"] = "models/player/breen.mdl", ["type"] = "model", }, [5] = { ["model"] = "models/player/charple.mdl", ["type"] = "model", }, } AddPropsOfParent(g_SpawnMenu.CustomizableSpawnlistNode.SMContentPanel, g_SpawnMenu.CustomizableSpawnlistNode, 0, {["models/player"] = { icon = "icon16/page.png", id = 999, name = "Example", parentid = 0, needsapp = nil, contents = contents }}) end)