Guest User

Untitled

a guest
Nov 20th, 2020
636
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.22 KB | None | 0 0
  1. local ITEM = BRICKS_SERVER.Func.CreateItemType( "custom_printer" ) -- This line creates the item, the argument should be the entity class.
  2.  
  3. ITEM.GetItemData = function( ent ) -- This function is used for getting the data from an entity
  4.     local itemData = { "custom_printer", ent:GetModel() } -- The 1st value should be the entity class and the 2nd the model
  5.     itemData[3] = ent:GetMoney() -- Any other values can be used for entity specific data
  6.  
  7.     return itemData, 1 -- You need to return two values, the first is the itemData and the second is the amount
  8. end
  9.  
  10. ITEM.OnSpawn = function( ply, pos, itemData, itemAmount ) -- This function is used when the entity is dropped
  11.     local ent = ents.Create( "custom_printer" )
  12.     if( not IsValid( ent ) ) then return end
  13.     ent:SetPos( pos )
  14.     ent:SetModel( itemData[2] )
  15.     ent:SetMoney( itemData[3] )
  16.     ent:Spawn()
  17. end
  18.  
  19. ITEM.GetInfo = function( itemData ) -- This function returns info about the entity, the itemData is provided here
  20.     return { "Money Printer", "A basic money printer!", (BRICKS_SERVER.CONFIG.INVENTORY.ItemRarities or {})["custom_printer"] } -- The 1st value is the name, the 2nd is the description and the 3rd is the item rarity
  21. end
  22.  
  23. ITEM:Register()
Advertisement
Add Comment
Please, Sign In to add comment