Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- GARAGE = {}
- GARAGE.RepairPrice = 100 //How much costs the repairing
- GARAGE.BodyGroupPrice = 200 //Bodygroups price
- GARAGE.SkinPrice = 500 //Paint job price
- GARAGE.ColorPrice = 250 //Color price
- GARAGE.Data = {}
- GARAGE_PROPS = GARAGE_PROPS or {}
- local plt = "models/hunter/plates/plate3x6.mdl"
- local pltB = "models/hunter/plates/plate6x6.mdl"
- local MX = {Vector(0,-142,0),Vector(142,0,0),Vector(142*2,-142,7200),Vector(142,-142*2,0)}
- if SERVER then
- util.AddNetworkString("CreateGarage")
- util.AddNetworkString("SendGarageMoney")
- util.AddNetworkString("RepairGarageCar")
- util.AddNetworkString("RepairCar")
- resource.AddFile("materials/garage/customs.vmt")
- resource.AddFile("materials/garage/circle.vmt")
- resource.AddFile("materials/garage/dot.vmt")
- resource.AddFile("materials/garage/neon_light.vmt")
- end
- concommand.Add("gzg_garage_create",function(ply)
- if(ply:IsAdmin()) then
- net.Start("CreateGarage")
- net.SendToServer()
- end
- end)
- concommand.Add("gzg_garage_save",function(ply)
- local tbl = {}
- file.Delete("garage_data.dat")
- file.Write("garage_data.dat",util.TableToJSON(GARAGE.Data))
- end)
- concommand.Add("gzg_garage_remove",function()
- if(GARAGE_PROPS != nil) then
- for k,v in pairs(GARAGE_PROPS) do
- if(IsValid(v)) then
- v:Remove()
- end
- end
- end
- GARAGE.Data = {}
- end)
- concommand.Add("gzg_garage_reload",function()
- timer.Simple(1,function()
- local t = util.JSONToTable(file.Read("garage_data.dat","DATA") or "[]")
- if(istable(t)) then
- for k,v in pairs(t) do
- PRELOAD_DOORS(v[1],v[2])
- end
- end
- end)
- end)
- net.Receive("SendGarageMoney",function(l,ply)
- local a,b,c,d = net.ReadFloat(),net.ReadColor(),net.ReadTable(),net.ReadFloat()
- if(ply:getDarkRPVar("money") >= d) then
- ply:addMoney(-d)
- timer.Simple(0.1,function()
- local vh = ply:GetVehicle()
- vh:SetSkin(a)
- vh:SetColor(b)
- for k,v in pairs(c) do
- vh:SetBodygroup(k,v)
- end
- end)
- end
- end)
- net.Receive("RepairCar",function(l,ply)
- if(ply:getDarkRPVar("money") >= GARAGE.RepairPrice) then
- ply:addMoney(-GARAGE.RepairPrice)
- ply:GetVehicle():SetHealth(ply:GetVehicle():GetMaxHealth() or 100)
- end
- end)
- net.Receive("RepairGarageCar",function(l,ply)
- ply:GetVehicle():SetHealth(ply:GetVehicle():GetMaxHealth() or 100)
- end)
- net.Receive("CreateGarage",function(l,ply)
- table.insert(GARAGE.Data,{ply:GetEyeTrace().HitPos,ply:EyeAngles()})
- PRELOAD_DOORS(ply:GetEyeTrace().HitPos,ply:EyeAngles(),ply)
- end)
- hook.Add("Think","DoorResponse",function()
- for k,v in pairs(ents.FindByClass("prop_physics")) do
- if(v.IsGarageDoor or false) then
- b = false
- for _,a in pairs(ents.FindInSphere(v:GetPos(),180)) do
- if(a:IsPlayer()) then
- b = true
- end
- end
- if(b) then
- if(v.Out or 0 < 180) then
- v.Out = math.Clamp((v.Out or 0) + 2,0,144)
- end
- else
- if(v.Out or 0 > -1) then
- v.Out = math.Clamp((v.Out or 0) - 2,0,144)
- end
- end
- v:SetPos(v.Base + Vector(0,0,v.Out or 0))
- end
- end
- if CLIENT then
- if(!IsValid(LocalPlayer().Lookcamera)) then
- LocalPlayer().ShouldMenu = false
- end
- for k,v in pairs(ents.FindByClass("prop_dynamic")) do
- if(v:GetNWBool("Waypoint",false)) then
- if(v:GetPos():Distance(LocalPlayer():GetPos()) < 96 && LocalPlayer():InVehicle()) then
- LocalPlayer().Lookcamera = v
- if(!(LocalPlayer().ShouldMenu or false)) then
- if(LocalPlayer().DM != nil) then
- LocalPlayer().DM:Remove()
- LocalPlayer().DM = nil
- end
- LocalPlayer().DM = vgui.Create("DGarage")
- LocalPlayer().ShouldMenu = true
- end
- elseif(LocalPlayer().Lookcamera == v) then
- LocalPlayer().Lookcamera = nil
- LocalPlayer().ShouldMenu = false
- end
- end
- end
- end
- end)
- function drawGarage( ply, pos, angles, fov )
- if(IsValid(LocalPlayer().Lookcamera)) then
- local ent = LocalPlayer().Lookcamera
- local view = {}
- view.origin = ent:GetPos() + Vector(0,0,100) + ent:GetForward()*72 - ent:GetRight()*96
- view.angles = ent:GetAngles() + Angle(35,135+90+10,0)
- view.fov = fov
- return view
- end
- end
- hook.Add( "CalcView", "drawGarage", drawGarage )
- hook.Add( "ShouldDrawLocalPlayer", "drawGarage", function( ply )
- if(IsValid(LocalPlayer().Lookcamera)) then
- return true
- end
- end )
- hook.Add("CreateMove","SetMovementNil",function(cmd)
- if((LocalPlayer().ShouldMenu or false) && ispanel(LocalPlayer().DM)) then
- cmd:ClearMovement()
- cmd:ClearButtons()
- end
- end)
- function garagePickup( ply, ent )
- if ent.IsGarage or false then
- return false
- end
- end
- hook.Add( "PhysgunPickup", "Allow garagePickup Pickup", garagePickup )
- hook.Add("CanTool","VehicleColor",function( ply, tr, tool )
- if (tool == "colour" || tool == "material") and IsValid( tr.Entity ) and tr.Entity:IsVehicle() then
- return false
- end
- end)
- hook.Add( "CanProperty", "RemoveVehicleProperties", function( ply, property, ent )
- if(property == "bodygroups" or property == "skin") then
- return false
- end
- end )
- local Laser = Material( "garage/neon_light" )
- local letter = Material("garage/customs")
- local function drawBeams(ent,color)
- render.DrawBeam( ent:GetPos() + ent:GetRight()*148 - ent:GetUp()*4 - ent:GetForward()*70, ent:GetPos() - ent:GetForward()*70 - ent:GetRight()*148 - ent:GetUp()*4, 10, 10, 10, color )
- render.DrawBeam( ent:GetPos() + ent:GetRight()*148 - ent:GetUp()*4 - ent:GetForward()*4, ent:GetPos() - ent:GetForward()*4 - ent:GetRight()*148 - ent:GetUp()*4, 10, 10, 10, color )
- render.DrawBeam( ent:GetPos() + ent:GetRight()*70 - ent:GetUp()*4 - ent:GetForward()*70, ent:GetPos() + ent:GetRight()*70 - ent:GetUp()*4 + ent:GetForward()*-4, 10, 10, 10, color )
- render.DrawBeam( ent:GetPos() - ent:GetRight()*66 - ent:GetUp()*4 - ent:GetForward()*70, ent:GetPos() - ent:GetRight()*66 - ent:GetUp()*4 + ent:GetForward()*-4, 10, 10, 10, color )
- end
- hook.Add("PreDrawTranslucentRenderables","DrawNeon",function()
- for k,ent in pairs(ents.FindByClass("prop_physics")) do
- if(ent:GetNWBool("IsGarageDoor",false)) then
- render.SetMaterial( Laser )
- local col = HSVToColor( CurTime() % 6 * 60, 1, 1 )
- local color = Color(col.r,col.g,col.b,255 + math.cos(CurTime()*math.random(1,100))*65)
- drawBeams(ent,Color(150,150,150,255))
- drawBeams(ent,color)
- local offset = Vector( 0, 0, 85 )
- local ang = Angle(0,0,0)
- local pos = ent:GetPos() + offset - ent:GetUp()*6 + ent:GetForward() * 32
- ang:RotateAroundAxis( ang:Forward(), 90 )
- cam.Start3D2D( pos, ang, 0.5 )
- surface.SetMaterial(letter)
- surface.SetDrawColor(255,255,255)
- surface.DrawTexturedRect(-256/2+8,-26,316,116)
- cam.End3D2D()
- end
- end
- for k,b in pairs(ents.FindByClass("prop_dynamic")) do
- if(b:GetNWBool("Waypoint",false)) then
- local col = HSVToColor( CurTime() % 6 * 60, 1, 1 )
- render.SetMaterial( Laser )
- render.DrawBeam( b:GetPos() + b:GetRight()*151 + b:GetUp()*2 + b:GetForward()*148, b:GetPos() + b:GetForward()*148 - b:GetRight()*151 + b:GetUp()*2, 10, 1, 1, col )
- render.DrawBeam( b:GetPos() - b:GetRight()*148 + b:GetUp()*2 - b:GetForward()*148, b:GetPos() + b:GetForward()*148 - b:GetRight()*148 + b:GetUp()*2, 10, 1, 1, col )
- render.DrawBeam( b:GetPos() + b:GetRight()*148 + b:GetUp()*2 - b:GetForward()*148, b:GetPos() + b:GetForward()*148 + b:GetRight()*148 + b:GetUp()*2, 10, 1, 1, col )
- render.DrawBeam( b:GetPos() + b:GetRight()*151 + b:GetUp()*2 + b:GetForward()*148 + Vector(0,0,140), b:GetPos() + b:GetForward()*148 - b:GetRight()*151 + b:GetUp()*2 + Vector(0,0,140), 10, 1, 1, col )
- render.DrawBeam( b:GetPos() - b:GetRight()*148 + b:GetUp()*2 - b:GetForward()*148 + Vector(0,0,140), b:GetPos() + b:GetForward()*148 - b:GetRight()*148 + b:GetUp()*2 + Vector(0,0,140), 10, 1, 1, col )
- render.DrawBeam( b:GetPos() + b:GetRight()*148 + b:GetUp()*2 - b:GetForward()*148 + Vector(0,0,140), b:GetPos() + b:GetForward()*148 + b:GetRight()*148 + b:GetUp()*2 + Vector(0,0,140), 10, 1, 1, col )
- end
- end
- end)
- hook.Add("Initialize","CreateGarages",function()
- timer.Simple(1,function()
- local t = util.JSONToTable(file.Read("garage_data.dat","DATA") or "[]")
- if(istable(t)) then
- for k,v in pairs(t) do
- PRELOAD_DOORS(v[1],v[2])
- end
- end
- end)
- end)
- function PRELOAD_DOORS(pos,ang,ply)
- local bs = pos
- local an = Angle(0,ang.y,0)
- if(!IsValid(ply)) then
- ply = ents.Create("prop_dynamic")
- ply:SetModel("models/Gibs/HGIBS.mdl")
- ply:SetAngles(Angle(0,ang.y,0))
- ply:SetPos(pos)
- ply:Spawn()
- end
- local undoList = {}
- for k=1,4 do
- local fPos = bs + ply:GetForward()*MX[k].y + ply:GetRight()*MX[k].x + Vector(0,0,72) + ply:GetForward()*142 - ply:GetRight()*142
- local ent = ents.Create("prop_physics")
- ent:SetModel(plt)
- ent:SetAngles(Angle(90,an.y+90*k*-1,0))
- ent:SetPos(fPos)
- ent:Spawn()
- ent.IsGarage = true
- if(k==4) then
- ent.IsGarageDoor = true
- ent.Base = ent:GetPos()
- ent:SetNWBool("IsGarageDoor",true)
- ent:SetMaterial("phoenix_storms/dome")
- else
- ent:SetMaterial("brick/brick_model")
- end
- ent:GetPhysicsObject():EnableMotion(false)
- table.insert(GARAGE_PROPS,ent)
- table.insert(undoList,ent)
- end
- local ent = ents.Create("prop_physics")
- ent:SetModel(pltB)
- ent:SetAngles(Angle(0,an.y,0))
- ent:SetPos(bs + Vector(0,0,144))
- ent:Spawn()
- ent.IsGarage = true
- ent.IsTop = true
- ent:SetMaterial("models/props_foliage/tree_deciduous_01a_trunk")
- ent:GetPhysicsObject():EnableMotion(false)
- local wp = ents.Create("prop_dynamic")
- wp:SetModel("models/Gibs/HGIBS.mdl")
- wp:SetPos(bs + Vector(0,0,0))
- wp:SetAngles(Angle(0,an.y,0))
- wp:Spawn()
- wp:SetNWBool("Waypoint",true)
- wp.Owner = nil
- wp:SetRenderMode(RENDERMODE_TRANSALPHA)
- wp:SetColor(Color(0,0,0,0))
- wp:SetMoveType(MOVETYPE_NONE)
- table.insert(undoList,ent)
- table.insert(undoList,wp)
- table.insert(GARAGE_PROPS,ent)
- table.insert(GARAGE_PROPS,wp)
- if(ply:IsPlayer()) then
- undo.Create( "prop" )
- for k,v in pairs(undoList) do
- undo.AddEntity( v )
- end
- undo.SetPlayer( ply )
- undo.SetCustomUndoText( "Undone Garage" )
- undo.Finish()
- else
- ply:Remove()
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement