Developer API Reference

Use this to look up classes or methods.

Note

Not every class is documented here. Look at the source code for usage examples. This is intended to explain data structures that might not be obvious at first as well as documenting the public interface.

Modules

class Blueprint

A blueprint defines all properties needed for a custom item.

class SettingsCategory

A table representing a category that contains one or more settings. The category’s path is indicated by it’s key in the table. The info key is used to provide a readable name for the category to be used in the configurator component. It contains multiple Settings, the path is again provided by the key.

class MODULE

The module information table. Contains information such as a module’s blueprints and settings. This is to be defined in the module’s sh_module.lua

Name

The name of the module.

Author

The author of the module

RestrictGamemodes

A table containing gamemodes that this module is restricted to. The module will only be loaded if the active gamemode is in the list.

Blueprints

A table containing Blueprint s that players can use.

Settings

A table containing the settings of the module. A seperate table for each realm exists. Settings.Server is only sent to admins when changing the settings, Settings.Shared is synced with all clients. Accessing Settings is done by calling Pointshop2.GetSetting() . Each realm settings table defines Settings that can be accessed and configured easily and can contain multiple SettingsCategory s. Settings registered this way are automatically saved the the database when changed.

SettingsButton

A table containing information about the settings button that will show up in the management tab. The table has three elements:

label: The label of the button icon: The icon of the button control: The derma control that is created when clicking the button

Poinsthop2.RegisterModule(MODULE)

Registers a MODULE to be used with Pointshop 2.

Pointshop2.GetSetting(moduleName, path)

Retrieves a setting value that was defined in MODULE.Settings. Automatically uses the default or database saved value.

  • modName: The MODULE.Name of the module where the setting is defined
  • path: The category and name of the setting, seperated by a ”.”

Example:

print(Pointshop2.GetSetting("TTTIntegration", "RoundWin.Innocent"))
Pointshop2.AddEquipmentSlot(name, itemValidFunction)

Registers a new equipment slot.

Name:label of the slot that is shown underneath the slot’s panel in the inventory. itemValidFunction: A function that takes an item as an argument and returns whether or not it can be equipped in the slot.

Pointshop2:AddTab(label, controlName, shouldShow)

Adds a new tab to the top navigation of the pointshop.

  • label: The label of the tab.
  • controlName: The derma control that is created as panel.
  • shouldShow: optional A function returning whether or not the player should be able to see this tab.
Pointshop2:AddManagementPanel(label, icon, controlName, shouldShow)

Adds a new tab to the side navigation of the management panel.

  • label: The label of the tab
  • icon: The tab’s icon
  • controlName: The derma control that is created as panel
  • shouldShow: optional A function returning whether or not the player should be able to see this tab

Example:

derma.DefineControl( "DPointshopManagementTab_Settings", "", PANEL, "DPanel" )

Pointshop2:AddManagementPanel( "Settings", "pointshop2/advanced.png", "DPointshopManagementTab_Settings", function( )
    return PermissionInterface.query( LocalPlayer(), "pointshop2 managemodules" )
end )
Pointshop2:AddInventoryPanel(label, icon, controlName, shouldShow)

Adds a new tab to the side navigation of the management panel.

  • label: The label of the tab
  • icon: The tab’s icon
  • controlName: The derma control that is created as panel
  • shouldShow: optional A function returning whether or not the player should be able to see this tab
class Configurator

Interface for Configurator controls. Used by the settings section.

SetModule(module)

Passes the MODULE table to the control.

SetData(data)

Passes the Settings as retrieved from the server to the control. data contains Server and Shared settings merged together.

Player integration

class Wallet

In Pointshop 2 points are stored in a player’s wallet. A wallet is a LibK model instance, you can use :save() on it after changing it.

PLAYER:PS2_AddStandardPoints(points, message, small)

Awards points to a player. If a message is specified it will show up in their pointfeed.

points: Amount of points given message: Message displayed to the pointfeed small: Use the small print (for bonus points related to a primary event)

PLAYER:PS2_AddPremiumPoints(points)

Adds premium points to a player’s wallet.

points: Amount of points given