PLUGIN
Plugin Hook Documentation.
Base hooks for plugins. Hooks are functions that can have code appended to, and are triggered at specific events. NutScript allows you to add hooks via PLUGIN, rather than hook.Add. See: https://wiki.facepunch.com/gmod/Hook_Library_Usage and Why use PLUGIN?
Character-related hooks
PLUGIN:CharacterLoaded (id)
PLUGIN:CharacterLoaded
Called when a character is fully loaded.
Parameters:
integer id The character ID that was loadedPLUGIN:CharacterPreSave (character)
PLUGIN:CharacterPreSave
Called right before a character is saved.
Parameters:
Character character The character being savedPLUGIN:CanPlayerUseChar (client, char)
PLUGIN:CanPlayerUseChar
Checks whether a player can play as a specific character. Return false and a string to prevent a character from being selected.
Parameters:
Client client The player trying to load a characterCharacter char The character being loaded
Returns:
boolstring Reason the character can't be loaded
PLUGIN:GetDefaultCharDesc (client, faction)
PLUGIN:GetDefaultCharDesc
Returns the default character description used during creation.
Parameters:
Client client The player creating the characterinteger faction The faction index of the character
PLUGIN:GetDefaultCharName (client, faction)
PLUGIN:GetDefaultCharName
Returns the default character name used during creation.
Parameters:
Client client The player creating the characterinteger faction The faction index of the character
PLUGIN:CheckFactionLimitReached (faction, character, client)
PLUGIN:CheckFactionLimitReached
Whether or not more players are allowed to load a character of a specific faction.
Parameters:
faction faction Faction metadataCharacter character The character trying to join
Client client The player trying to join
Returns:
boolPLUGIN:PlayerLoadedChar (client, character, lastChar)
PLUGIN:PlayerLoadedChar
Runs after a player loads a character.
Parameters:
Client client The player EntityCharacter character The new character
Character lastChar [opt] Previous character
PLUGIN:PrePlayerLoadedChar (client, character, lastChar)
PLUGIN:PrePlayerLoadedChar
Runs before a player loads a character.
Parameters:
Client client The player EntityCharacter character The new character
Character lastChar [opt] Previous character
PLUGIN:OnCharVarChanged (char, varName, oldVar, newVar)
PLUGIN:OnCharVarChanged
Triggers whenever a character's var is changed.
Parameters:
Character char The character affectedstring varName Name of the variable
vararg oldVar Old value
vararg newVar New value
Inventory management hooks
PLUGIN:CanItemBeTransfered (itemObject, curInv, inventory)
PLUGIN:CanItemBeTransfered
Check whether an item can be transferred between inventories.
Parameters:
Item itemObject The itemInventory curInv Current inventory
Inventory inventory Target inventory
Returns:
bool Return false to block transferPLUGIN:CanPlayerDropItem (client, item)
PLUGIN:CanPlayerDropItem
Check if a player can drop an item.
Parameters:
Client client The playerItem item The item
Returns:
bool Return false to block droppingPLUGIN:CanPlayerInteractItem (client, action, item)
PLUGIN:CanPlayerInteractItem
Check if a player can interact with an item.
Parameters:
Client client The playerstring action The action name
Item item The item
Returns:
bool Return false to block interactionPLUGIN:CanPlayerTakeItem (client, item)
PLUGIN:CanPlayerTakeItem
Check if a player can take an item.
Parameters:
Client client The playerItem item The item
Returns:
bool Return false to block takingPLUGIN:CreateDefaultInventory (character)
PLUGIN:CreateDefaultInventory
Creates a default inventory for a character.
Parameters:
Character character The characterReturns:
Inventory The created inventoryPLUGIN:CreateInventoryPanel (inventory, parent)
PLUGIN:CreateInventoryPanel
Creates the inventory UI panel.
Parameters:
Inventory inventory The inventoryPanel parent Optional parent panel
Returns:
panel The created panelPLUGIN:GetDefaultInventoryType (character)
PLUGIN:GetDefaultInventoryType
Determines the inventory type for a character.
Parameters:
Character character The characterReturns:
string Inventory type IDPLUGIN:OnInventoryCreated (inventory)
PLUGIN:OnInventoryCreated
Called when an inventory is created.
Parameters:
inventory inventory The new inventoryPLUGIN:OnInventoryDeleted (id)
PLUGIN:OnInventoryDeleted
Called when an inventory is deleted.
Parameters:
integer id The inventory IDPLUGIN:OnInventoryLoaded (inventory)
PLUGIN:OnInventoryLoaded
Called when an inventory is loaded.
Parameters:
inventory inventory The loaded inventoryItem lifecycle hooks
PLUGIN:ItemShowEntityMenu (entity)
PLUGIN:ItemShowEntityMenu
Shows the item entity menu.
Parameters:
vararg entityPLUGIN:OnItemCreated (item)
PLUGIN:OnItemCreated
Called when an item is created.
Parameters:
Item item The itemPLUGIN:OnItemRegistered (item)
PLUGIN:OnItemRegistered
Called after an item is registered.
Parameters:
Item item The item definitionSalary/Money Hooks
PLUGIN:CreateSalaryTimer (client)
PLUGIN:CreateSalaryTimer
Creates a salary timer for a player.
Parameters:
Client client The playerPLUGIN:GetSalaryAmount (client, faction, class)
PLUGIN:GetSalaryAmount
Gets the salary amount for a player.
Parameters:
Client client The playertable faction Faction table
table class Class table
Returns:
number AmountPLUGIN:GetSalaryInterval (client, faction)
PLUGIN:GetSalaryInterval
Gets the salary interval.
Parameters:
Client client The playertable faction Faction table
Returns:
number IntervalPLUGIN:GetSalaryLimit (client, faction, class)
PLUGIN:GetSalaryLimit
Gets the salary cap.
Parameters:
Client client The playertable faction Faction table
table class Class table
Returns:
number LimitPLUGIN:OnPickupMoney (client, moneyEntity)
PLUGIN:OnPickupMoney
Called when a player picks up money
Parameters:
Client client Player picking upEntity moneyEntity Money entity being picked up
Plugin system
PLUGIN:DoPluginIncludes (path, PLUGIN)
PLUGIN:DoPluginIncludes
Loads extra plugin files.
Parameters:
string path Directory pathtable PLUGIN The plugin table
PLUGIN:PluginLoaded (uniqueID, PLUGIN)
PLUGIN:PluginLoaded
Called after plugin is loaded.
Parameters:
string uniqueID The plugin IDtable PLUGIN The plugin table
PLUGIN:PluginShouldLoad (uniqueID)
PLUGIN:PluginShouldLoad
Decides whether plugin should load.
Parameters:
string uniqueID Plugin IDReturns:
bool Return false to block loadPLUGIN:RegisterPreparedStatements ()
PLUGIN:RegisterPreparedStatements
Called when prepared statements should be registered.
Client-side UI
PLUGIN:ScreenResolutionChanged (oldW, oldH)
PLUGIN:ScreenResolutionChanged
Called when the screen resolution changes. This is triggered by a timer that checks resolution every second.
Parameters:
integer oldW Previous screen widthinteger oldH Previous screen height
PLUGIN:LoadNutFonts (font, genericFont, configFont)
PLUGIN:LoadNutFonts
Loads fonts.
Parameters:
string font Main fontstring genericFont Secondary font
string configFont Config font
PLUGIN:ShouldDrawEntityInfo (entity)
PLUGIN:ShouldDrawEntityInfo
Checks if info should draw.
Parameters:
Entity entity The entityReturns:
bool Should draw infoPLUGIN:ShouldCreateLoadingScreen ()
PLUGIN:ShouldCreateLoadingScreen
Checks if loading screen should appear.
PLUGIN:SetupQuickMenu (menu)
PLUGIN:SetupQuickMenu
Sets up quick menu.
Parameters:
Derma menu Quick menu panelPLUGIN:DrawNutModelView (panel, ent)
PLUGIN:DrawNutModelView
Draws model view in panel.
Parameters:
Derma panel Model panelEntity ent Entity
Logging
PLUGIN:OnServerLog (client, logType, ...)
PLUGIN:OnServerLog
Server log output.
Parameters:
Client client The clientstring logType Log type
vararg ... Extra data
Bot hooks
PLUGIN:SetupBotCharacter (client)
PLUGIN:SetupBotCharacter
Sets up bot character.
Parameters:
Client client The botPLUGIN:SetupBotInventory (client, character)
PLUGIN:SetupBotInventory
Sets up bot inventory.
Parameters:
Client client The botCharacter character The bot character
Combat system
PLUGIN:PlayerGetFistDamage (client, damage, context)
PLUGIN:PlayerGetFistDamage
Gets damage for fist SWEP.
Parameters:
Client client The attackerinteger damage Default damage
table context Damage context
Attribute system
PLUGIN:OnCharAttribBoosted (client, character, attribID, boostID, boostAmount)
PLUGIN:OnCharAttribBoosted
Called on attribute boost.
Parameters:
Client client The clientCharacter character The character
string attribID Attribute ID
string boostID Boost ID
number boostAmount Boost value
Fallover
PLUGIN:OnCharFallover (client, ragdoll, fellover)
PLUGIN:OnCharFallover
Called when fallover state changes.
Parameters:
Client client The clientEntity ragdoll The ragdoll
boolean fellover Is ragdolled