Advertisement
Guest User

BASE PRINTER

a guest
Oct 29th, 2016
25
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 35.90 KB | None | 0 0
  1. AddCSLuaFile()
  2.  
  3. ENT.Base = "base_gmodentity"
  4. ENT.Type = "anim"
  5. ENT.Spawnable = false
  6. ENT.AdminOnly = false
  7. ENT.PrintName = "Base Money Printer"
  8. ENT.Author = "husho"
  9.  
  10. ENT.EntityVars = 0
  11. ENT.IntVars = 0
  12. ENT.FloatVars = 0
  13. ENT.StringVars = 0
  14.  
  15. if not ENT.PrintingSpeedLevels then
  16. ENT.PrintingSpeedLevels = {
  17. {LevelName = "None", NameColor = Color(255, 255, 255, 255), Multiplier = 1, MoneyToUpgrade = 0}
  18. }
  19. end
  20.  
  21. if not ENT.PrintingQualityLevels then
  22. ENT.PrintingQualityLevels = {
  23. {LevelName = "None", NameColor = Color(255, 255, 255, 255), Multiplier = 1, MoneyToUpgrade = 0}
  24. }
  25. end
  26.  
  27. if not ENT.PrinterStorageLevels then
  28. ENT.PrinterStorageLevels = {
  29. {LevelName = "None", NameColor = Color(255, 255, 255, 255), Multiplier = 1, MoneyToUpgrade = 0}
  30. }
  31. end
  32.  
  33. if not ENT.CoolingLevels then
  34. ENT.CoolingLevels = {
  35. {LevelName = "None", NameColor = Color(255, 255, 255, 255), Multiplier = 1, MoneyToUpgrade = 0}
  36. }
  37. end
  38.  
  39. function ENT:AddNetVar(Type, Name)
  40. if Type == "Entity" then
  41. self:NetworkVar("Entity", self.EntityVars, Name)
  42. self.EntityVars = self.EntityVars + 1
  43. elseif Type == "Int" then
  44. self:NetworkVar("Int", self.IntVars, Name)
  45. self.IntVars = self.IntVars + 1
  46. elseif Type == "Float" then
  47. self:NetworkVar("Float", self.FloatVars, Name)
  48. self.FloatVars = self.FloatVars + 1
  49. elseif Type == "String" then
  50. self:NetworkVar("String", self.StringVars, Name)
  51. self.StringVars = self.StringVars + 1
  52. end
  53. end
  54.  
  55. function ENT:SetupDataTables()
  56. self:AddNetVar("Entity", "OwningEntity")
  57.  
  58. self:AddNetVar("Int", "SpeedLevel")
  59. self:AddNetVar("Int", "StorageLevel")
  60. self:AddNetVar("Int", "QualityLevel")
  61. self:AddNetVar("Int", "CoolingLevel")
  62.  
  63. self:AddNetVar("Int", "PrintingProgress")
  64.  
  65. if self.InPrinterStorage then
  66. self:AddNetVar("Int", "MoneyInStorage")
  67. end
  68.  
  69. if self.EnableBattery then
  70. self:AddNetVar("Float", "PrinterBattery")
  71. end
  72.  
  73. if self.EnableTemperature then
  74. self:AddNetVar("Float", "Temperature")
  75. end
  76.  
  77. self:AddNetVar("Int", "StatusId")
  78.  
  79. self:AddNetVar("String", "CurrentPage")
  80. end
  81.  
  82. local StatusList = {
  83. [1] = "Reloading",
  84. [2] = "Printing",
  85. [3] = "Overheating",
  86. [4] = "Cooling",
  87. [5] = "Off"
  88. }
  89.  
  90. local StatusIds = {
  91. ["Reloading"] = 1,
  92. ["Printing"] = 2,
  93. ["Overheating"] = 3,
  94. ["Cooling"] = 4,
  95. ["Off"] = 5
  96. }
  97.  
  98. function ENT:GetStatus()
  99. return StatusList[self:GetStatusId()]
  100. end
  101.  
  102. function ENT:SetStatus(State)
  103. return self:SetStatusId(StatusIds[State])
  104. end
  105.  
  106. function ENT:Setowning_ent(Entity)
  107. self:SetOwningEntity(Entity)
  108. end
  109.  
  110. function ENT:Getowning_ent()
  111. return self:GetOwningEntity()
  112. end
  113.  
  114. if SERVER then
  115. util.AddNetworkString("SyncPrinterButtons76561198063652744")
  116.  
  117. net.Receive("SyncPrinterButtons76561198063652744",
  118. function (Length, Player)
  119. local Entity = net.ReadEntity()
  120. local Button = net.ReadUInt(4)
  121.  
  122. if Button == 0 then
  123. if Entity.CurrentPage == 1 then
  124. Entity.CurrentPage = #Entity.Pages
  125. else
  126. Entity.CurrentPage = Entity.CurrentPage - 1
  127. end
  128.  
  129. Entity:SetCurrentPage(Entity.Pages[Entity.CurrentPage])
  130. elseif Button == 1 then
  131. if Entity.CurrentPage == #Entity.Pages then
  132. Entity.CurrentPage = 1
  133. else
  134. Entity.CurrentPage = Entity.CurrentPage + 1
  135. end
  136.  
  137. Entity:SetCurrentPage(Entity.Pages[Entity.CurrentPage])
  138. elseif Button == 2 and Entity.InPrinterStorage then
  139. local Money = Entity:GetMoneyInStorage()
  140.  
  141. if Money > 0 then
  142. Entity:SetPrintingProgress(0)
  143. Entity:SetMoneyInStorage(0)
  144.  
  145. if Entity:GetPrinterBattery() > 0 then
  146. Entity:SetStatus("Reloading")
  147. end
  148.  
  149. Player:addMoney(Money)
  150. DarkRP.notify(Player, 0, 4, "You have taken " .. Money .. "$ from money printer")
  151. end
  152. elseif Button == 3 and Entity.EnableTemperature then
  153. if Entity:GetStatus() ~= "Cooling" and Entity:GetTemperature() > Entity.TemperatureOnSpawn and Entity:GetStatus() ~= "Off" then
  154. Entity:SetStatus("Cooling")
  155. end
  156. elseif Button == 4 and Entity.UpgradablePrintingSpeed then
  157. local Level = Entity:GetSpeedLevel()
  158.  
  159. if Level < #Entity.PrintingSpeedLevels and Player:canAfford(Entity.PrintingSpeedLevels[Level + 1].MoneyToUpgrade) then
  160. Entity:SetPrintingProgress(0)
  161.  
  162. if Entity:GetStatus() ~= "Off" then
  163. Entity:SetStatus("Reloading")
  164. end
  165.  
  166. Player:addMoney(-Entity.PrintingSpeedLevels[Level + 1].MoneyToUpgrade or 0)
  167. Entity:SetSpeedLevel(Level + 1)
  168. else
  169. DarkRP.notify(Player, 1, 4, DarkRP.getPhrase("cant_afford", "upgrade"))
  170. end
  171. elseif Button == 5 and Entity.UpgradablePrinterStorage then
  172. local Level = Entity:GetStorageLevel()
  173.  
  174. if Level < #Entity.PrinterStorageLevels and Player:canAfford(Entity.PrinterStorageLevels[Level + 1].MoneyToUpgrade) then
  175. Entity:SetPrintingProgress(0)
  176.  
  177. if Entity:GetStatus() ~= "Off" then
  178. Entity:SetStatus("Reloading")
  179. end
  180.  
  181. Player:addMoney(-Entity.PrinterStorageLevels[Level + 1].MoneyToUpgrade or 0)
  182. Entity:SetStorageLevel(Level + 1)
  183. Entity.MaxMoneyStorage = Entity.DefaultMaxMoneyStorage * Entity.PrinterStorageLevels[Level + 1].Multiplier
  184. else
  185. DarkRP.notify(Player, 1, 4, DarkRP.getPhrase("cant_afford", "upgrade"))
  186. end
  187. elseif Button == 6 and Entity.UpgradablePrintingQuality then
  188. local Level = Entity:GetQualityLevel()
  189.  
  190. if Level < #Entity.PrintingQualityLevels and Player:canAfford(Entity.PrintingQualityLevels[Level + 1].MoneyToUpgrade) then
  191. Entity:SetPrintingProgress(0)
  192.  
  193. if Entity:GetStatus() ~= "Off" then
  194. Entity:SetStatus("Reloading")
  195. end
  196.  
  197. Player:addMoney(-Entity.PrintingQualityLevels[Level + 1].MoneyToUpgrade or 0)
  198. Entity:SetQualityLevel(Level + 1)
  199. else
  200. DarkRP.notify(Player, 1, 4, DarkRP.getPhrase("cant_afford", "upgrade"))
  201. end
  202. elseif Button == 7 and Entity.UpgradableCooling then
  203. local Level = Entity:GetCoolingLevel()
  204.  
  205. if Level < #Entity.CoolingLevels and Player:canAfford(Entity.CoolingLevels[Level + 1].MoneyToUpgrade) then
  206. Entity:SetPrintingProgress(0)
  207.  
  208. if Entity:GetStatus() ~= "Off" then
  209. Entity:SetStatus("Reloading")
  210. end
  211.  
  212. Player:addMoney(-Entity.CoolingLevels[Level + 1].MoneyToUpgrade or 0)
  213. Entity:SetCoolingLevel(Level + 1)
  214. else
  215. DarkRP.notify(Player, 1, 4, DarkRP.getPhrase("cant_afford", "upgrade"))
  216. end
  217. elseif Button == 8 and Entity.TurnOnOffEnabled then
  218. Entity:SetStatus("Off")
  219. elseif Button == 9 and Entity.TurnOnOffEnabled then
  220. if Entity:GetStatus() == "Off" then
  221. Entity:SetStatus("Reloading")
  222. end
  223. end
  224. end
  225. )
  226.  
  227. function ENT:Initialize()
  228. self:SetModel("models/props_c17/consolebox01a.mdl")
  229. self:PhysicsInit(SOLID_VPHYSICS)
  230. self:SetMoveType(MOVETYPE_VPHYSICS)
  231. self:SetSolid(SOLID_VPHYSICS)
  232. self:GetPhysicsObject():Wake()
  233. self:SetColor(self.PrinterColor)
  234. self.IsMoneyPrinter = true
  235. self.PrinterHealth = 100
  236. self:SetStatus("Reloading")
  237.  
  238. if self.EnableBattery then
  239. self:SetPrinterBattery(self.BatteryValueOnSpawn)
  240. end
  241.  
  242. self:SetPrintingProgress(0)
  243.  
  244. if self.EnableTemperature then
  245. self:SetTemperature(self.TemperatureOnSpawn)
  246. end
  247.  
  248. self:SetCurrentPage("General")
  249. self.CurrentPage = 1
  250. self.ReloadingTicks = 0
  251. self.BurningTicks = 0
  252. self.CoolingTicks = 0
  253.  
  254. self.IsSparking = false
  255.  
  256. self:SetSpeedLevel(1)
  257. self:SetStorageLevel(1)
  258. self:SetQualityLevel(1)
  259. self:SetCoolingLevel(1)
  260.  
  261. if self.InPrinterStorage then
  262. self:SetMoneyInStorage(0)
  263. local Level = self:GetStorageLevel() or 0
  264. self.MaxMoneyStorage = self.DefaultMaxMoneyStorage * self.PrinterStorageLevels[Level].Multiplier
  265. end
  266.  
  267. if self.MakePrintingSound then
  268. self.Sound = CreateSound(self, Sound("ambient/levels/labs/equipment_printer_loop1.wav"))
  269. self.Sound:SetSoundLevel(self.SoundLevel)
  270. end
  271. end
  272.  
  273. function ENT:SetDamage(Amount)
  274. self.PrinterHealth = self.PrinterHealth - Amount
  275.  
  276. if self.EnableTemperature then
  277. self:SetTemperature(self:GetTemperature() + math.random(0, self.DeathTemperature / 2))
  278. end
  279.  
  280. if self.PrinterHealth <= 0 then self:Destroy() return end
  281.  
  282. if self:GetStatus() == "Printing" then
  283. self.ReloadingTicks = 0
  284. self:SetStatus("Reloading")
  285. end
  286. end
  287.  
  288. function ENT:OnTakeDamage(Damage)
  289. if Damage:GetAttacker():GetClass() == "entityflame" then return end
  290.  
  291. --self:SetDamage(76561198063651545)
  292. self:SetDamage(Damage:GetDamage())
  293. end
  294.  
  295. function ENT:Destroy()
  296. local Position = self:GetPos()
  297.  
  298. if self.CreateExplosionWhenDestroy then
  299. local Effect = EffectData()
  300.  
  301. Effect:SetStart(Position)
  302. Effect:SetOrigin(Position)
  303. Effect:SetScale(1)
  304. util.Effect("Explosion", Effect)
  305.  
  306. local Distance = math.random(20, 40)
  307.  
  308. for _, Entity in pairs(ents.FindInSphere(self:GetPos(), Distance)) do
  309. if Entity ~= self then
  310. if not Entity:IsPlayer() and not Entity:IsWeapon() and Entity:GetClass() ~= "predicted_viewmodel" and not Entity.IsMoneyPrinter then
  311. Entity:Ignite(math.random(5, 20), 0)
  312. end
  313.  
  314. if Entity.IsMoneyPrinter and Entity.PrinterHealth > 0 then
  315. Entity:SetDamage(math.random(0, 40))
  316.  
  317. if Entity.EnableTemperature then
  318. Entity:SetTemperature(math.random(Entity.DeathTemperature * 1.1, Entity.DeathTemperature * 5))
  319. end
  320. end
  321.  
  322. if Entity:IsPlayer() then
  323. Entity:TakeDamage(Entity:GetPos():Distance(self:GetPos()) / Distance * 100, self, self)
  324. end
  325. end
  326. end
  327. end
  328.  
  329. DarkRP.notify(self:GetOwningEntity(), 1, 4, DarkRP.getPhrase("money_printer_exploded"))
  330.  
  331. self:Remove()
  332. end
  333.  
  334. function ENT:StartTouch(Entity)
  335. if not Entity.Touched then Entity.Touched = 0 end
  336. Entity.Touched = Entity.Touched + 1
  337. end
  338.  
  339. function ENT:Touch(Entity)
  340. if Entity.IsPrinterBattery and Entity.Touched <= 1 then
  341. Entity:Remove()
  342. self:SetPrinterBattery(self.MaxBatteryValue)
  343.  
  344. if self:GetStatus() == "Off" then
  345. self:SetStatus("Reloading")
  346. end
  347. end
  348. end
  349.  
  350. function ENT:EndTouch(Entity)
  351. if not Entity.Touched then Entity.Touched = 0 return end
  352. Entity.Touched = Entity.Touched - 1
  353. end
  354.  
  355. function ENT:Print()
  356. if not IsValid(self) then return end
  357. local Multiplier = self.PrintingQualityLevels[self:GetQualityLevel()].Multiplier
  358.  
  359. if self.InPrinterStorage then
  360. if not self.InfinitePrinterStorage then
  361. local Money = self:GetMoneyInStorage()
  362.  
  363. if not self.PrintOutsideIfFull and Money + self.PrintMoney * Multiplier >= self.MaxMoneyStorage then
  364. self:SetMoneyInStorage(self.MaxMoneyStorage)
  365. self:SetStatus("Off")
  366.  
  367. return
  368. end
  369.  
  370. if Money < self.MaxMoneyStorage then
  371. self:SetMoneyInStorage(Money + self.PrintMoney * Multiplier)
  372. else
  373. local Position = self:GetPos()
  374. DarkRP.createMoneyBag(Vector(Position.x + 15, Position.y, Position.z + 15), self.PrintMoney * Multiplier)
  375. end
  376. else
  377. self:SetMoneyInStorage(self:GetMoneyInStorage() + self.PrintMoney * Multiplier)
  378. end
  379. else
  380. local Position = self:GetPos()
  381. DarkRP.createMoneyBag(Vector(Position.x + 15, Position.y, Position.z + 15), self.PrintMoney * Multiplier)
  382. end
  383. end
  384.  
  385. function ENT:Think()
  386. if not IsValid(self:GetOwningEntity()) then self:Remove() end
  387. if self:WaterLevel() > 0 then self:Destroy() return end
  388.  
  389. if self:GetStatus() == "Off" then
  390. if self.MakePrintingSound then
  391. if self.Sound then
  392. self.Sound:Stop()
  393. end
  394. end
  395.  
  396. self.IsSparking = false
  397.  
  398. if self.EnableTemperature then
  399. local RandTemp = math.random(0, 0.1)
  400. local Temp = self:GetTemperature()
  401. if Temp - RandTemp >= self.TemperatureOnSpawn then
  402. self:SetTemperature(Temp - RandTemp)
  403. end
  404. end
  405. end
  406.  
  407. if self.EnableTemperature then
  408. if self.BurningTicks >= self.BurningTime then self:Destroy() return end
  409.  
  410. if self.CoolingLevels[self:GetCoolingLevel()].AutoCooling and self:GetStatus() ~= "Cooling" and self:GetTemperature() + self.DeathTemperature / 10 > self.DeathTemperature and self:GetStatus() ~= "Off" then
  411. self:SetStatus("Cooling")
  412.  
  413. return
  414. end
  415.  
  416. if self:GetStatus() == "Overheating" then
  417. self.BurningTicks = self.BurningTicks + 1
  418.  
  419. local Temp = self:GetTemperature()
  420. if Temp * self.BurningTicks < 1500 then
  421. self:SetTemperature(Temp * self.BurningTicks)
  422. else
  423. self:SetTemperature(math.random(1300, 1600))
  424. end
  425.  
  426. if not self:IsOnFire() then
  427. self:Ignite(self.BurningTime)
  428. end
  429.  
  430. return
  431. end
  432.  
  433. if self:GetTemperature() >= self.DeathTemperature and self:GetStatus() ~= "Cooling" then
  434. self:SetStatus("Overheating")
  435. DarkRP.notify(self:GetOwningEntity(), 0, 4, DarkRP.getPhrase("money_printer_overheating"))
  436.  
  437. return
  438. end
  439.  
  440. if self:GetStatus() == "Cooling" then
  441. if self:IsOnFire() then
  442. self:Extinguish()
  443. end
  444.  
  445. self.CoolingTicks = self.CoolingTicks + 1
  446.  
  447. if self.WasteEnergyOnCooling then
  448. local Battery = self:GetPrinterBattery()
  449.  
  450. if Battery - self.WastingAmountOnCooling * self.CoolingLevels[self:GetCoolingLevel()].CoolingMultiplier <= 0 then
  451. self:SetPrinterBattery(0)
  452. self:SetStatus("Off")
  453. else
  454. self:SetPrinterBattery(Battery - self.WastingAmountOnCooling * self.CoolingLevels[self:GetCoolingLevel()].CoolingMultiplier)
  455. end
  456. end
  457.  
  458. if self:GetTemperature() - self.CoolingTemperature * self.CoolingLevels[self:GetCoolingLevel()].CoolingMultiplier <= self.TemperatureOnSpawn then
  459. self:SetTemperature(self.TemperatureOnSpawn)
  460. else
  461. self:SetTemperature(self:GetTemperature() - self.CoolingTemperature * self.CoolingLevels[self:GetCoolingLevel()].CoolingMultiplier)
  462. end
  463.  
  464. if (self.CoolingTicks >= self.CoolingTime / self.CoolingLevels[self:GetCoolingLevel()].CoolingTimeDivider and self:GetTemperature() < self.DeathTemperature) or (self:GetTemperature() <= self.TemperatureOnSpawn) then
  465. self.CoolingTicks = 0
  466.  
  467. if not self.InfinitePrinterStorage then
  468. if self:GetMoneyInStorage() + self.PrintMoney * self.PrintingQualityLevels[self:GetQualityLevel()].Multiplier < self.MaxMoneyStorage then
  469. self:SetStatus("Reloading")
  470. else
  471. self:SetStatus("Off")
  472. end
  473. else
  474. self:SetStatus("Reloading")
  475. end
  476. end
  477. end
  478. end
  479.  
  480. if self:GetStatus() == "Reloading" then
  481. self.ReloadingTicks = self.ReloadingTicks + 1
  482.  
  483. if self.ReloadingTicks >= self.ReloadingTime then
  484. self.ReloadingTicks = 0
  485. self:SetStatus("Printing")
  486. end
  487. end
  488.  
  489. if self:GetStatus() == "Printing" then
  490. if self.MakePrintingSound then
  491. if self.Sound then
  492. if not self.Sound:IsPlaying() then
  493. self.Sound:PlayEx(1, 100)
  494. end
  495. end
  496. end
  497.  
  498. self.IsSparking = true
  499.  
  500. self:SetPrintingProgress(self:GetPrintingProgress() + 1)
  501.  
  502. if self.WasteEnergyOnPrinting then
  503. local Battery = self:GetPrinterBattery()
  504.  
  505. if Battery - self.WastingAmountOnPrinting * self.PrintingSpeedLevels[self:GetSpeedLevel()].Multiplier * self.PrintingQualityLevels[self:GetQualityLevel()].Multiplier <= 0 then
  506. self:SetPrinterBattery(0)
  507. self:SetStatus("Off")
  508. else
  509. self:SetPrinterBattery(Battery - self.WastingAmountOnPrinting * self.PrintingSpeedLevels[self:GetSpeedLevel()].Multiplier * self.PrintingQualityLevels[self:GetQualityLevel()].Multiplier)
  510. end
  511. end
  512.  
  513. if self.EnableTemperature then
  514. self:SetTemperature(self:GetTemperature() + self.HeatingTemperature * self.PrintingSpeedLevels[self:GetSpeedLevel()].Multiplier * self.PrintingQualityLevels[self:GetQualityLevel()].Multiplier / self.CoolingLevels[self:GetCoolingLevel()].HeatingDivider)
  515. end
  516. else
  517. if self.MakePrintingSound then
  518. if self.Sound then
  519. if self.Sound:IsPlaying() then
  520. self.Sound:Stop()
  521. end
  522. end
  523. end
  524.  
  525. self.IsSparking = false
  526. end
  527.  
  528. if self:GetPrintingProgress() >= self.PrintingSpeed / self.PrintingSpeedLevels[self:GetSpeedLevel()].Multiplier and self:GetStatus() ~= "Off" then
  529. self:SetPrintingProgress(0)
  530. self:SetStatus("Reloading")
  531. self:Print()
  532. end
  533.  
  534. if self.IsSparking and self.SparkingEffect then
  535. local Effect = EffectData()
  536. Effect:SetOrigin(self:GetPos())
  537. Effect:SetMagnitude(1)
  538. Effect:SetScale(1)
  539. Effect:SetRadius(2)
  540. util.Effect("Sparks", Effect)
  541. end
  542. end
  543.  
  544. function ENT:OnRemove()
  545. if self.Sound then self.Sound:Stop() end
  546. end
  547. end
  548.  
  549. if CLIENT then
  550. local function NumberRound(Number, Decimal)
  551. local exp = Decimal and 10 ^ Decimal or 1
  552. return math.ceil(Number * exp - 0.5) / exp
  553. end
  554.  
  555. local function NumberFormat(Number, Special)
  556. if type(Number) ~= "number" then
  557. return 0
  558. elseif Number >= 1000000 then
  559. Number = NumberRound(Number / 1000000, 1) .. "m"
  560. elseif Number >= 1000 and not Special then
  561. Number = NumberRound(Number / 1000, 1) .. "k"
  562. elseif Number >= 10000 and Special then
  563. Number = NumberRound(Number / 1000, 1) .. "k"
  564. else
  565. Number = math.floor(Number)
  566. end
  567. return Number
  568. end
  569. --print(NumberFormat(76561198063654743, true))
  570.  
  571. function ENT:Draw()
  572. self:DrawModel()
  573.  
  574. local Player = LocalPlayer()
  575. local Position = self:GetPos() + (self:GetUp() * 11)
  576. local Angles = self:GetAngles()
  577. local Rotation = Vector(0, 90, 0)
  578. local LeftTopX, LeftTopY = -145, -155
  579.  
  580. Angles:RotateAroundAxis(Angles:Right(), Rotation.x)
  581. Angles:RotateAroundAxis(Angles:Up(), Rotation.y)
  582. Angles:RotateAroundAxis(Angles:Forward(), Rotation.z)
  583.  
  584. local Owner = self:GetOwningEntity()
  585. Owner = (IsValid(Owner) and Owner:Nick()) or "Unknown"
  586.  
  587. local Text = self.PrintName
  588.  
  589. if self.EnableBattery then
  590. local Position2 = self:GetPos() + (self:GetForward() * 17)
  591. local Angles2 = self:GetAngles()
  592. local Rotation2 = Vector(0, 90, 90)
  593.  
  594. Angles2:RotateAroundAxis(Angles2:Right(), Rotation2.x)
  595. Angles2:RotateAroundAxis(Angles2:Up(), Rotation2.y)
  596. Angles2:RotateAroundAxis(Angles2:Forward(), Rotation2.z)
  597.  
  598. cam.Start3D2D(Position2, Angles2, 0.1)
  599. draw.RoundedBox(self.BoxesRadiusCorner, -148, -105, 300, 100, self.BatteryBoxColor or Color(0, 0, 0, 150))
  600.  
  601. draw.RoundedBox(0, -121, -78, 176, 46, self.BatteryBgColor or Color(255, 255, 255, 255))
  602. draw.RoundedBox(0, 55, -62, 5, 15, self.BatteryBgColor or Color(255, 255, 255, 255))
  603. draw.RoundedBox(0, -118, -75, self:GetPrinterBattery() / self.MaxBatteryValue * 170, 40, Color(255 - self:GetPrinterBattery() / self.MaxBatteryValue * 255, self:GetPrinterBattery() / self.MaxBatteryValue * 255, 0, 255))
  604.  
  605. draw.SimpleText(math.floor(self:GetPrinterBattery() / self.MaxBatteryValue * 100) .. "%", "hPrinterBattety", 105, -55, self.BatteryTextColor or Color(255, 255, 255, 255), 1, 1)
  606. cam.End3D2D()
  607. end
  608.  
  609. cam.Start3D2D(Position, Angles, 0.1)
  610. local TraceLine = util.TraceLine({start = Player:GetShootPos(), endpos = Player:GetAimVector() * 128 + Player:GetShootPos(), filter = Player})
  611. local HitPosition = self:WorldToLocal(TraceLine.HitPos)
  612.  
  613. if self.ShadowEnabled then
  614. draw.RoundedBox(self.BoxesRadiusCorner, LeftTopX - 2, LeftTopY - 2, -LeftTopX * 2 + 8, 64, self.ShadowColor)
  615. end
  616.  
  617. draw.RoundedBox(self.BoxesRadiusCorner, LeftTopX, LeftTopY , -LeftTopX * 2 + 4, 60, self.NameOwnerBoxColor or Color(255, 255, 255, 255))
  618. draw.SimpleText(Text or "", "hPrinterName", 0, LeftTopY + 5, self.NameTextColor or Color(255, 255, 255, 255), 1, 0)
  619. draw.SimpleText(Owner or "", "hPrinterOwner", 0, LeftTopY + 32, self.OwnerTextColor or Color(255, 255, 255, 255), 1, 0)
  620.  
  621. if self.ShadowEnabled then
  622. draw.RoundedBox(self.BoxesRadiusCorner, LeftTopX - 2, LeftTopY + 218, -LeftTopX * 2 + 8, 74, self.ShadowColor)
  623. end
  624.  
  625. draw.RoundedBox(self.BoxesRadiusCorner, LeftTopX, LeftTopY + 220, -LeftTopX * 2 + 4, 70, self.ButtonsBoxColor or Color(255, 255, 255, 255))
  626.  
  627. local BackButtonColor = self.ButtonsColor or Color(255, 255, 255, 255)
  628.  
  629. if TraceLine.Entity == self and HitPosition.x <= 12.5 and HitPosition.x >= 7.5 and HitPosition.y >= -13.5 and HitPosition.y <= -6.2 then
  630. if Player:KeyDown(IN_USE) and not Player.PrinterKeyPressed then
  631. net.Start("SyncPrinterButtons76561198063652744")
  632. net.WriteEntity(self)
  633. net.WriteUInt(0, 4)
  634. net.SendToServer()
  635.  
  636. Player.PrinterKeyPressed = true
  637. end
  638. BackButtonColor = self.ButtonsColorHovered or Color(255, 255, 255, 255)
  639. end
  640.  
  641. draw.RoundedBox(self.BoxesRadiusCorner, LeftTopX + 10, LeftTopY + 230, 70, 50, BackButtonColor)
  642. surface.SetMaterial(Material("icon16/arrow_left.png"))
  643. surface.SetDrawColor(Color(255, 255, 255, 255))
  644. surface.DrawTexturedRect(-117, 85, 32, 32)
  645.  
  646. local NextButtonColor = self.ButtonsColor or Color(255, 255, 255, 255)
  647.  
  648. if TraceLine.Entity == self and HitPosition.x <= 12.5 and HitPosition.x >= 7.5 and HitPosition.y >= 7 and HitPosition.y <= 14 then
  649. if Player:KeyDown(IN_USE) and not Player.PrinterKeyPressed then
  650. net.Start("SyncPrinterButtons76561198063652744")
  651. net.WriteEntity(self)
  652. net.WriteUInt(1, 4)
  653. net.SendToServer()
  654.  
  655. Player.PrinterKeyPressed = true
  656. end
  657. NextButtonColor = self.ButtonsColorHovered or Color(255, 255, 255, 255)
  658. end
  659.  
  660. draw.RoundedBox(self.BoxesRadiusCorner, LeftTopX + 215, LeftTopY + 230, 70, 50, NextButtonColor)
  661. surface.SetMaterial(Material("icon16/arrow_right.png"))
  662. surface.SetDrawColor(Color(255, 255, 255, 255))
  663. surface.DrawTexturedRect(90, 85, 32, 32)
  664.  
  665. if self.ShadowEnabled then
  666. draw.RoundedBox(self.BoxesRadiusCorner, LeftTopX - 2, LeftTopY + 63, -LeftTopX * 2 + 8, 154, self.ShadowColor)
  667. end
  668.  
  669. draw.RoundedBox(self.BoxesRadiusCorner, LeftTopX, LeftTopY + 65, -LeftTopX * 2 + 4, 150, self.PageBoxColor or Color(255, 255, 255, 255))
  670.  
  671. if self:GetCurrentPage() == "General" then
  672. local TextY, Y = 5, 65
  673.  
  674. if self:GetStatus() == "Printing" then
  675. draw.SimpleText("Status: " .. self:GetStatus() .. "... " .. math.floor(self:GetPrintingProgress() / self.PrintingSpeed * self.PrintingSpeedLevels[self:GetSpeedLevel()].Multiplier * 100) .. "%", "hPrinterPage", LeftTopX + 10, LeftTopY + Y + TextY, self.PageTextColor or Color(255, 255, 255, 255), 0, 0)
  676. else
  677. draw.SimpleText("Status: ".. self:GetStatus() , "hPrinterPage", LeftTopX + 10, LeftTopY + Y + TextY, self.PageTextColor or Color(255, 255, 255, 255), 0, 0)
  678. end
  679.  
  680. if self.InPrinterStorage then
  681. TextY = TextY + 28
  682. if not self.InfinitePrinterStorage then
  683. draw.SimpleText("Storage: " .. NumberFormat(self:GetMoneyInStorage(), true) .. "$ / " .. NumberFormat(self.DefaultMaxMoneyStorage * self.PrinterStorageLevels[self:GetStorageLevel()].Multiplier, true) .. "$", "hPrinterPage", LeftTopX + 10, LeftTopY + Y + TextY, self.PageTextColor or Color(255, 255, 255, 255), 0, 0)
  684. else
  685. draw.SimpleText("Storage: " .. NumberFormat(self:GetMoneyInStorage(), true) .. "$", "hPrinterPage", LeftTopX + 10, LeftTopY + Y + TextY, self.PageTextColor or Color(255, 255, 255, 255), 0, 0)
  686. end
  687. end
  688.  
  689. if self.EnableTemperature then
  690. TextY = TextY + 28
  691. local TempColor = Color(0, 255, 0, 255)
  692.  
  693. if self.DeathTemperature - self:GetTemperature() < self.DeathTemperature / 5 then TempColor = Color(255, 255, 0, 255) end
  694. if self.DeathTemperature - self:GetTemperature() < self.DeathTemperature / 10 then TempColor = Color(255, 0, 0, 255) end
  695.  
  696. draw.SimpleText("Temperature: ", "hPrinterPage", LeftTopX + 10, LeftTopY + Y + TextY, self.PageTextColor or Color(255, 255, 255, 255), 0, 0)
  697. draw.SimpleText(math.floor(self:GetTemperature()) .. self.TemperatureMetricSystem, "hPrinterPage", LeftTopX + 160, LeftTopY + Y + TextY, TempColor, 0, 0)
  698. end
  699.  
  700. if self.InPrinterStorage then
  701. local WithdrawButtonColor = self.ButtonsColor or Color(255, 255, 255, 255)
  702.  
  703. if TraceLine.Entity == self and HitPosition.x <= 5.5 and HitPosition.x >= 0.5 and HitPosition.y >= -13.5 and HitPosition.y <= 0 then
  704. if Player:KeyDown(IN_USE) and not Player.PrinterKeyPressed then
  705. if self.MoneySound then if not self.MoneySound:IsPlaying() then self.MoneySound:PlayEx(1, 100) end end
  706. net.Start("SyncPrinterButtons76561198063652744")
  707. net.WriteEntity(self)
  708. net.WriteUInt(2, 4)
  709. net.SendToServer()
  710.  
  711. Player.PrinterKeyPressed = true
  712. end
  713. WithdrawButtonColor = self.ButtonsColorHovered or Color(255, 255, 255, 255)
  714. end
  715.  
  716. draw.RoundedBox(self.BoxesRadiusCorner, LeftTopX + 12, LeftTopY + 160, 130, 50, WithdrawButtonColor)
  717. draw.SimpleText("Withdraw", "hPrinterPage", LeftTopX + 12 + 65, LeftTopY + 160 + 27, self.WithdrawText or Color(255, 255, 255, 255), 1, 1)
  718. end
  719.  
  720. if self.EnableTemperature and not self.CoolingLevels[self:GetCoolingLevel()].AutoCooling then
  721. local CoolButtonColor = self.ButtonsColor or Color(255, 255, 255, 255)
  722.  
  723. if TraceLine.Entity == self and HitPosition.x <= 5.5 and HitPosition.x >= 0.5 and HitPosition.y >= 1 and HitPosition.y <= 13.5 then
  724. if Player:KeyDown(IN_USE) and not Player.PrinterKeyPressed then
  725. net.Start("SyncPrinterButtons76561198063652744")
  726. net.WriteEntity(self)
  727. net.WriteUInt(3, 4)
  728. net.SendToServer()
  729.  
  730. Player.PrinterKeyPressed = true
  731. end
  732. CoolButtonColor = self.ButtonsColorHovered or Color(255, 255, 255, 255)
  733. end
  734.  
  735. draw.RoundedBox(self.BoxesRadiusCorner, LeftTopX + 152, LeftTopY + 160, 130, 50, CoolButtonColor)
  736. draw.SimpleText("Cool", "hPrinterPage", LeftTopX + 152 + 65, LeftTopY + 160 + 27, self.CoolingText or Color(255, 255, 255, 255), 1, 1)
  737. end
  738. end
  739.  
  740. if self:GetCurrentPage() == "Upgrades" then
  741. local Y = 70
  742.  
  743. if self.UpgradablePrintingSpeed then
  744. local Level = self:GetSpeedLevel()
  745.  
  746. draw.SimpleText("Speed: ", "hPrinterPage", LeftTopX + 10, LeftTopY + Y, self.PageTextColor or Color(255, 255, 255, 255), 0, 0)
  747. draw.SimpleText(self.PrintingSpeedLevels[Level].LevelName or "", "hPrinterPage", LeftTopX + 90, LeftTopY + Y, self.PrintingSpeedLevels[Level].NameColor or Color(255, 255, 255, 255), 0, 0)
  748.  
  749. if Level < #self.PrintingSpeedLevels then
  750. local ButtonColor = self.ButtonsColor or Color(255, 255, 255, 255)
  751.  
  752. if TraceLine.Entity == self and HitPosition.x <= ((LeftTopY + Y - 3) + 35) / 10 and HitPosition.x >= (LeftTopY + Y - 3) / 10 and HitPosition.y >= 6 and HitPosition.y <= 14.5 then
  753. if Player:KeyDown(IN_USE) and not Player.PrinterKeyPressed then
  754. net.Start("SyncPrinterButtons76561198063652744")
  755. net.WriteEntity(self)
  756. net.WriteUInt(4, 4)
  757. net.SendToServer()
  758.  
  759. Player.PrinterKeyPressed = true
  760. end
  761. ButtonColor = self.ButtonsColorHovered or Color(255, 255, 255, 255)
  762. end
  763.  
  764. draw.RoundedBox(self.BoxesRadiusCorner, LeftTopX + 205, LeftTopY + Y - 3, 85, 35, ButtonColor)
  765.  
  766. draw.SimpleText(NumberFormat(self.PrintingSpeedLevels[Level + 1].MoneyToUpgrade, true) .. "$", "hPrinterUpgrade", LeftTopX + 255, LeftTopY + Y + 15, self.UpgradeCostText or Color(255, 255, 255, 255), 1, 1)
  767.  
  768. surface.SetMaterial(Material("icon16/add.png"))
  769. surface.SetDrawColor(Color(255, 255, 255, 255))
  770. surface.DrawTexturedRect(LeftTopX + 207, LeftTopY + Y + 6, 16, 16)
  771. end
  772. end
  773.  
  774. if self.UpgradablePrinterStorage and not self.InfinitePrinterStorage then
  775. local Level = self:GetStorageLevel()
  776.  
  777. Y = Y + 37
  778. draw.SimpleText("Storage: ", "hPrinterPage", LeftTopX + 10, LeftTopY + Y, self.PageTextColor or Color(255, 255, 255, 255), 0, 0)
  779. draw.SimpleText(self.PrinterStorageLevels[Level].LevelName or "", "hPrinterPage", LeftTopX + 107, LeftTopY + Y, self.PrinterStorageLevels[Level].NameColor or Color(255, 255, 255, 255), 0, 0)
  780.  
  781. if Level < #self.PrinterStorageLevels then
  782. local ButtonColor = self.ButtonsColor or Color(255, 255, 255, 255)
  783.  
  784. if TraceLine.Entity == self and HitPosition.x <= ((LeftTopY + Y - 3) + 35) / 10 and HitPosition.x >= (LeftTopY + Y - 3) / 10 and HitPosition.y >= 6 and HitPosition.y <= 14.5 then
  785. if Player:KeyDown(IN_USE) and not Player.PrinterKeyPressed then
  786. net.Start("SyncPrinterButtons76561198063652744")
  787. net.WriteEntity(self)
  788. net.WriteUInt(5, 4)
  789. net.SendToServer()
  790.  
  791. Player.PrinterKeyPressed = true
  792. end
  793. ButtonColor = self.ButtonsColorHovered or Color(255, 255, 255, 255)
  794. end
  795.  
  796. draw.RoundedBox(self.BoxesRadiusCorner, LeftTopX + 205, LeftTopY + Y - 3, 85, 35, ButtonColor)
  797.  
  798. draw.SimpleText(NumberFormat(self.PrinterStorageLevels[Level + 1].MoneyToUpgrade, true) .. "$", "hPrinterUpgrade", LeftTopX + 255, LeftTopY + Y + 15, self.UpgradeCostText or Color(255, 255, 255, 255), 1, 1)
  799.  
  800. surface.SetMaterial(Material("icon16/add.png"))
  801. surface.SetDrawColor(Color(255, 255, 255, 255))
  802. surface.DrawTexturedRect(LeftTopX + 207, LeftTopY + Y + 6, 16, 16)
  803. end
  804. end
  805.  
  806. if self.UpgradablePrintingQuality then
  807. local Level = self:GetQualityLevel()
  808.  
  809. Y = Y + 37
  810. draw.SimpleText("Quality: ", "hPrinterPage", LeftTopX + 10, LeftTopY + Y, self.PageTextColor or Color(255, 255, 255, 255), 0, 0)
  811. draw.SimpleText(self.PrintingQualityLevels[Level].LevelName or "", "hPrinterPage", LeftTopX + 97, LeftTopY + Y, self.PrintingQualityLevels[Level].NameColor or Color(255, 255, 255, 255), 0, 0)
  812.  
  813. if Level < #self.PrintingQualityLevels then
  814. local ButtonColor = self.ButtonsColor or Color(255, 255, 255, 255)
  815.  
  816. if TraceLine.Entity == self and HitPosition.x <= ((LeftTopY + Y - 3) + 35) / 10 and HitPosition.x >= (LeftTopY + Y - 3) / 10 and HitPosition.y >= 6 and HitPosition.y <= 14.5 then
  817. if Player:KeyDown(IN_USE) and not Player.PrinterKeyPressed then
  818. net.Start("SyncPrinterButtons76561198063652744")
  819. net.WriteEntity(self)
  820. net.WriteUInt(6, 4)
  821. net.SendToServer()
  822.  
  823. Player.PrinterKeyPressed = true
  824. end
  825. ButtonColor = self.ButtonsColorHovered or Color(255, 255, 255, 255)
  826. end
  827.  
  828. draw.RoundedBox(self.BoxesRadiusCorner, LeftTopX + 205, LeftTopY + Y - 3, 85, 35, ButtonColor)
  829.  
  830. draw.SimpleText(NumberFormat(self.PrintingQualityLevels[Level + 1].MoneyToUpgrade, true) .. "$", "hPrinterUpgrade", LeftTopX + 255, LeftTopY + Y + 15, self.UpgradeCostText or Color(255, 255, 255, 255), 1, 1)
  831.  
  832. surface.SetMaterial(Material("icon16/add.png"))
  833. surface.SetDrawColor(Color(255, 255, 255, 255))
  834. surface.DrawTexturedRect(LeftTopX + 207, LeftTopY + Y + 6, 16, 16)
  835. end
  836. end
  837.  
  838. if self.UpgradableCooling then
  839. local Level = self:GetCoolingLevel()
  840.  
  841. Y = Y + 37
  842. draw.SimpleText("Cooling: ", "hPrinterPage", LeftTopX + 10, LeftTopY + Y, self.PageTextColor or Color(255, 255, 255, 255), 0, 0)
  843. draw.SimpleText(self.CoolingLevels[Level].LevelName or "", "hPrinterPage", LeftTopX + 100, LeftTopY + Y, self.CoolingLevels[Level].NameColor or Color(255, 255, 255, 255), 0, 0)
  844.  
  845. if Level < #self.CoolingLevels then
  846. local ButtonColor = self.ButtonsColor or Color(255, 255, 255, 255)
  847.  
  848. if TraceLine.Entity == self and HitPosition.x <= ((LeftTopY + Y - 3) + 35) / 10 and HitPosition.x >= (LeftTopY + Y - 3) / 10 and HitPosition.y >= 6 and HitPosition.y <= 14.5 then
  849. if Player:KeyDown(IN_USE) and not Player.PrinterKeyPressed then
  850. net.Start("SyncPrinterButtons76561198063652744")
  851. net.WriteEntity(self)
  852. net.WriteUInt(7, 4)
  853. net.SendToServer()
  854.  
  855. Player.PrinterKeyPressed = true
  856. end
  857. ButtonColor = self.ButtonsColorHovered or Color(255, 255, 255, 255)
  858. end
  859.  
  860. draw.RoundedBox(self.BoxesRadiusCorner, LeftTopX + 205, LeftTopY + Y - 3, 85, 35, ButtonColor)
  861.  
  862. draw.SimpleText(NumberFormat(self.CoolingLevels[Level + 1].MoneyToUpgrade, true) .. "$", "hPrinterUpgrade", LeftTopX + 255, LeftTopY + Y + 15, self.UpgradeCostText or Color(255, 255, 255, 255), 1, 1)
  863.  
  864. surface.SetMaterial(Material("icon16/add.png"))
  865. surface.SetDrawColor(Color(255, 255, 255, 255))
  866. surface.DrawTexturedRect(LeftTopX + 207, LeftTopY + Y + 6, 16, 16)
  867. end
  868. end
  869. end
  870.  
  871. if self:GetCurrentPage() == "Statistics" then
  872. local Y = 70
  873.  
  874. if self:GetStatus() ~= "Off" then
  875. draw.SimpleText("Printing rate: ~ " .. NumberFormat((self.PrintMoney * self.PrintingQualityLevels[self:GetQualityLevel()].Multiplier) / (((self.PrintingSpeed / self.PrintingSpeedLevels[self:GetSpeedLevel()].Multiplier) + self.ReloadingTime) / 5)) .. "$/sec", "hPrinterPage", LeftTopX + 10, LeftTopY + Y, self.PageTextColor or Color(255, 255, 255, 255), 0, 0)
  876. else
  877. draw.SimpleText("Printing rate: 0$/sec", "hPrinterPage", LeftTopX + 10, LeftTopY + Y, self.PageTextColor or Color(255, 255, 255, 255), 0, 0)
  878. end
  879.  
  880. if self.EnableBattery then
  881. Y = Y + 37
  882. local BatteryLifetime = math.floor(self:GetPrinterBattery() / (self.WastingAmountOnPrinting * self.PrintingSpeedLevels[self:GetSpeedLevel()].Multiplier * self.PrintingQualityLevels[self:GetQualityLevel()].Multiplier) / 5)
  883.  
  884. if BatteryLifetime > 60 then
  885. draw.SimpleText("Battery lifetime: ~ " .. NumberFormat(BatteryLifetime / 60) .. " min", "hPrinterPage", LeftTopX + 10, LeftTopY + Y, self.PageTextColor or Color(255, 255, 255, 255), 0, 0)
  886. elseif BatteryLifetime > 0 then
  887. draw.SimpleText("Battery lifetime: ~ " .. BatteryLifetime .. " sec", "hPrinterPage", LeftTopX + 10, LeftTopY + Y, self.PageTextColor or Color(255, 255, 255, 255), 0, 0)
  888. else
  889. draw.SimpleText("Battery lifetime: dead", "hPrinterPage", LeftTopX + 10, LeftTopY + Y, self.PageTextColor or Color(255, 255, 255, 255), 0, 0)
  890. end
  891. end
  892.  
  893. if self.TurnOnOffEnabled then
  894. local ButtonColor1 = self.ButtonsColor or Color(255, 255, 255, 255)
  895. local ButtonColor2 = self.ButtonsColor or Color(255, 255, 255, 255)
  896.  
  897. if TraceLine.Entity == self and HitPosition.x <= 5.5 and HitPosition.x >= 0.5 and HitPosition.y >= -13.5 and HitPosition.y <= 0 then
  898. if Player:KeyDown(IN_USE) and not Player.PrinterKeyPressed then
  899. net.Start("SyncPrinterButtons76561198063652744")
  900. net.WriteEntity(self)
  901. net.WriteUInt(8, 4)
  902. net.SendToServer()
  903.  
  904. Player.PrinterKeyPressed = true
  905. end
  906. ButtonColor1 = self.ButtonsColorHovered or Color(255, 255, 255, 255)
  907. end
  908.  
  909. draw.RoundedBox(self.BoxesRadiusCorner, LeftTopX + 12, LeftTopY + 160, 130, 50, ButtonColor1)
  910. draw.SimpleText("Turn off", "hOnOffText", LeftTopX + 12 + 65, LeftTopY + 160 + 27, self.TurnOffText or Color(255, 255, 255, 255), 1, 1)
  911.  
  912.  
  913. if TraceLine.Entity == self and HitPosition.x <= 5.5 and HitPosition.x >= 0.5 and HitPosition.y >= 1 and HitPosition.y <= 13.5 then
  914. if Player:KeyDown(IN_USE) and not Player.PrinterKeyPressed then
  915. net.Start("SyncPrinterButtons76561198063652744")
  916. net.WriteEntity(self)
  917. net.WriteUInt(9, 4)
  918. net.SendToServer()
  919.  
  920. Player.PrinterKeyPressed = true
  921. end
  922. ButtonColor2 = self.ButtonsColorHovered or Color(255, 255, 255, 255)
  923. end
  924.  
  925. draw.RoundedBox(self.BoxesRadiusCorner, LeftTopX + 152, LeftTopY + 160, 130, 50, ButtonColor2)
  926. draw.SimpleText("Turn on", "hOnOffText", LeftTopX + 152 + 65, LeftTopY + 160 + 27, self.TurnOnText or Color(255, 255, 255, 255), 1, 1)
  927. end
  928. end
  929.  
  930. local CurrPage = self:GetCurrentPage()
  931. if CurrPage == "Statistics" and self.TurnOnOffEnabled then CurrPage = "Control" end
  932.  
  933. draw.SimpleText(CurrPage, "hPrinterPage", 0, LeftTopY + 240, self.CurPageTextColor or Color(255, 255, 255, 255), 1, 0)
  934.  
  935. cam.End3D2D()
  936. end
  937.  
  938. hook.Add("Tick", "PrinterKeyPressed76561198063654970",
  939. function()
  940. local Player = LocalPlayer()
  941. if Player then
  942. if IsValid(Player) then
  943. if not Player:KeyPressed(IN_USE) and not Player:KeyDownLast(IN_USE) then
  944. Player.PrinterKeyPressed = false
  945. end
  946. end
  947. end
  948. end
  949. )
  950. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement