Hi there, so I have Tomas printers, and im not sure how to add them to VIP/Owner/otherusergroups with the code itself, do i have to create another darkrp custom entity?
include("shared.lua")
function ENT:Initialize()
self.Battery = 100
self.Heat = 10
self.Speed = 1
self.PrintedMoney = 0
self.Cooling = 100
self.PrintRate = 50
self.Name = "Money Printer"
self.StarMaterial = Material( "icon16/star.png", "noclamp")
end
function ENT:Draw()
self:DrawModel()
if self:GetPos():Distance(LocalPlayer():GetPos()) < 500 then -- How far people can see printer UI
local Pos = self:GetPos()
local Ang = self:GetAngles()
Ang:RotateAroundAxis(Ang:Up(), 90)
cam.Start3D2D(Pos + Ang:Up() * 10.8 + Ang:Forward() * -15 + Ang:Right() * -16.1, Ang, 0.11)
draw.RoundedBox( 0, 0, 0, 275, 275, Color(20,20,20,255) )
draw.RoundedBox( 0, 10, 59, 255, 60, Color(40,40,40,255) )
draw.RoundedBox( 0, 10, 127, 120, 90, Color(40,40,40,255) )
draw.RoundedBox( 0, 139, 127, 126, 90, Color(40,40,40,255) )
draw.RoundedBox( 0, 0, 0, 275, 50, Color(255, 0, 0, 255) )
surface.DrawOutlinedRect( 0, 0, 275, 275 )
surface.DrawOutlinedRect( 1, 1, 273, 273 )
draw.TexturedQuad
{
texture = surface.GetTextureID "gui/gradient_up",
color = Color(200, 0, 0, 255),
x = 0,
y = 0,
w = 275,
h = 50
}
surface.SetDrawColor(Color(255, 0, 0, 255))
draw.RoundedBox( 0, 0, 225, 275, 50, Color(255, 0, 0, 255) )
draw.TexturedQuad
{
texture = surface.GetTextureID "gui/gradient_up",
color = Color(200, 0, 0, 255),
x = 0,
y = 225,
w = 275,
h = 50
}
draw.DrawText( self.Name, "HUDNumber5", 137.5, 10, Color(255,255,255,255), TEXT_ALIGN_CENTER )
draw.DrawText( self:Getowning_ent():Name() or "Unknown", "HUDNumber5", 137.5, 235, Color(255,255,255,255), TEXT_ALIGN_CENTER )
draw.DrawText( "Speed:", "HUDNumber5", 25, 60, Color(255,255,255,255), TEXT_ALIGN_LEFT )
for i=0,8 do
if self.Speed > i then
surface.SetMaterial( self.StarMaterial )
surface.SetDrawColor( Color(255, 255, 255, 255) )
surface.DrawTexturedRect( 25+20*i, 95, 16, 16 )
else
surface.SetMaterial( self.StarMaterial )
surface.SetDrawColor( Color(20, 20, 20, 255) )
surface.DrawTexturedRect( 25+20*i, 95, 16, 16 )
end
end
draw.RoundedBox( 0, 210, 80, 46, 30, Color(0,150,0,255) )
draw.RoundedBox( 0, 212, 82, 42, 26, Color(0,0,0,150) )
draw.DrawText( "Buy", "Trebuchet24", 218, 83, Color(255,255,255,255), TEXT_ALIGN_LEFT )
draw.RoundedBox( 0, 17, 160, 100, 50, Color(200,200,200,255) )
draw.RoundedBox( 0, 21, 164, 92, 42, Color(60,60,60,255) )
local Col2 = Color(0,140,0,255)
local Col3 = Color(0,180,0,255)
if self.Battery > 0 and self.Battery < 25 then
Col2 = Color(140,0,0,255)
Col3 = Color(180,0,0,255)
elseif self.Battery > 25 and self.Battery < 50 then
Col2 = Color(180,180,0,255)
Col3 = Color(240,240,0,255)
elseif self.Battery > 50 then
Col2 = Color(0,180,0,255)
Col3 = Color(0,220,0,255)
end
surface.SetDrawColor(Col3)
surface.DrawRect(21, 164, 0.92*self.Battery, 42)
draw.TexturedQuad
{
texture = surface.GetTextureID "gui/gradient_up",
color = Col2,
x = 21,
y = 164,
w = 0.92*self.Battery,
h = 42
}
draw.RoundedBox( 0, 117, 173, 5, 25, Color(200,200,200,255) )
draw.RoundedBox( 0, 40, 160, 4, 50, Color(200,200,200,255) )
draw.RoundedBox( 0, 65, 160, 4, 50, Color(200,200,200,255) )
draw.RoundedBox( 0, 90, 160, 4, 50, Color(200,200,200,255) )
draw.RoundedBox( 0, 10, 127, 120, 27, Color(0,0,0,120) )
draw.DrawText( "Battery: "..self.Battery.."%", "HudHintTextLarge",70, 132, Color(255,255,255,255), TEXT_ALIGN_CENTER )
draw.RoundedBox( 0, 139, 167, 126, 50, Color(255, 0, 0, 255) )
draw.RoundedBox( 0, 142, 170, 120, 44, Color(0,0,0,150) )
draw.RoundedBox( 0, 139, 127, 126, 27, Color(0,0,0,120) )
draw.DrawText( "Rate: "..self.PrintRate .."$/min.", "HudHintTextLarge",200, 132, Color(255,255,255,255), TEXT_ALIGN_CENTER )
draw.DrawText( "$"..self.PrintedMoney, "HUDNumber5", 155, 176, Color(255,255,255,255), TEXT_ALIGN_LEFT )
cam.End3D2D()
Ang:RotateAroundAxis(Ang:Forward(), 90)
cam.Start3D2D(Pos + Ang:Up() * 16.4 + Ang:Forward() * -15 + Ang:Right() * -10.2, Ang, 0.11)
draw.RoundedBox( 0, 0, 0, 275, 90, Color(40,40,40,255) )
surface.SetDrawColor(Color(255, 0, 0, 255))
surface.DrawOutlinedRect( 5, 0, 200, 86)
surface.DrawOutlinedRect( 6, 1, 198, 84)
draw.RoundedBox( 0, 0, 0, 275, 35, Color(0,0,0,150) )
draw.RoundedBox( 0, 11, 41, 188, 40, Color(0,123,255,255) )
draw.RoundedBox( 0, 16, 46, 175, 30, Color(40,40,40,255) )
draw.TexturedQuad
{
texture = surface.GetTextureID "models/shadertest/shader3",
color = Color(255,255,255,255),
x = 16,
y = 46,
w = 1.78*self.Cooling,
h = 30
}
draw.DrawText( "Cooling gel: "..self.Cooling.."%", "Trebuchet24",100, 5, Color(255,255,255,255), TEXT_ALIGN_CENTER )
cam.End3D2D()
cam.Start3D2D(Pos + Ang:Up() * 16.9 + Ang:Forward() * 7.9 + Ang:Right() * -10.2, Ang, 0.11)
draw.RoundedBox( 0, 0, 0, 70, 90, Color(40,40,40,255) )
draw.RoundedBox( 0, 0, 0, 70, 25, Color(0,0,0,150) )
surface.SetDrawColor(Color(255, 0, 0, 255))
surface.DrawOutlinedRect( 0, 0, 70, 90)
surface.DrawOutlinedRect( 1, 1, 68, 88)
draw.RoundedBox( 0, 5, 30, 15, 53, Color(200,200,200,255) )
local Col = Color(0,0,255,255)
if self.Heat > 0 and self.Heat < 30 then
Col = Color(0,0,255,255)
elseif self.Heat > 30 and self.Heat < 60 then
Col = Color(255,255,0,255)
elseif self.Heat > 60 then
Col = Color(255,0,0,255)
end
draw.RoundedBox( 0, 6, 82, 13, -0.51*self.Heat, Col)
draw.DrawText( "Heat", "HudHintTextLarge", 35,5, Color(255,255,255,255), TEXT_ALIGN_CENTER )
draw.DrawText( "Very Hot", "Default", 22,30, Color(255,255,255,255), TEXT_ALIGN_LEFT )
draw.DrawText( "Hot", "Default", 22,50, Color(255,255,255,255), TEXT_ALIGN_LEFT )
draw.DrawText( "Cool", "Default", 22,70, Color(255,255,255,255), TEXT_ALIGN_LEFT )
cam.End3D2D()
end
end
net.Receive("UpdatePrinter",function()
local Tabl = net.ReadTable()
local Entity = net.ReadEntity()
Entity.Battery = Tabl.Battery
Entity.Heat = Tabl.Heat
Entity.Speed = Tabl.Speed
Entity.PrintedMoney = Tabl.PrintedMoney
Entity.Cooling = Tabl.Cooling
Entity.PrintRate = Tabl.PrintRate
Entity.Name = Tabl.Name
end)
include("shared.lua")
AddCSLuaFile("shared.lua")
AddCSLuaFile("cl_init.lua")
util.AddNetworkString( "UpdatePrinter" )
local function UpdatePrinter(ent)
local Tabl = {}
Tabl.Battery = ent.Battery
Tabl.Heat = ent.Heat
Tabl.Speed = ent.Speed
Tabl.PrintedMoney = ent.PrintedMoney
Tabl.Cooling = ent.Cooling
Tabl.PrintRate = ent.Speed*TPRINTERS_CONFIG.Money_Red
Tabl.Name = TPRINTERS_CONFIG.Name_Red
net.Start("UpdatePrinter")
net.WriteTable(Tabl)
net.WriteEntity(ent)
net.Broadcast()
end
local function MinTimer(ent)
if not ent:IsValid() then return end
if ent.Battery > 0 then
ent.PrintedMoney = ent.PrintedMoney + ent.Speed * TPRINTERS_CONFIG.Money_Red
ent.Battery = ent.Battery - TPRINTERS_CONFIG.Battery_Red
if ent.Battery < 0 then ent.Battery = 0 end
ent.Cooling = ent.Cooling - TPRINTERS_CONFIG.Cooling_Red
if ent.Cooling < 0 then ent.Cooling = 0 end
if ent.Cooling > 0 then
ent.Heat = ent.Heat - 5
else
ent.Heat = ent.Heat + TPRINTERS_CONFIG.Heat_Red
end
if ent.Heat > 100 then ent.Heat = 100 end
if ent.Heat < 10 then ent.Heat = 10 end
else
ent.Heat = ent.Heat - 20
if ent.Heat < 0 then ent.Heat = 0 end
end
if ent.Heat >= 100 then
ent:Destruct()
ent:Remove()
end
UpdatePrinter(ent)
timer.Simple(TPRINTERS_CONFIG.PrintRate_Red, function() MinTimer(ent) end)
end
function ENT:Destruct()
local vPoint = self:GetPos()
local effectdata = EffectData()
effectdata:SetStart(vPoint)
effectdata:SetOrigin(vPoint)
effectdata:SetScale(1)
util.Effect("Explosion", effectdata)
DarkRP.notify(self:Getowning_ent(), 1, 4, DarkRP.getPhrase("money_printer_exploded"))
end
function ENT:OnTakeDamage(dmg)
if self.burningup then return end
self.damage = (self.damage or 100) - dmg:GetDamage()
if self.damage <= 0 then
self:Destruct()
self:Remove()
end
end
function ENT:Initialize()
self:SetModel("models/props_c17/consolebox01a.mdl")
self:PhysicsInit(SOLID_VPHYSICS)
self:SetMoveType(MOVETYPE_VPHYSICS)
self:SetSolid(SOLID_VPHYSICS)
local phys = self:GetPhysicsObject()
phys:Wake()
self:SetUseType( SIMPLE_USE )
self.Battery = 100
self.Heat = 10
self.Speed = 1
self.PrintedMoney = 0
self.Cooling = 100
timer.Simple(1,function() if self:IsValid() then UpdatePrinter(self) end end)
timer.Simple(TPRINTERS_CONFIG.PrintRate_Red, function() MinTimer(self) end)
self.sound = CreateSound(self, Sound("ambient/levels/labs/equipment_printer_loop1.wav"))
self.sound:SetSoundLevel(52)
self.sound:PlayEx(1, 100)
end
local function WorldToScreen(vWorldPos,vPos,vScale,aRot)
local vWorldPos=vWorldPos-vPos
vWorldPos:Rotate(Angle(0,-aRot.y,0))
vWorldPos:Rotate(Angle(-aRot.p,0,0))
vWorldPos:Rotate(Angle(0,0,-aRot.r))
return vWorldPos.x/vScale,(-vWorldPos.y)/vScale
end
local function inrange(x, y, x2, y2, x3, y3)
if x > x3 then return false end
if y < y3 then return false end
if x2 < x3 then return false end
if y2 > y3 then return false end
return true
end
function ENT:OnRemove()
if self.sound then
self.sound:Stop()
end
end
function ENT:Use(ply)
if(ply:IsPlayer())then
local lookAtX,lookAtY = WorldToScreen(ply:GetEyeTrace().HitPos or Vector(0,0,0),self:GetPos()+self:GetAngles():Up()*1.55, 0.2375, self:GetAngles())
if inrange(-31, -34, -17, -55, lookAtX, lookAtY) and ply:getDarkRPVar("money") >= TPRINTERS_CONFIG.UpgradePrice_Red and self.Speed < 9 then
sound.Play( "buttons/button15.wav", self:GetPos(), 100, 100, 1 )
ply:addMoney( -TPRINTERS_CONFIG.UpgradePrice_Red )
self.Speed = self.Speed + 1
DarkRP.notify( ply, 1, 5, "Printer speed has been upgraded!" )
UpdatePrinter(self)
elseif self.PrintedMoney > 0 then
ply:addMoney( self.PrintedMoney )
DarkRP.notify( ply, 0, 5, "You picked up $"..self.PrintedMoney )
self.PrintedMoney = 0
UpdatePrinter(self)
end
end
end
function ENT:UpdatePrintera()
UpdatePrinter(self)
end
function ENT:Think()
if not self:Getowning_ent():IsValid() then
self:Remove()
end
end
ENT.Type = "anim"
ENT.Base = "base_gmodentity"
ENT.PrintName = "Money Printer"
ENT.Author = "Tomas"
ENT.Spawnable = false
ENT.AdminSpawnable = false
function ENT:SetupDataTables()
self:NetworkVar("Entity", 0, "owning_ent")
end