Advertisement
Guest User

Untitled

a guest
Feb 9th, 2016
109
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.23 KB | None | 0 0
  1. --[[
  2. DarkRP Gemstone Printers - https://github.com/dkoz/gsprinters
  3. Created by Koz - http://steamcommunity.com/profiles/76561197989811664
  4. --]]
  5.  
  6. AddCSLuaFile("cl_init.lua")
  7. AddCSLuaFile("shared.lua")
  8. include("shared.lua")
  9.  
  10. ENT.SeizeReward = 950
  11.  
  12. local PrintMore
  13. function ENT:Initialize()
  14. local tcolor = gemstone.config.topazcolor
  15.  
  16. self:SetModel("models/props_c17/consolebox01a.mdl")
  17. self:PhysicsInit(SOLID_VPHYSICS)
  18. self:SetMoveType(MOVETYPE_VPHYSICS)
  19. self:SetSolid(SOLID_VPHYSICS)
  20. self:SetColor( tcolor )
  21. local phys = self:GetPhysicsObject()
  22. if phys:IsValid() then phys:Wake() end
  23. self.damage = 100
  24. self.IsMoneyPrinter = true
  25. timer.Simple(1.0, function() PrintMore(self) end)
  26. self:SetNWInt("PrintA",0)
  27.  
  28. self.sound = CreateSound(self, Sound("ambient/levels/labs/equipment_printer_loop1.wav"))
  29. self.sound:SetSoundLevel(52)
  30. self.sound:PlayEx(1, 100)
  31. end
  32.  
  33. function ENT:OnTakeDamage(dmg)
  34. if self.burningup then return end
  35.  
  36. self.damage = (self.damage or 100) - dmg:GetDamage()
  37. if self.damage <= 0 then
  38. local rnd = math.random(1, 10)
  39. if rnd < 6 then
  40. self:BurstIntoFlames()
  41. else
  42. self:Destruct()
  43. self:Remove()
  44. end
  45. end
  46. end
  47.  
  48. function ENT:Destruct()
  49. local vPoint = self:GetPos()
  50. local effectdata = EffectData()
  51. effectdata:SetStart(vPoint)
  52. effectdata:SetOrigin(vPoint)
  53. effectdata:SetScale(1)
  54. util.Effect("Explosion", effectdata)
  55. DarkRP.notify(self:Getowning_ent(), 1, 4, "Your money printer has exploded!")
  56. end
  57.  
  58. function ENT:BurstIntoFlames()
  59. DarkRP.notify(self:Getowning_ent(), 1, 4, "Your money printer is overheating!")
  60. self.burningup = true
  61. local burntime = math.random(8, 18)
  62. self:Ignite(burntime, 0)
  63. timer.Simple(burntime, function() self:Fireball() end)
  64. end
  65.  
  66. function ENT:Fireball()
  67. if not self:IsOnFire() then self.burningup = false return end
  68. local dist = math.random(5, 50) -- Explosion radius
  69. self:Destruct()
  70. for k, v in pairs(ents.FindInSphere(self:GetPos(), dist)) do
  71. if not v:IsPlayer() and not v:IsWeapon() and v:GetClass() ~= "predicted_viewmodel" and not v.IsMoneyPrinter then
  72. v:Ignite(math.random(5, 22), 0)
  73. elseif v:IsPlayer() then
  74. local distance = v:GetPos():Distance(self:GetPos())
  75. v:TakeDamage(distance / dist * 100, self, self)
  76. end
  77. end
  78. self:Remove()
  79. end
  80.  
  81. PrintMore = function(ent)
  82. if IsValid(ent) then
  83. ent.sparking = true
  84. timer.Simple(1.0, function() ent:CreateMoneybag() end)
  85. end
  86. end
  87.  
  88. function ENT:CreateMoneybag()
  89. if not IsValid(self) then return end
  90. if self:IsOnFire() then return end
  91. local MoneyPos = self:GetPos()
  92. local printamount = gemstone.config.topazprintamount
  93. local printtime = gemstone.config.topazprinttime
  94. if math.random(1, 1000) == 3 then self:BurstIntoFlames() end
  95. local amount = self:GetNWInt("PrintA") + printamount
  96. self:SetNWInt("PrintA",amount)
  97. self.sparking = false
  98. timer.Simple(printtime, function() PrintMore(self) end)
  99. end
  100.  
  101. function ENT:Use(activator)
  102. if(activator:IsPlayer()) and self:GetNWInt("PrintA") >= 1 then
  103. activator:addMoney(self:GetNWInt("PrintA"));
  104. DarkRP.notify(activator, 1, 4, "You have collected $"..self:GetNWInt("PrintA").." from a Topaz Printer.")
  105. self:SetNWInt("PrintA",0)
  106. end
  107. end
  108.  
  109. function ENT:OnRemove()
  110. if self.sound then
  111. self.sound:Stop()
  112. end
  113. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement