SHARE
TWEET

baster

a guest Sep 16th, 2019 89 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. AddCSLuaFile( "cl_init.lua" )
  2. AddCSLuaFile( "shared.lua" )
  3.  
  4. include( "shared.lua" )
  5.  
  6. function ENT:Initialize()
  7.  
  8.     self:SetModel( "models/props_phx/construct/metal_plate2x4.mdl" )
  9.  
  10.     self:PhysicsInit( SOLID_VPHYSICS )
  11.     self:SetMoveType( MOVETYPE_VPHYSICS )
  12.     self:SetSolid( SOLID_VPHYSICS )
  13.  
  14.     self:SetCollisionGroup( COLLISION_GROUP_WEAPON )
  15.  
  16.     local phys = self:GetPhysicsObject()
  17.     phys:Sleep()
  18.     phys:EnableMotion( false )
  19.    
  20.     self:DrawShadow( false )
  21.  
  22.     self:SetMaterial( "models/debug/debugwhite" )
  23.  
  24.     self.ply = nil
  25.     self.lastThink = CurTime()
  26.     self.vehicle = nil
  27.  
  28.     self.bodygroupsnumlist = {}
  29.     self.OldVehicleSpecs = {}
  30.  
  31. end
  32.  
  33.  
  34.  
  35. function ENT:Think()
  36.  
  37.     if( self.lastThink > CurTime() ) then
  38.         return
  39.     end
  40.     self.lastThink = CurTime() + 2.5
  41.  
  42.     if IsValid(self.ply) and self.ply:GetPos():DistToSqr( self:GetPos() ) > 200^2 then
  43.  
  44.         --print( "we left!" )
  45.         self.ply:ChatPrint( CAR_DEALER.CFG.Language["carcustomsleave"] )
  46.  
  47.         self.ply.PlayerInCustomization = false
  48.         net.Start("RG:CloseCustomizerVGUI")
  49.             net.WriteEntity(self.vehicle)
  50.         net.Send( self.ply )
  51.  
  52.         self.ply = nil
  53.         self.vehicle = nil
  54.         return
  55.     end
  56.  
  57.    
  58.     local mins = self:OBBMins()
  59.     local maxs = self:OBBMaxs()
  60.     local startpos = self:GetPos()
  61.     local dir = self:GetUp()
  62.     local len = 128
  63.  
  64.     local tr = util.TraceHull( {
  65.         start = startpos,
  66.         endpos = startpos + dir * len,
  67.         maxs = maxs,
  68.         mins = mins,
  69.         filter = ents.FindByClass( "npc_rg_carcustomizer" )
  70.     } )
  71.    
  72.     local vehicle = tr.Entity
  73.  
  74.    
  75.  
  76.     if IsValid(vehicle) and vehicle:IsVehicle() and IsValid(vehicle:GetDriver()) then
  77.        
  78.         local pl = vehicle:GetDriver()
  79.  
  80.         if not IsValid(pl) then return end
  81.  
  82.         if CAR_DEALER:GetSpawnedVehicle(pl) ~= vehicle then
  83.             print( "Not owner!" )
  84.             pl:ChatPrint( "Not owner!" )
  85.             return
  86.         end
  87.        
  88.         if self.ply == pl then
  89.             return
  90.         else
  91.            
  92.             self.ply = pl
  93.             self.vehicle = vehicle
  94.  
  95.             --local self.bodygroupsnumlist = {}
  96.            
  97.  
  98.             --print( "we're here!" )
  99.             self.ply:ChatPrint( CAR_DEALER.CFG.Language["carcustomswelcome"] )
  100.            
  101.             self.ply.PlayerInCustomization = true
  102.             net.Start("RG:OpenCustomizerVGUI")
  103.                 net.WriteEntity(vehicle)
  104.             net.Send( self.ply )
  105.  
  106.         end
  107.        
  108.     else
  109.         self.ply = nil
  110.     end
  111.  
  112. end
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top