Advertisement
Guest User

Untitled

a guest
Feb 21st, 2019
102
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.49 KB | None | 0 0
  1. -- Again, this is all a prototype, shouldn't be taken seriously, I didn't think alot about it, started writting what had made sense for me at the time.
  2.  
  3. SRH.Shipments = SRH.Shipments or {}
  4.  
  5. SRH.Shipments.All = {}
  6.  
  7.  
  8. function SRH.Shipments:Register( class, single, type, model, amount, price, name, access )
  9.  
  10. self.All[ name ] = { class, single, type, model, amount, price, name, access }
  11.  
  12. end
  13.  
  14.  
  15. function SRH.Shipments:Buy( ply, shipmentname )
  16.  
  17. local shipment = self.All[ shipmentname ]
  18.  
  19. if not ply:CanAfford( shipment.price ) then
  20.  
  21. ply:Error( "You can't afford this " .. shipment.name .. " ($" .. shipment.price .. ")!" )
  22. return
  23. end
  24.  
  25. if shipment.single then
  26.  
  27. ply:AddMoney( -shipment.price )
  28.  
  29. local ship = ents.Create( shipment.class )
  30.  
  31. ship:SetPos( ply:GetEyeTrace().HitPos + Vector( 0, 0, 10 ) )
  32. ship:Spawn()
  33. return
  34. else
  35.  
  36. ply:AddMoney( -shipment.price )
  37.  
  38. local ship = ents.Create( "shipment_base" )
  39.  
  40. ship:SetModel( shipment.model )
  41.  
  42. ship.ShipmentName = shipment.name
  43. ship.Amount = shipment.amount
  44. ship.Container = shipment.class
  45.  
  46. end
  47.  
  48. end
  49.  
  50. -- examples
  51.  
  52. -- SRH.Shipments:Register( "weapon_pist_deagle", true, "gun", "deaglemodel.mdl", 1, 300, "Desert Eagle", { {"Trader", 3}, {"Arms Dealer", 1} } )
  53. -- SRH.Shipments:Register( "weapon_snip_scout", false, "gun", "scoutmodel.mdl", 5, 2000, "Scout Shipment", { {"Arms Dealer", 1} } )
  54. -- SRH.Shipments:Register( "drug_lsd", true, "drug", "lsdmodel.mdl", 1, 400, "LSD", { {"Trader", 2} } )
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement