Skip to content

Commit

Permalink
Added Hooks
Browse files Browse the repository at this point in the history
Added hooks for purchasing, selling, equiping, holstering, and modifying.
  • Loading branch information
xbeastguyx authored Jul 10, 2016
1 parent c8ee2aa commit 1178818
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions lua/pointshop/sv_player_extension.lua
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
PS_ITEM_EQUIP = 1 or PS_ITEM_EQUIP
PS_ITEM_HOLSTER = 2 or PS_ITEM_HOLSTER
PS_ITEM_MODIFIED = 3 or PS_ITEM_MODIFIED

local Player = FindMetaTable('Player')

function Player:PS_PlayerSpawn()
Expand Down Expand Up @@ -242,6 +246,8 @@ function Player:PS_BuyItem(item_id)
self:PS_Notify('Bought ', ITEM.Name, ' for ', points, ' ', PS.Config.PointsName)

ITEM:OnBuy(self)

hook.Call( "PS_ItemBought", nil, self, item_id )

if ITEM.SingleUse then
self:PS_Notify('Single use item. You\'ll have to buy this item again next time!')
Expand Down Expand Up @@ -277,6 +283,8 @@ function Player:PS_SellItem(item_id)

ITEM:OnHolster(self)
ITEM:OnSell(self)

hook.Call( "PS_ItemSold", nil, self, item_id )

self:PS_Notify('Sold ', ITEM.Name, ' for ', points, ' ', PS.Config.PointsName)

Expand Down Expand Up @@ -382,6 +390,8 @@ function Player:PS_EquipItem(item_id)
ITEM:OnEquip(self, self.PS_Items[item_id].Modifiers)

self:PS_Notify('Equipped ', ITEM.Name, '.')

hook.Call( "PS_ItemUpdated", nil, self, item_id, PS_ITEM_EQUIP )

PS:SavePlayerItem(self, item_id, self.PS_Items[item_id])

Expand Down Expand Up @@ -411,6 +421,8 @@ function Player:PS_HolsterItem(item_id)
ITEM:OnHolster(self)

self:PS_Notify('Holstered ', ITEM.Name, '.')

hook.Call( "PS_ItemUpdated", nil, self, item_id, PS_ITEM_HOLSTER )

PS:SavePlayerItem(self, item_id, self.PS_Items[item_id])

Expand All @@ -433,6 +445,8 @@ function Player:PS_ModifyItem(item_id, modifications)

ITEM:OnModify(self, self.PS_Items[item_id].Modifiers)

hook.Call( "PS_ItemUpdated", nil, self, item_id, PS_ITEM_MODIFIED, modifications )

PS:SavePlayerItem(self, item_id, self.PS_Items[item_id])

self:PS_SendItems()
Expand Down

0 comments on commit 1178818

Please sign in to comment.