Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- AddCSLuaFile()
- ENT.Base = "base_gmodentity"
- ENT.Type = "anim"
- ENT.Spawnable = false
- ENT.AdminOnly = false
- ENT.PrintName = "Base Money Printer"
- ENT.Author = "husho"
- ENT.EntityVars = 0
- ENT.IntVars = 0
- ENT.FloatVars = 0
- ENT.StringVars = 0
- if not ENT.PrintingSpeedLevels then
- ENT.PrintingSpeedLevels = {
- {LevelName = "None", NameColor = Color(255, 255, 255, 255), Multiplier = 1, MoneyToUpgrade = 0}
- }
- end
- if not ENT.PrintingQualityLevels then
- ENT.PrintingQualityLevels = {
- {LevelName = "None", NameColor = Color(255, 255, 255, 255), Multiplier = 1, MoneyToUpgrade = 0}
- }
- end
- if not ENT.PrinterStorageLevels then
- ENT.PrinterStorageLevels = {
- {LevelName = "None", NameColor = Color(255, 255, 255, 255), Multiplier = 1, MoneyToUpgrade = 0}
- }
- end
- if not ENT.CoolingLevels then
- ENT.CoolingLevels = {
- {LevelName = "None", NameColor = Color(255, 255, 255, 255), Multiplier = 1, MoneyToUpgrade = 0}
- }
- end
- function ENT:AddNetVar(Type, Name)
- if Type == "Entity" then
- self:NetworkVar("Entity", self.EntityVars, Name)
- self.EntityVars = self.EntityVars + 1
- elseif Type == "Int" then
- self:NetworkVar("Int", self.IntVars, Name)
- self.IntVars = self.IntVars + 1
- elseif Type == "Float" then
- self:NetworkVar("Float", self.FloatVars, Name)
- self.FloatVars = self.FloatVars + 1
- elseif Type == "String" then
- self:NetworkVar("String", self.StringVars, Name)
- self.StringVars = self.StringVars + 1
- end
- end
- function ENT:SetupDataTables()
- self:AddNetVar("Entity", "OwningEntity")
- self:AddNetVar("Int", "SpeedLevel")
- self:AddNetVar("Int", "StorageLevel")
- self:AddNetVar("Int", "QualityLevel")
- self:AddNetVar("Int", "CoolingLevel")
- self:AddNetVar("Int", "PrintingProgress")
- if self.InPrinterStorage then
- self:AddNetVar("Int", "MoneyInStorage")
- end
- if self.EnableBattery then
- self:AddNetVar("Float", "PrinterBattery")
- end
- if self.EnableTemperature then
- self:AddNetVar("Float", "Temperature")
- end
- self:AddNetVar("Int", "StatusId")
- self:AddNetVar("String", "CurrentPage")
- end
- local StatusList = {
- [1] = "Reloading",
- [2] = "Printing",
- [3] = "Overheating",
- [4] = "Cooling",
- [5] = "Off"
- }
- local StatusIds = {
- ["Reloading"] = 1,
- ["Printing"] = 2,
- ["Overheating"] = 3,
- ["Cooling"] = 4,
- ["Off"] = 5
- }
- function ENT:GetStatus()
- return StatusList[self:GetStatusId()]
- end
- function ENT:SetStatus(State)
- return self:SetStatusId(StatusIds[State])
- end
- function ENT:Setowning_ent(Entity)
- self:SetOwningEntity(Entity)
- end
- function ENT:Getowning_ent()
- return self:GetOwningEntity()
- end
- if SERVER then
- util.AddNetworkString("SyncPrinterButtons76561198063652744")
- net.Receive("SyncPrinterButtons76561198063652744",
- function (Length, Player)
- local Entity = net.ReadEntity()
- local Button = net.ReadUInt(4)
- if Button == 0 then
- if Entity.CurrentPage == 1 then
- Entity.CurrentPage = #Entity.Pages
- else
- Entity.CurrentPage = Entity.CurrentPage - 1
- end
- Entity:SetCurrentPage(Entity.Pages[Entity.CurrentPage])
- elseif Button == 1 then
- if Entity.CurrentPage == #Entity.Pages then
- Entity.CurrentPage = 1
- else
- Entity.CurrentPage = Entity.CurrentPage + 1
- end
- Entity:SetCurrentPage(Entity.Pages[Entity.CurrentPage])
- elseif Button == 2 and Entity.InPrinterStorage then
- local Money = Entity:GetMoneyInStorage()
- if Money > 0 then
- Entity:SetPrintingProgress(0)
- Entity:SetMoneyInStorage(0)
- if Entity:GetPrinterBattery() > 0 then
- Entity:SetStatus("Reloading")
- end
- Player:addMoney(Money)
- DarkRP.notify(Player, 0, 4, "You have taken " .. Money .. "$ from money printer")
- end
- elseif Button == 3 and Entity.EnableTemperature then
- if Entity:GetStatus() ~= "Cooling" and Entity:GetTemperature() > Entity.TemperatureOnSpawn and Entity:GetStatus() ~= "Off" then
- Entity:SetStatus("Cooling")
- end
- elseif Button == 4 and Entity.UpgradablePrintingSpeed then
- local Level = Entity:GetSpeedLevel()
- if Level < #Entity.PrintingSpeedLevels and Player:canAfford(Entity.PrintingSpeedLevels[Level + 1].MoneyToUpgrade) then
- Entity:SetPrintingProgress(0)
- if Entity:GetStatus() ~= "Off" then
- Entity:SetStatus("Reloading")
- end
- Player:addMoney(-Entity.PrintingSpeedLevels[Level + 1].MoneyToUpgrade or 0)
- Entity:SetSpeedLevel(Level + 1)
- else
- DarkRP.notify(Player, 1, 4, DarkRP.getPhrase("cant_afford", "upgrade"))
- end
- elseif Button == 5 and Entity.UpgradablePrinterStorage then
- local Level = Entity:GetStorageLevel()
- if Level < #Entity.PrinterStorageLevels and Player:canAfford(Entity.PrinterStorageLevels[Level + 1].MoneyToUpgrade) then
- Entity:SetPrintingProgress(0)
- if Entity:GetStatus() ~= "Off" then
- Entity:SetStatus("Reloading")
- end
- Player:addMoney(-Entity.PrinterStorageLevels[Level + 1].MoneyToUpgrade or 0)
- Entity:SetStorageLevel(Level + 1)
- Entity.MaxMoneyStorage = Entity.DefaultMaxMoneyStorage * Entity.PrinterStorageLevels[Level + 1].Multiplier
- else
- DarkRP.notify(Player, 1, 4, DarkRP.getPhrase("cant_afford", "upgrade"))
- end
- elseif Button == 6 and Entity.UpgradablePrintingQuality then
- local Level = Entity:GetQualityLevel()
- if Level < #Entity.PrintingQualityLevels and Player:canAfford(Entity.PrintingQualityLevels[Level + 1].MoneyToUpgrade) then
- Entity:SetPrintingProgress(0)
- if Entity:GetStatus() ~= "Off" then
- Entity:SetStatus("Reloading")
- end
- Player:addMoney(-Entity.PrintingQualityLevels[Level + 1].MoneyToUpgrade or 0)
- Entity:SetQualityLevel(Level + 1)
- else
- DarkRP.notify(Player, 1, 4, DarkRP.getPhrase("cant_afford", "upgrade"))
- end
- elseif Button == 7 and Entity.UpgradableCooling then
- local Level = Entity:GetCoolingLevel()
- if Level < #Entity.CoolingLevels and Player:canAfford(Entity.CoolingLevels[Level + 1].MoneyToUpgrade) then
- Entity:SetPrintingProgress(0)
- if Entity:GetStatus() ~= "Off" then
- Entity:SetStatus("Reloading")
- end
- Player:addMoney(-Entity.CoolingLevels[Level + 1].MoneyToUpgrade or 0)
- Entity:SetCoolingLevel(Level + 1)
- else
- DarkRP.notify(Player, 1, 4, DarkRP.getPhrase("cant_afford", "upgrade"))
- end
- elseif Button == 8 and Entity.TurnOnOffEnabled then
- Entity:SetStatus("Off")
- elseif Button == 9 and Entity.TurnOnOffEnabled then
- if Entity:GetStatus() == "Off" then
- Entity:SetStatus("Reloading")
- end
- end
- end
- )
- function ENT:Initialize()
- self:SetModel("models/props_c17/consolebox01a.mdl")
- self:PhysicsInit(SOLID_VPHYSICS)
- self:SetMoveType(MOVETYPE_VPHYSICS)
- self:SetSolid(SOLID_VPHYSICS)
- self:GetPhysicsObject():Wake()
- self:SetColor(self.PrinterColor)
- self.IsMoneyPrinter = true
- self.PrinterHealth = 100
- self:SetStatus("Reloading")
- if self.EnableBattery then
- self:SetPrinterBattery(self.BatteryValueOnSpawn)
- end
- self:SetPrintingProgress(0)
- if self.EnableTemperature then
- self:SetTemperature(self.TemperatureOnSpawn)
- end
- self:SetCurrentPage("General")
- self.CurrentPage = 1
- self.ReloadingTicks = 0
- self.BurningTicks = 0
- self.CoolingTicks = 0
- self.IsSparking = false
- self:SetSpeedLevel(1)
- self:SetStorageLevel(1)
- self:SetQualityLevel(1)
- self:SetCoolingLevel(1)
- if self.InPrinterStorage then
- self:SetMoneyInStorage(0)
- local Level = self:GetStorageLevel() or 0
- self.MaxMoneyStorage = self.DefaultMaxMoneyStorage * self.PrinterStorageLevels[Level].Multiplier
- end
- if self.MakePrintingSound then
- self.Sound = CreateSound(self, Sound("ambient/levels/labs/equipment_printer_loop1.wav"))
- self.Sound:SetSoundLevel(self.SoundLevel)
- end
- end
- function ENT:SetDamage(Amount)
- self.PrinterHealth = self.PrinterHealth - Amount
- if self.EnableTemperature then
- self:SetTemperature(self:GetTemperature() + math.random(0, self.DeathTemperature / 2))
- end
- if self.PrinterHealth <= 0 then self:Destroy() return end
- if self:GetStatus() == "Printing" then
- self.ReloadingTicks = 0
- self:SetStatus("Reloading")
- end
- end
- function ENT:OnTakeDamage(Damage)
- if Damage:GetAttacker():GetClass() == "entityflame" then return end
- --self:SetDamage(76561198063651545)
- self:SetDamage(Damage:GetDamage())
- end
- function ENT:Destroy()
- local Position = self:GetPos()
- if self.CreateExplosionWhenDestroy then
- local Effect = EffectData()
- Effect:SetStart(Position)
- Effect:SetOrigin(Position)
- Effect:SetScale(1)
- util.Effect("Explosion", Effect)
- local Distance = math.random(20, 40)
- for _, Entity in pairs(ents.FindInSphere(self:GetPos(), Distance)) do
- if Entity ~= self then
- if not Entity:IsPlayer() and not Entity:IsWeapon() and Entity:GetClass() ~= "predicted_viewmodel" and not Entity.IsMoneyPrinter then
- Entity:Ignite(math.random(5, 20), 0)
- end
- if Entity.IsMoneyPrinter and Entity.PrinterHealth > 0 then
- Entity:SetDamage(math.random(0, 40))
- if Entity.EnableTemperature then
- Entity:SetTemperature(math.random(Entity.DeathTemperature * 1.1, Entity.DeathTemperature * 5))
- end
- end
- if Entity:IsPlayer() then
- Entity:TakeDamage(Entity:GetPos():Distance(self:GetPos()) / Distance * 100, self, self)
- end
- end
- end
- end
- DarkRP.notify(self:GetOwningEntity(), 1, 4, DarkRP.getPhrase("money_printer_exploded"))
- self:Remove()
- end
- function ENT:StartTouch(Entity)
- if not Entity.Touched then Entity.Touched = 0 end
- Entity.Touched = Entity.Touched + 1
- end
- function ENT:Touch(Entity)
- if Entity.IsPrinterBattery and Entity.Touched <= 1 then
- Entity:Remove()
- self:SetPrinterBattery(self.MaxBatteryValue)
- if self:GetStatus() == "Off" then
- self:SetStatus("Reloading")
- end
- end
- end
- function ENT:EndTouch(Entity)
- if not Entity.Touched then Entity.Touched = 0 return end
- Entity.Touched = Entity.Touched - 1
- end
- function ENT:Print()
- if not IsValid(self) then return end
- local Multiplier = self.PrintingQualityLevels[self:GetQualityLevel()].Multiplier
- if self.InPrinterStorage then
- if not self.InfinitePrinterStorage then
- local Money = self:GetMoneyInStorage()
- if not self.PrintOutsideIfFull and Money + self.PrintMoney * Multiplier >= self.MaxMoneyStorage then
- self:SetMoneyInStorage(self.MaxMoneyStorage)
- self:SetStatus("Off")
- return
- end
- if Money < self.MaxMoneyStorage then
- self:SetMoneyInStorage(Money + self.PrintMoney * Multiplier)
- else
- local Position = self:GetPos()
- DarkRP.createMoneyBag(Vector(Position.x + 15, Position.y, Position.z + 15), self.PrintMoney * Multiplier)
- end
- else
- self:SetMoneyInStorage(self:GetMoneyInStorage() + self.PrintMoney * Multiplier)
- end
- else
- local Position = self:GetPos()
- DarkRP.createMoneyBag(Vector(Position.x + 15, Position.y, Position.z + 15), self.PrintMoney * Multiplier)
- end
- end
- function ENT:Think()
- if not IsValid(self:GetOwningEntity()) then self:Remove() end
- if self:WaterLevel() > 0 then self:Destroy() return end
- if self:GetStatus() == "Off" then
- if self.MakePrintingSound then
- if self.Sound then
- self.Sound:Stop()
- end
- end
- self.IsSparking = false
- if self.EnableTemperature then
- local RandTemp = math.random(0, 0.1)
- local Temp = self:GetTemperature()
- if Temp - RandTemp >= self.TemperatureOnSpawn then
- self:SetTemperature(Temp - RandTemp)
- end
- end
- end
- if self.EnableTemperature then
- if self.BurningTicks >= self.BurningTime then self:Destroy() return end
- if self.CoolingLevels[self:GetCoolingLevel()].AutoCooling and self:GetStatus() ~= "Cooling" and self:GetTemperature() + self.DeathTemperature / 10 > self.DeathTemperature and self:GetStatus() ~= "Off" then
- self:SetStatus("Cooling")
- return
- end
- if self:GetStatus() == "Overheating" then
- self.BurningTicks = self.BurningTicks + 1
- local Temp = self:GetTemperature()
- if Temp * self.BurningTicks < 1500 then
- self:SetTemperature(Temp * self.BurningTicks)
- else
- self:SetTemperature(math.random(1300, 1600))
- end
- if not self:IsOnFire() then
- self:Ignite(self.BurningTime)
- end
- return
- end
- if self:GetTemperature() >= self.DeathTemperature and self:GetStatus() ~= "Cooling" then
- self:SetStatus("Overheating")
- DarkRP.notify(self:GetOwningEntity(), 0, 4, DarkRP.getPhrase("money_printer_overheating"))
- return
- end
- if self:GetStatus() == "Cooling" then
- if self:IsOnFire() then
- self:Extinguish()
- end
- self.CoolingTicks = self.CoolingTicks + 1
- if self.WasteEnergyOnCooling then
- local Battery = self:GetPrinterBattery()
- if Battery - self.WastingAmountOnCooling * self.CoolingLevels[self:GetCoolingLevel()].CoolingMultiplier <= 0 then
- self:SetPrinterBattery(0)
- self:SetStatus("Off")
- else
- self:SetPrinterBattery(Battery - self.WastingAmountOnCooling * self.CoolingLevels[self:GetCoolingLevel()].CoolingMultiplier)
- end
- end
- if self:GetTemperature() - self.CoolingTemperature * self.CoolingLevels[self:GetCoolingLevel()].CoolingMultiplier <= self.TemperatureOnSpawn then
- self:SetTemperature(self.TemperatureOnSpawn)
- else
- self:SetTemperature(self:GetTemperature() - self.CoolingTemperature * self.CoolingLevels[self:GetCoolingLevel()].CoolingMultiplier)
- end
- if (self.CoolingTicks >= self.CoolingTime / self.CoolingLevels[self:GetCoolingLevel()].CoolingTimeDivider and self:GetTemperature() < self.DeathTemperature) or (self:GetTemperature() <= self.TemperatureOnSpawn) then
- self.CoolingTicks = 0
- if not self.InfinitePrinterStorage then
- if self:GetMoneyInStorage() + self.PrintMoney * self.PrintingQualityLevels[self:GetQualityLevel()].Multiplier < self.MaxMoneyStorage then
- self:SetStatus("Reloading")
- else
- self:SetStatus("Off")
- end
- else
- self:SetStatus("Reloading")
- end
- end
- end
- end
- if self:GetStatus() == "Reloading" then
- self.ReloadingTicks = self.ReloadingTicks + 1
- if self.ReloadingTicks >= self.ReloadingTime then
- self.ReloadingTicks = 0
- self:SetStatus("Printing")
- end
- end
- if self:GetStatus() == "Printing" then
- if self.MakePrintingSound then
- if self.Sound then
- if not self.Sound:IsPlaying() then
- self.Sound:PlayEx(1, 100)
- end
- end
- end
- self.IsSparking = true
- self:SetPrintingProgress(self:GetPrintingProgress() + 1)
- if self.WasteEnergyOnPrinting then
- local Battery = self:GetPrinterBattery()
- if Battery - self.WastingAmountOnPrinting * self.PrintingSpeedLevels[self:GetSpeedLevel()].Multiplier * self.PrintingQualityLevels[self:GetQualityLevel()].Multiplier <= 0 then
- self:SetPrinterBattery(0)
- self:SetStatus("Off")
- else
- self:SetPrinterBattery(Battery - self.WastingAmountOnPrinting * self.PrintingSpeedLevels[self:GetSpeedLevel()].Multiplier * self.PrintingQualityLevels[self:GetQualityLevel()].Multiplier)
- end
- end
- if self.EnableTemperature then
- self:SetTemperature(self:GetTemperature() + self.HeatingTemperature * self.PrintingSpeedLevels[self:GetSpeedLevel()].Multiplier * self.PrintingQualityLevels[self:GetQualityLevel()].Multiplier / self.CoolingLevels[self:GetCoolingLevel()].HeatingDivider)
- end
- else
- if self.MakePrintingSound then
- if self.Sound then
- if self.Sound:IsPlaying() then
- self.Sound:Stop()
- end
- end
- end
- self.IsSparking = false
- end
- if self:GetPrintingProgress() >= self.PrintingSpeed / self.PrintingSpeedLevels[self:GetSpeedLevel()].Multiplier and self:GetStatus() ~= "Off" then
- self:SetPrintingProgress(0)
- self:SetStatus("Reloading")
- self:Print()
- end
- if self.IsSparking and self.SparkingEffect then
- local Effect = EffectData()
- Effect:SetOrigin(self:GetPos())
- Effect:SetMagnitude(1)
- Effect:SetScale(1)
- Effect:SetRadius(2)
- util.Effect("Sparks", Effect)
- end
- end
- function ENT:OnRemove()
- if self.Sound then self.Sound:Stop() end
- end
- end
- if CLIENT then
- local function NumberRound(Number, Decimal)
- local exp = Decimal and 10 ^ Decimal or 1
- return math.ceil(Number * exp - 0.5) / exp
- end
- local function NumberFormat(Number, Special)
- if type(Number) ~= "number" then
- return 0
- elseif Number >= 1000000 then
- Number = NumberRound(Number / 1000000, 1) .. "m"
- elseif Number >= 1000 and not Special then
- Number = NumberRound(Number / 1000, 1) .. "k"
- elseif Number >= 10000 and Special then
- Number = NumberRound(Number / 1000, 1) .. "k"
- else
- Number = math.floor(Number)
- end
- return Number
- end
- --print(NumberFormat(76561198063654743, true))
- function ENT:Draw()
- self:DrawModel()
- local Player = LocalPlayer()
- local Position = self:GetPos() + (self:GetUp() * 11)
- local Angles = self:GetAngles()
- local Rotation = Vector(0, 90, 0)
- local LeftTopX, LeftTopY = -145, -155
- Angles:RotateAroundAxis(Angles:Right(), Rotation.x)
- Angles:RotateAroundAxis(Angles:Up(), Rotation.y)
- Angles:RotateAroundAxis(Angles:Forward(), Rotation.z)
- local Owner = self:GetOwningEntity()
- Owner = (IsValid(Owner) and Owner:Nick()) or "Unknown"
- local Text = self.PrintName
- if self.EnableBattery then
- local Position2 = self:GetPos() + (self:GetForward() * 17)
- local Angles2 = self:GetAngles()
- local Rotation2 = Vector(0, 90, 90)
- Angles2:RotateAroundAxis(Angles2:Right(), Rotation2.x)
- Angles2:RotateAroundAxis(Angles2:Up(), Rotation2.y)
- Angles2:RotateAroundAxis(Angles2:Forward(), Rotation2.z)
- cam.Start3D2D(Position2, Angles2, 0.1)
- draw.RoundedBox(self.BoxesRadiusCorner, -148, -105, 300, 100, self.BatteryBoxColor or Color(0, 0, 0, 150))
- draw.RoundedBox(0, -121, -78, 176, 46, self.BatteryBgColor or Color(255, 255, 255, 255))
- draw.RoundedBox(0, 55, -62, 5, 15, self.BatteryBgColor or Color(255, 255, 255, 255))
- 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))
- draw.SimpleText(math.floor(self:GetPrinterBattery() / self.MaxBatteryValue * 100) .. "%", "hPrinterBattety", 105, -55, self.BatteryTextColor or Color(255, 255, 255, 255), 1, 1)
- cam.End3D2D()
- end
- cam.Start3D2D(Position, Angles, 0.1)
- local TraceLine = util.TraceLine({start = Player:GetShootPos(), endpos = Player:GetAimVector() * 128 + Player:GetShootPos(), filter = Player})
- local HitPosition = self:WorldToLocal(TraceLine.HitPos)
- if self.ShadowEnabled then
- draw.RoundedBox(self.BoxesRadiusCorner, LeftTopX - 2, LeftTopY - 2, -LeftTopX * 2 + 8, 64, self.ShadowColor)
- end
- draw.RoundedBox(self.BoxesRadiusCorner, LeftTopX, LeftTopY , -LeftTopX * 2 + 4, 60, self.NameOwnerBoxColor or Color(255, 255, 255, 255))
- draw.SimpleText(Text or "", "hPrinterName", 0, LeftTopY + 5, self.NameTextColor or Color(255, 255, 255, 255), 1, 0)
- draw.SimpleText(Owner or "", "hPrinterOwner", 0, LeftTopY + 32, self.OwnerTextColor or Color(255, 255, 255, 255), 1, 0)
- if self.ShadowEnabled then
- draw.RoundedBox(self.BoxesRadiusCorner, LeftTopX - 2, LeftTopY + 218, -LeftTopX * 2 + 8, 74, self.ShadowColor)
- end
- draw.RoundedBox(self.BoxesRadiusCorner, LeftTopX, LeftTopY + 220, -LeftTopX * 2 + 4, 70, self.ButtonsBoxColor or Color(255, 255, 255, 255))
- local BackButtonColor = self.ButtonsColor or Color(255, 255, 255, 255)
- 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
- if Player:KeyDown(IN_USE) and not Player.PrinterKeyPressed then
- net.Start("SyncPrinterButtons76561198063652744")
- net.WriteEntity(self)
- net.WriteUInt(0, 4)
- net.SendToServer()
- Player.PrinterKeyPressed = true
- end
- BackButtonColor = self.ButtonsColorHovered or Color(255, 255, 255, 255)
- end
- draw.RoundedBox(self.BoxesRadiusCorner, LeftTopX + 10, LeftTopY + 230, 70, 50, BackButtonColor)
- surface.SetMaterial(Material("icon16/arrow_left.png"))
- surface.SetDrawColor(Color(255, 255, 255, 255))
- surface.DrawTexturedRect(-117, 85, 32, 32)
- local NextButtonColor = self.ButtonsColor or Color(255, 255, 255, 255)
- if TraceLine.Entity == self and HitPosition.x <= 12.5 and HitPosition.x >= 7.5 and HitPosition.y >= 7 and HitPosition.y <= 14 then
- if Player:KeyDown(IN_USE) and not Player.PrinterKeyPressed then
- net.Start("SyncPrinterButtons76561198063652744")
- net.WriteEntity(self)
- net.WriteUInt(1, 4)
- net.SendToServer()
- Player.PrinterKeyPressed = true
- end
- NextButtonColor = self.ButtonsColorHovered or Color(255, 255, 255, 255)
- end
- draw.RoundedBox(self.BoxesRadiusCorner, LeftTopX + 215, LeftTopY + 230, 70, 50, NextButtonColor)
- surface.SetMaterial(Material("icon16/arrow_right.png"))
- surface.SetDrawColor(Color(255, 255, 255, 255))
- surface.DrawTexturedRect(90, 85, 32, 32)
- if self.ShadowEnabled then
- draw.RoundedBox(self.BoxesRadiusCorner, LeftTopX - 2, LeftTopY + 63, -LeftTopX * 2 + 8, 154, self.ShadowColor)
- end
- draw.RoundedBox(self.BoxesRadiusCorner, LeftTopX, LeftTopY + 65, -LeftTopX * 2 + 4, 150, self.PageBoxColor or Color(255, 255, 255, 255))
- if self:GetCurrentPage() == "General" then
- local TextY, Y = 5, 65
- if self:GetStatus() == "Printing" then
- 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)
- else
- draw.SimpleText("Status: ".. self:GetStatus() , "hPrinterPage", LeftTopX + 10, LeftTopY + Y + TextY, self.PageTextColor or Color(255, 255, 255, 255), 0, 0)
- end
- if self.InPrinterStorage then
- TextY = TextY + 28
- if not self.InfinitePrinterStorage then
- 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)
- else
- draw.SimpleText("Storage: " .. NumberFormat(self:GetMoneyInStorage(), true) .. "$", "hPrinterPage", LeftTopX + 10, LeftTopY + Y + TextY, self.PageTextColor or Color(255, 255, 255, 255), 0, 0)
- end
- end
- if self.EnableTemperature then
- TextY = TextY + 28
- local TempColor = Color(0, 255, 0, 255)
- if self.DeathTemperature - self:GetTemperature() < self.DeathTemperature / 5 then TempColor = Color(255, 255, 0, 255) end
- if self.DeathTemperature - self:GetTemperature() < self.DeathTemperature / 10 then TempColor = Color(255, 0, 0, 255) end
- draw.SimpleText("Temperature: ", "hPrinterPage", LeftTopX + 10, LeftTopY + Y + TextY, self.PageTextColor or Color(255, 255, 255, 255), 0, 0)
- draw.SimpleText(math.floor(self:GetTemperature()) .. self.TemperatureMetricSystem, "hPrinterPage", LeftTopX + 160, LeftTopY + Y + TextY, TempColor, 0, 0)
- end
- if self.InPrinterStorage then
- local WithdrawButtonColor = self.ButtonsColor or Color(255, 255, 255, 255)
- if TraceLine.Entity == self and HitPosition.x <= 5.5 and HitPosition.x >= 0.5 and HitPosition.y >= -13.5 and HitPosition.y <= 0 then
- if Player:KeyDown(IN_USE) and not Player.PrinterKeyPressed then
- if self.MoneySound then if not self.MoneySound:IsPlaying() then self.MoneySound:PlayEx(1, 100) end end
- net.Start("SyncPrinterButtons76561198063652744")
- net.WriteEntity(self)
- net.WriteUInt(2, 4)
- net.SendToServer()
- Player.PrinterKeyPressed = true
- end
- WithdrawButtonColor = self.ButtonsColorHovered or Color(255, 255, 255, 255)
- end
- draw.RoundedBox(self.BoxesRadiusCorner, LeftTopX + 12, LeftTopY + 160, 130, 50, WithdrawButtonColor)
- draw.SimpleText("Withdraw", "hPrinterPage", LeftTopX + 12 + 65, LeftTopY + 160 + 27, self.WithdrawText or Color(255, 255, 255, 255), 1, 1)
- end
- if self.EnableTemperature and not self.CoolingLevels[self:GetCoolingLevel()].AutoCooling then
- local CoolButtonColor = self.ButtonsColor or Color(255, 255, 255, 255)
- if TraceLine.Entity == self and HitPosition.x <= 5.5 and HitPosition.x >= 0.5 and HitPosition.y >= 1 and HitPosition.y <= 13.5 then
- if Player:KeyDown(IN_USE) and not Player.PrinterKeyPressed then
- net.Start("SyncPrinterButtons76561198063652744")
- net.WriteEntity(self)
- net.WriteUInt(3, 4)
- net.SendToServer()
- Player.PrinterKeyPressed = true
- end
- CoolButtonColor = self.ButtonsColorHovered or Color(255, 255, 255, 255)
- end
- draw.RoundedBox(self.BoxesRadiusCorner, LeftTopX + 152, LeftTopY + 160, 130, 50, CoolButtonColor)
- draw.SimpleText("Cool", "hPrinterPage", LeftTopX + 152 + 65, LeftTopY + 160 + 27, self.CoolingText or Color(255, 255, 255, 255), 1, 1)
- end
- end
- if self:GetCurrentPage() == "Upgrades" then
- local Y = 70
- if self.UpgradablePrintingSpeed then
- local Level = self:GetSpeedLevel()
- draw.SimpleText("Speed: ", "hPrinterPage", LeftTopX + 10, LeftTopY + Y, self.PageTextColor or Color(255, 255, 255, 255), 0, 0)
- draw.SimpleText(self.PrintingSpeedLevels[Level].LevelName or "", "hPrinterPage", LeftTopX + 90, LeftTopY + Y, self.PrintingSpeedLevels[Level].NameColor or Color(255, 255, 255, 255), 0, 0)
- if Level < #self.PrintingSpeedLevels then
- local ButtonColor = self.ButtonsColor or Color(255, 255, 255, 255)
- 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
- if Player:KeyDown(IN_USE) and not Player.PrinterKeyPressed then
- net.Start("SyncPrinterButtons76561198063652744")
- net.WriteEntity(self)
- net.WriteUInt(4, 4)
- net.SendToServer()
- Player.PrinterKeyPressed = true
- end
- ButtonColor = self.ButtonsColorHovered or Color(255, 255, 255, 255)
- end
- draw.RoundedBox(self.BoxesRadiusCorner, LeftTopX + 205, LeftTopY + Y - 3, 85, 35, ButtonColor)
- 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)
- surface.SetMaterial(Material("icon16/add.png"))
- surface.SetDrawColor(Color(255, 255, 255, 255))
- surface.DrawTexturedRect(LeftTopX + 207, LeftTopY + Y + 6, 16, 16)
- end
- end
- if self.UpgradablePrinterStorage and not self.InfinitePrinterStorage then
- local Level = self:GetStorageLevel()
- Y = Y + 37
- draw.SimpleText("Storage: ", "hPrinterPage", LeftTopX + 10, LeftTopY + Y, self.PageTextColor or Color(255, 255, 255, 255), 0, 0)
- draw.SimpleText(self.PrinterStorageLevels[Level].LevelName or "", "hPrinterPage", LeftTopX + 107, LeftTopY + Y, self.PrinterStorageLevels[Level].NameColor or Color(255, 255, 255, 255), 0, 0)
- if Level < #self.PrinterStorageLevels then
- local ButtonColor = self.ButtonsColor or Color(255, 255, 255, 255)
- 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
- if Player:KeyDown(IN_USE) and not Player.PrinterKeyPressed then
- net.Start("SyncPrinterButtons76561198063652744")
- net.WriteEntity(self)
- net.WriteUInt(5, 4)
- net.SendToServer()
- Player.PrinterKeyPressed = true
- end
- ButtonColor = self.ButtonsColorHovered or Color(255, 255, 255, 255)
- end
- draw.RoundedBox(self.BoxesRadiusCorner, LeftTopX + 205, LeftTopY + Y - 3, 85, 35, ButtonColor)
- 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)
- surface.SetMaterial(Material("icon16/add.png"))
- surface.SetDrawColor(Color(255, 255, 255, 255))
- surface.DrawTexturedRect(LeftTopX + 207, LeftTopY + Y + 6, 16, 16)
- end
- end
- if self.UpgradablePrintingQuality then
- local Level = self:GetQualityLevel()
- Y = Y + 37
- draw.SimpleText("Quality: ", "hPrinterPage", LeftTopX + 10, LeftTopY + Y, self.PageTextColor or Color(255, 255, 255, 255), 0, 0)
- draw.SimpleText(self.PrintingQualityLevels[Level].LevelName or "", "hPrinterPage", LeftTopX + 97, LeftTopY + Y, self.PrintingQualityLevels[Level].NameColor or Color(255, 255, 255, 255), 0, 0)
- if Level < #self.PrintingQualityLevels then
- local ButtonColor = self.ButtonsColor or Color(255, 255, 255, 255)
- 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
- if Player:KeyDown(IN_USE) and not Player.PrinterKeyPressed then
- net.Start("SyncPrinterButtons76561198063652744")
- net.WriteEntity(self)
- net.WriteUInt(6, 4)
- net.SendToServer()
- Player.PrinterKeyPressed = true
- end
- ButtonColor = self.ButtonsColorHovered or Color(255, 255, 255, 255)
- end
- draw.RoundedBox(self.BoxesRadiusCorner, LeftTopX + 205, LeftTopY + Y - 3, 85, 35, ButtonColor)
- 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)
- surface.SetMaterial(Material("icon16/add.png"))
- surface.SetDrawColor(Color(255, 255, 255, 255))
- surface.DrawTexturedRect(LeftTopX + 207, LeftTopY + Y + 6, 16, 16)
- end
- end
- if self.UpgradableCooling then
- local Level = self:GetCoolingLevel()
- Y = Y + 37
- draw.SimpleText("Cooling: ", "hPrinterPage", LeftTopX + 10, LeftTopY + Y, self.PageTextColor or Color(255, 255, 255, 255), 0, 0)
- draw.SimpleText(self.CoolingLevels[Level].LevelName or "", "hPrinterPage", LeftTopX + 100, LeftTopY + Y, self.CoolingLevels[Level].NameColor or Color(255, 255, 255, 255), 0, 0)
- if Level < #self.CoolingLevels then
- local ButtonColor = self.ButtonsColor or Color(255, 255, 255, 255)
- 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
- if Player:KeyDown(IN_USE) and not Player.PrinterKeyPressed then
- net.Start("SyncPrinterButtons76561198063652744")
- net.WriteEntity(self)
- net.WriteUInt(7, 4)
- net.SendToServer()
- Player.PrinterKeyPressed = true
- end
- ButtonColor = self.ButtonsColorHovered or Color(255, 255, 255, 255)
- end
- draw.RoundedBox(self.BoxesRadiusCorner, LeftTopX + 205, LeftTopY + Y - 3, 85, 35, ButtonColor)
- 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)
- surface.SetMaterial(Material("icon16/add.png"))
- surface.SetDrawColor(Color(255, 255, 255, 255))
- surface.DrawTexturedRect(LeftTopX + 207, LeftTopY + Y + 6, 16, 16)
- end
- end
- end
- if self:GetCurrentPage() == "Statistics" then
- local Y = 70
- if self:GetStatus() ~= "Off" then
- 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)
- else
- draw.SimpleText("Printing rate: 0$/sec", "hPrinterPage", LeftTopX + 10, LeftTopY + Y, self.PageTextColor or Color(255, 255, 255, 255), 0, 0)
- end
- if self.EnableBattery then
- Y = Y + 37
- local BatteryLifetime = math.floor(self:GetPrinterBattery() / (self.WastingAmountOnPrinting * self.PrintingSpeedLevels[self:GetSpeedLevel()].Multiplier * self.PrintingQualityLevels[self:GetQualityLevel()].Multiplier) / 5)
- if BatteryLifetime > 60 then
- draw.SimpleText("Battery lifetime: ~ " .. NumberFormat(BatteryLifetime / 60) .. " min", "hPrinterPage", LeftTopX + 10, LeftTopY + Y, self.PageTextColor or Color(255, 255, 255, 255), 0, 0)
- elseif BatteryLifetime > 0 then
- draw.SimpleText("Battery lifetime: ~ " .. BatteryLifetime .. " sec", "hPrinterPage", LeftTopX + 10, LeftTopY + Y, self.PageTextColor or Color(255, 255, 255, 255), 0, 0)
- else
- draw.SimpleText("Battery lifetime: dead", "hPrinterPage", LeftTopX + 10, LeftTopY + Y, self.PageTextColor or Color(255, 255, 255, 255), 0, 0)
- end
- end
- if self.TurnOnOffEnabled then
- local ButtonColor1 = self.ButtonsColor or Color(255, 255, 255, 255)
- local ButtonColor2 = self.ButtonsColor or Color(255, 255, 255, 255)
- if TraceLine.Entity == self and HitPosition.x <= 5.5 and HitPosition.x >= 0.5 and HitPosition.y >= -13.5 and HitPosition.y <= 0 then
- if Player:KeyDown(IN_USE) and not Player.PrinterKeyPressed then
- net.Start("SyncPrinterButtons76561198063652744")
- net.WriteEntity(self)
- net.WriteUInt(8, 4)
- net.SendToServer()
- Player.PrinterKeyPressed = true
- end
- ButtonColor1 = self.ButtonsColorHovered or Color(255, 255, 255, 255)
- end
- draw.RoundedBox(self.BoxesRadiusCorner, LeftTopX + 12, LeftTopY + 160, 130, 50, ButtonColor1)
- draw.SimpleText("Turn off", "hOnOffText", LeftTopX + 12 + 65, LeftTopY + 160 + 27, self.TurnOffText or Color(255, 255, 255, 255), 1, 1)
- if TraceLine.Entity == self and HitPosition.x <= 5.5 and HitPosition.x >= 0.5 and HitPosition.y >= 1 and HitPosition.y <= 13.5 then
- if Player:KeyDown(IN_USE) and not Player.PrinterKeyPressed then
- net.Start("SyncPrinterButtons76561198063652744")
- net.WriteEntity(self)
- net.WriteUInt(9, 4)
- net.SendToServer()
- Player.PrinterKeyPressed = true
- end
- ButtonColor2 = self.ButtonsColorHovered or Color(255, 255, 255, 255)
- end
- draw.RoundedBox(self.BoxesRadiusCorner, LeftTopX + 152, LeftTopY + 160, 130, 50, ButtonColor2)
- draw.SimpleText("Turn on", "hOnOffText", LeftTopX + 152 + 65, LeftTopY + 160 + 27, self.TurnOnText or Color(255, 255, 255, 255), 1, 1)
- end
- end
- local CurrPage = self:GetCurrentPage()
- if CurrPage == "Statistics" and self.TurnOnOffEnabled then CurrPage = "Control" end
- draw.SimpleText(CurrPage, "hPrinterPage", 0, LeftTopY + 240, self.CurPageTextColor or Color(255, 255, 255, 255), 1, 0)
- cam.End3D2D()
- end
- hook.Add("Tick", "PrinterKeyPressed76561198063654970",
- function()
- local Player = LocalPlayer()
- if Player then
- if IsValid(Player) then
- if not Player:KeyPressed(IN_USE) and not Player:KeyDownLast(IN_USE) then
- Player.PrinterKeyPressed = false
- end
- end
- end
- end
- )
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement