Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- AddCSLuaFile()
- ENT.Type = "anim"
- ENT.PrintName = "Private Reserve"
- ENT.Instructions = "Use the machine only if you're worthy"
- ENT.Author = "Azbr"
- ENT.Purpose = "Provide Reserve only to those who deserve it."
- ENT.Spawnable = true
- ENT.Category = "Azbr's Gizmos"
- ENT.Menuopensound = (Sound("ambient/levels/labs/coinslot1.wav"))
- local Menuchoicesound = (Sound("buttons/button1.wav"))
- local DrinkSelections = {"reservecanhp1", "reservecanhp2", "reservecanar1", "reservecanar2", "reservecanmix", "reservecanmix2"}
- local DrinkSelectionTitles = {"Classic Reserve", "Diet Reserve", "Cherry Reserve", "Diet Cherry Reserve", "Reserve Twist!", "Diet Reserve Twist!"}
- local drink
- local classname = "reservemachine"
- sound.Add({
- name = "Azbr_Machine_ProductFalling",
- channel = CHAN_STATIC,
- volume = 0.75,
- level = 75,
- pitch = {90,110},
- sound = {"azbr/azbr_reservemachine/productfall.wav"}
- })
- sound.Add({
- name = "Azbr_Machine_Reserve_Playthisonremove",
- channel = CHAN_AUTO,
- volume = 1,
- level = 80,
- pitch = {90,110},
- sound = {"vo/citadel/br_ohshit.wav", "vo/citadel/br_no.wav", "vo/citadel/br_failing11.wav",
- "vo/citadel/br_youneedme.wav","vo/citadel/br_youfool.wav","vo/citadel/br_mock09.wav",}
- })
- sound.Add({
- name = "Azbr_Machine_Reserve_Playthisonspawn",
- channel = CHAN_AUTO,
- volume = 1,
- level = 80,
- pitch = {90,110},
- sound = {"vo/citadel/br_mock05.wav", "vo/citadel/br_laugh01.wav", "vo/k_lab/br_tele_02.wav",
- "vo/k_lab/br_tele_03.wav","vo/breencast/br_tofreeman06.wav",}
- })
- if SERVER then
- function ENT:Initialize()
- self:SetModel("models/props_interiors/VendingMachineSoda01a.mdl")
- self:PhysicsInit(SOLID_VPHYSICS)
- self:SetMoveType(MOVETYPE_VPHYSICS)
- self:SetSolid(SOLID_VPHYSICS)
- self:SetUseType(3)
- self:GetPhysicsObject():SetMass(1600)
- local phys = self:GetPhysicsObject()
- if(phys:IsValid()) then
- phys:Wake()
- local glow = ents.Create("light_dynamic")
- glow:Spawn()
- glow:Activate()
- glow:SetPos(self:LocalToWorld(Vector(60, 0, 16))) -- FRONT, RIGHT/LEFT, UP/DOWN (Facing the vending machine)
- glow:SetKeyValue("distance", 110)
- glow:SetKeyValue("brightness", 7)
- glow:SetKeyValue("_light", "75 140 143 255")
- glow:Fire("TurnOn")
- glow:SetParent(self, 1)
- self.ambientsound = CreateSound(self, "ambient/machines/air_conditioner_loop_1.wav")
- self.ambientsound:Play()
- self.ambientsound:ChangeVolume(.25,0)
- end
- end
- util.AddNetworkString("Reservemenu")
- util.AddNetworkString("Reservechoice")
- function ENT:SpawnFunction(ply,tr)
- if (!tr.Hit) then return end
- local SpLoc = tr.HitPos + tr.HitNormal * 5
- local playerlook = ply:EyeAngles():ToTable()
- local ent = ents.Create(classname)
- ent:SetPos(SpLoc)
- ent:SetAngles(Angle(0,playerlook[2] +180,0))
- ent:Spawn()
- ent:Activate()
- local effectData = EffectData()
- effectData:SetOrigin(ent:GetPos() + (Vector(0,0,5)))
- effectData:SetMagnitude(0.05)
- effectData:SetScale(0.05)
- util.Effect("Explosion", effectData)
- util.ScreenShake(ent:GetPos(), 15, 5, 1.75, 250)
- ent:EmitSound("Azbr_Machine_Reserve_Playthisonspawn")
- return ent
- end
- function ENT:Use(acti,call) -- When Entity is Used, open the GUI for the client.
- if call:IsPlayer() then
- if (!timer.Exists("ReserveProductSpawning")) then
- net.Start("Reservemenu")
- net.WriteEntity(self)
- net.Send(call)
- self:EmitSound(self.Menuopensound, 80, 100, .75, CHAN_AUTO)
- end
- end
- end
- local existingcans = {}
- net.Receive("Reservechoice" , function(len,ply)
- if (IsValid(ply) and ply:IsPlayer()) then
- local TM = (net.ReadEntity())
- local choice = (net.ReadString())
- drink = ents.Create(choice)
- drink:SetPos(TM:LocalToWorld(Vector(18,-3.5,-26)))
- drink:SetAngles(TM:LocalToWorldAngles(Angle(0,0,90)))
- drink:SetCollisionGroup(COLLISION_GROUP_WEAPON)
- if TM:IsValid() then
- if (!timer.Exists("ReserveProductSpawning")) then
- timer.Create("ReserveProductSpawning", 0.8, 1, function()
- drink:Spawn()
- drink:GetPhysicsObject():ApplyForceCenter(TM:GetForward())
- end)
- TM:EmitSound(Menuchoicesound, 80, 100, .75, CHAN_AUTO)
- timer.Simple(.35, function()
- TM:EmitSound("ProductFalling") -- SFX of item tumbling out of machine.
- end)
- end
- table.insert(existingcans, drink)
- end
- end
- end)
- function ENT:OnRemove() -- This will remove any cans spawned by *ANY* reserve machine when you delete one.
- for k , v in pairs(existingcans) do -- This is to assist with spam and lag reduction.
- if IsValid(drink) && IsValid(self) then v:Remove() -- I would make it to where it only deletes cans spawned by the partiuclar machine if I knew how: sorry.
- end -- Comment out the entire function if you wish to turn this off.
- end
- table.Empty(existingcans)
- self:EmitSound("Azbr_Machine_Reserve_Playthisonremove")
- self:StopSound("Azbr_Machine_Reserve_Playthisonspawn")
- if self.ambientsound then self.ambientsound:Stop() end
- end
- end -- End of Server Functions.
- if CLIENT then
- local ButtonColorTable = {Color(30,145,210),Color(30,120,170),Color(165,30,60),Color(135,30,60), Color(255,0,190), Color(255,45,225)}
- local ButtonMessageTable = {}
- surface.CreateFont("ReserveFont", {
- font = "Agency FB",
- extended = false,
- size = 27,
- weight = 610,
- blursize = 0,
- scanlines = 0,
- antialias = true,
- underline = false,
- italic = false,
- strikeout = false,
- symbol = false,
- rotary = false,
- shadow = false,
- additive = false,
- outline = false
- } )
- local textcolor = Color(0,0,0)
- net.Receive("Reservemenu", function(len)
- local ThisMachine = net.ReadEntity()
- if(!frame) then
- local frame = vgui.Create("DFrame")
- frame:SetTitle("Make your selection.")
- frame:SetSize(300,600)
- frame:Center()
- frame:SetVisible(true)
- frame:MakePopup()
- frame:SetBackgroundBlur(true)
- frame:SetDeleteOnClose(true)
- frame.Paint = function(self,w,h)
- draw.RoundedBox(8, 0, 0, w, h, Color(120,120,255,200))
- end
- local function CreateButton(text,color,iter)
- local button = vgui.Create("DButton", frame)
- button:SetFont("ReserveFont")
- button:SetText(text)
- button:SetSize(200, 88)
- button:SetContentAlignment(5)
- button:Dock(TOP)
- button:DockMargin(3,0,3,6)
- button.Paint = function(self,w,h)
- if (!button:IsHovered()) then
- draw.RoundedBox(8,0,0,w,h,ButtonColorTable[iter])
- button:SetTextColor(Color(55,55,55)) else
- draw.RoundedBox(8,0,0,w,h,Color(25,165,25))
- button:SetTextColor(Color(175,175,175))
- end
- if button:IsDown() then draw.RoundedBox(5,0,0,w,h,Color(200,200,200))
- end
- end -- Of button.Paint
- function button:DoClick()
- net.Start("Reservechoice")
- net.WriteEntity(ThisMachine)
- net.WriteString(DrinkSelections[iter])
- net.SendToServer()
- frame:Close()
- end
- end
- for i = 1, #DrinkSelectionTitles do
- CreateButton(DrinkSelectionTitles[i], ButtonColorTable[i], i)
- end
- function frame:Think() if (!LocalPlayer():Alive()) then if frame then frame:Remove() end end end -- If you die or press END [Insert] [Home] [Pageup] close the menu.
- function frame:OnKeyCodePressed(key) -- [Delete] [*END*] [Pagedown]
- if (key == KEY_END) then
- frame:Remove()
- end
- end
- end
- end)
- function ENT:Draw()
- self:DrawModel()
- local dist = self:GetPos():Distance(LocalPlayer():GetPos())
- if dist <= 999 then
- local coords = self:GetPos()
- local angs1 = self:GetAngles()
- local angs2 = self:GetAngles()
- local angs3 = self:GetAngles()
- local angs4 = self:GetAngles()
- local h = 42
- local speed = 80
- local h2 = 65 + (math.sin(CurTime() * 2) * 2)
- local textcolor = Color(255,90,90,255)
- local outlinecolor = Color(0,0,0,90)
- angs1:RotateAroundAxis(angs1:Forward(), 90)
- angs1:RotateAroundAxis(angs1:Right(), -89)
- angs2:RotateAroundAxis(angs2:Forward(), 90)
- angs2:RotateAroundAxis(angs2:Right(), -80)
- angs3:RotateAroundAxis(angs3:Forward(),90)
- angs3:RotateAroundAxis(angs3:Right(),CurTime()*85)
- angs4:RotateAroundAxis(angs4:Forward(),90)
- angs4:RotateAroundAxis(angs4:Right(),180 + CurTime()*85)
- cam.Start3D2D(self:LocalToWorld(Vector(20.5,-8.45,h)), angs1, 0.15)
- draw.SimpleTextOutlined(" WAY FROM", "ReserveFont", 0, 0, textcolor, TEXT_ALIGN_CENTER, TEXT_ALIGN_TOP, 2, outlinecolor)
- cam.End3D2D()
- cam.Start3D2D(self:LocalToWorld(Vector(19.8,-17.8,h)),angs2, 0.15)
- draw.SimpleTextOutlined("KEEP A","ReserveFont", 0, 0, textcolor, TEXT_ALIGN_CENTER, TEXT_ALIGN_TOP, 2, outlinecolor)
- cam.End3D2D()
- //Spinning Text
- cam.Start3D2D(self:LocalToWorld(Vector(0,0,h2)),angs3,0.45)
- draw.SimpleTextOutlined("DR BREEN'S","ReserveFont",0,0,Color(150,150,150),TEXT_ALIGN_CENTER,TEXT_ALIGN_TOP,2,outlinecolor)
- cam.End3D2D()
- cam.Start3D2D(self:LocalToWorld(Vector(0,0,h2)),angs4,0.45)
- draw.SimpleTextOutlined("PRIVATE RESERVE","ReserveFont",0,0,Color(90,165,255),TEXT_ALIGN_CENTER,TEXT_ALIGN_TOP,2,outlinecolor)
- cam.End3D2D()
- end
- end
- end -- End of Client Functions
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement