|
| 29 Jul 2015 08:41 PM |
local Cars = game.ServerStorage['Cars'] local Custom = game.ReplicatedStorage['Customization']
local function Replace(Part, Replacement, Info, Type) local partInfo = Info[Type][Part.Name] Replacement = Replacement['Replacement'][partInfo['Type']]:Clone() local Primary = partInfo['PrimaryPart'] Replacement.PrimaryPart = Replacement[Primary] Part.PrimaryPart = Part[Primary] Replacement:SetPrimaryPartCFrame(Part:GetPrimaryPartCFrame()) Replacement.Parent = Part.Parent Replacement.Name = Part.Name Part:Destroy() local tbb = Replacement:GetChildren() for i = 1,#tbb do if tbb[i].Name == 'Paint' then local p = tbb[i] p.BrickColor = partInfo['BrickColor'] p.Reflectance = partInfo['Reflectance'] end end end
local function ReplacePart(Part, Replacement, Info, Type) local partInfo = Info[Type][Part.Name] Replacement = Replacement['Replacement'][partInfo['Type']]:Clone() Replacement.CFrame = Part.CFrame Replacement.Parent = Part.Parent Replacement.Name = Part.Name Part:Destroy() end
local function ReplaceDecal(Decal, Replacement, Info, Type) local decalInfo = Info[Type][Decal.Name] Decal.Texture = decalInfo end
local function loadCar(Info) local Car = Cars[Info['Type']] local Customs = Custom[Info['Type']] local tb = { Car['VehicleSeat']['Server']['Performance'], Car['VehicleSeat']['Server']['Stats'], } for i = 1,#tb do local c = tb[i]:GetChildren() for ii = 1,#c do c[ii].Value = Info[tb[i].Name][c[ii].Name] end end local Body = Car:findFirstChild('Body') if Body then local bodyParts = Customs['Aesthetics']['Exterior']['Body'] tb = Body:GetChildren() for i = 1,#tb do local Part = tb[i] local Replacement = bodyParts:findFirstChild(Part.Name) if Replacement then Replace(Part, Replacement, Info, 'Body') elseif Part.Name == 'Paint' then Part.BrickColor = Info['Body']['BrickColor'] Part.Reflectance = Info['Body']['Reflectance'] end end end Replace(Car['Exhaust'], Customs['Aesthetics']['Exhaust'], Info, 'Car') local Wheels = Car['Wheels']:GetChildren() local customW = Customs['Aesthetics']['Exterior']['Wheels'] for i = 1,#Wheels do local w = Wheels[i] ReplacePart(w['Tire'], customW['Tires'], Info, 'Wheels') Replace(w['Rim'], customW['Rims'], Info, 'Wheels') ReplaceDecal(w['Tire']['Blank'], customW['Tires']['Tire Brand'], Info, 'Wheels') end tb = {Car['frontBrakes'], Car['rearBrakes']} local brakeInfo = Info['Brakes'] for i = 1,#tb do local Brakes = {tb[i]['R']['Calipers'], tb[i]['L']['Calpiers']} for ii = 1,#Brakes do Brakes[ii].BrickColor = brakeInfo['BrickColor'] Brakes[ii].Reflectance = brakeInfo['Reflectance'] end end return Car end
local function saveCar(Car) local Info = {} local Customs = Custom[Info['Type']] local tb = { Car['VehicleSeat']['Server']['Performance'], Car['VehicleSeat']['Server']['Stats'], } for i = 1,#tb do local c = tb[i]:GetChildren() for ii = 1,#c do Info[tb[i].Name] = c[ii].Value end end local Body = Car:findFirstChild('Body') if Body then local bodyParts = Customs['Aesthetics']['Exterior']['Body'] tb = Body:GetChildren() for i = 1,#tb do local Part = tb[i] local Replacement = bodyParts:findFirstChild(Part.Name) if Replacement then Info['Body'][Part.Name]['Type'] = Part['Type'].Value local Paint = Part:findFirstChild('Paint') if Paint then Info['Body'][Part.Name]['BrickColor'] = Paint.BrickColor Info['Body'][Part.Name]['Reflectance'] = Paint.Reflectance end end end local Paint = Body['Paint'] Info['Body']['BrickColor'] = Paint.BrickColor Info['Body']['Reflectance'] = Paint.Reflectance end Info['Car']['Exhaust']['Type'] = Car['Exhaust']['Type'].Value local Wheels = Car['Wheels']:GetChildren() for i = 1,#Wheels do local w = Wheels[i] Info['Wheels']['Tire']['Type'] = w['Tire']['Type'].Value Info['Wheels']['Rim']['Type'] = w['Rim']['Type'].Value Info['Wheels']['Blank'] = w['Tire']['Blank'].Texture end local Brakes = Car['frontBrakes']['R']['Calipers'] Info['Brakes']['BrickColor'] = Brakes.BrickColor Info['Reflectance']['Reflectance'] = Brakes.Reflectance return Info end |
|
|
| Report Abuse |
|
| |
harrddy
|
  |
| Joined: 01 May 2009 |
| Total Posts: 29753 |
|
| |
| |
harrddy
|
  |
| Joined: 01 May 2009 |
| Total Posts: 29753 |
|
| |