Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- AddCSLuaFile("cl_init.lua")
- AddCSLuaFile("shared.lua")
- include("shared.lua")
- util.AddNetworkString("blackpearls:HardWare:PrinterMenu")
- function ENT:Initialize()
- self:SetModel(self.Model)
- self:PhysicsInit(SOLID_VPHYSICS)
- self:SetMoveType(MOVETYPE_VPHYSICS)
- self:SetSolid(SOLID_VPHYSICS)
- self:SetUseType(SIMPLE_USE)
- local phys = self:GetPhysicsObject()
- if (IsValid(phys)) then
- phys:Wake()
- end
- self:SetMoney(0)
- self:SetStorage(1000)
- self:SetTemp(25)
- self:SetPrinterBattery(100)
- self:SetCooling(100)
- self:SetMoneyRate(15)
- self:SetCoolingRate(1)
- self:SetTempRate(1)
- self:SetPrintTime(CurTime() + 2)
- self:SetPrinterHealth(100)
- end
- function ENT:AcceptInput( _event, _a, _p )
- if (_event == "Use" && _p:IsPlayer()) then
- if not IsValid(_p) then return end
- net.Start("blackpearls:HardWare:PrinterMenu")
- net.WriteEntity(self)
- net.Send(_p)
- end
- end
- function ENT:PrintMoney()
- if IsValid(self) then
- self:SetMoney(math.Clamp(self:GetMoney() + self:GetMoneyRate(), 0, self:GetStorage() ))
- end
- end
- function ENT:PrintTemp()
- if IsValid(self) then
- local temp = self:GetTemp() + self:GetTempRate()
- self:SetTemp(math.Clamp(temp, 0, 50 ))
- if self:GetTemp() >= 50 then
- self:Explode()
- end
- end
- end
- function ENT:PrintCooling()
- if IsValid(self) and self:GetCooling() >= 1 then
- local temp = self:GetCoolingRate() * 1.2
- self:SetTemp(math.Clamp(self:GetTemp() - temp, 0, 50 ))
- local cooling = self:GetCooling() - self:GetCoolingRate()
- self:SetCooling(math.Clamp(cooling, 0, 50 ))
- end
- end
- function ENT:PrintBattery()
- if IsValid(self) then
- local battery = self:GetPrinterBattery() - 1
- self:SetPrinterBattery(math.Clamp(battery, 0, 100 ))
- end
- end
- function ENT:Think()
- self:PrintMoney()
- self:PrintTemp()
- self:PrintBattery()
- self:PrintCooling()
- if self:WaterLevel() > 1 then
- self:Explode()
- end
- self:NextThink( CurTime() + 2 )
- return true
- end
- function ENT:Explode()
- local vPoint = self:GetPos()
- local effectdata = EffectData()
- effectdata:SetOrigin( vPoint )
- util.Effect( "Explosion", effectdata )
- for k, v in pairs( player.GetAll() ) do
- if v:GetPos():Distance(self:GetPos()) < 110 then
- v:TakeDamage( 100, self, nil )
- end
- end
- self:Remove()
- end
- util.AddNetworkString( "BP:HardWarePrinter:FunctionGlobal" )
- net.Receive( "BP:HardWarePrinter:FunctionGlobal", function(len, caller)
- if not IsValid(caller) and not caller:IsPlayer() then return end
- local printer, func = net.ReadEntity(), net.ReadString()
- if not IsValid(printer) or printer:GetClass() != "hardware_printer" then return end
- if func == "Money" then
- if printer:GetMoney() <= 0 or printer:CPPIGetOwner() != caller then return end
- caller:addMoney(printer:GetMoney())
- DarkRP.notify(caller, 0, 4, "Tu à recupéré "..string.Comma(printer:GetMoney()).." € dans ton imprimante.")
- printer:SetMoney(0)
- elseif func == "Name" then
- if printer:CPPIGetOwner() == NULL or printer:CPPIGetOwner() == nil then
- printer:CPPISetOwner(caller)
- DarkRP.notify(caller, 0, 4, "Tu viens d'acheter une nouvelle imprimante.")
- else
- DarkRP.notify(caller, 1, 4, "Le printer est déjà acheté !")
- end
- elseif func == "CPU" then
- if printer:CPPIGetOwner() != caller then return end
- local cpunumber = net.ReadInt(32)
- local cpu = hardWare_printer_CPU[cpunumber]
- if printer:GetCPUName() == cpu.name then
- DarkRP.notify(caller, 1, 4, "Tu à déjà ce cpu : "..cpu.name..".")
- return
- elseif printer:GetCPUID() == cpunumber then
- DarkRP.notify(caller, 1, 4, "Tu ne peut pas retrograder ton imprimante.")
- return
- end
- printer:SetCPUID(cpunumber)
- printer:SetMoneyRate(cpu.moneyrate)
- printer:SetCoolingRate(cpu.coolingrate)
- printer:SetTempRate(cpu.temprate)
- printer:SetBatteryRate(cpu.batteryrate)
- caller:addMoney(-cpu.price)
- DarkRP.notify(caller, 0, 4, "Tu viens d'acheter un cpu à "..string.Comma(cpu.price).."€, "..cpu.name..".")
- elseif func == "SSD" then
- if printer:CPPIGetOwner() != caller then return end
- local ssdumber = net.ReadInt(32)
- local ssd = hardWare_printer_SSD[ssdumber]
- if printer:GetSSDName() == ssd.name then
- DarkRP.notify(caller, 1, 4, "Tu à déjà ce ssd : "..ssd.name..".")
- return
- elseif printer:GetSSDID() < ssdumber then
- DarkRP.notify(caller, 1, 4, "Tu ne peut pas retrograder ton imprimante.")
- return
- end
- printer:SetStorage(ssd.storage)
- printer:SetSSDID(ssdumber)
- caller:addMoney(-ssd.price)
- DarkRP.notify(caller, 0, 4, "Tu viens d'acheter un ssd à "..string.Comma(ssd.price).."€, "..ssd.name..".")
- end
- end)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement