thomasfn

Untitled

Sep 9th, 2011
135
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.64 KB | None | 0 0
  1.  
  2. local metaInv = {}
  3. metaInv.__index = metaInv
  4.  
  5. function _R.Player:GetInventory()
  6. if (self.Inv) then return self.Inv end
  7. local o = {}
  8. setmetatable( o, metaInv )
  9. o:New( self )
  10. self.Inv = o
  11. return o
  12. end
  13.  
  14. function metaInv:New( ply )
  15. self.Owner = ply
  16. self.Items = {}
  17. print( "Inventory object for " .. ply:Nick() .. " created." )
  18. end
  19.  
  20. function metaInv:PickupItem( ent )
  21. print( self.Owner:Nick() .. " picked up a " .. ent:ClassName() .. "." )
  22. ent:Remove()
  23. end
  24.  
  25.  
  26.  
  27. hooks.Add( "PlayerUse", "testinventory", function( ply, ent )
  28. if (ent:ClassName() == "prop_physics") then
  29. ply:GetInventory():PickupItem( ent )
  30. end
  31. end )
Advertisement
Add Comment
Please, Sign In to add comment