Skip to content

Instantly share code, notes, and snippets.

@ValentinFunk
Last active June 28, 2017 11:48
Show Gist options
  • Save ValentinFunk/3bf0e70316fbab83c00a95d36c14d29e to your computer and use it in GitHub Desktop.
Save ValentinFunk/3bf0e70316fbab83c00a95d36c14d29e to your computer and use it in GitHub Desktop.
Give a random item from category
local function GiveRandomItemFromCategory( ply, categoryName )
local factory = Pointshop2.ItemFromCategoryFactory:new()
factory.settings = {
["ManualSettings.CategoryName"] = categoryName,
["BasicSettings.WeightedRandom"] = true
}
local item = factory:CreateItem( true )
return ply:PS2_EasyAddItem( item.class.className )
end
@ValentinFunk
Copy link
Author

e.g.

GiveRandomItemFromCategory( player.GetByID( 1 ), "Hats" )

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment