Advertisement
TheDenVxUA

Untitled

Sep 15th, 2019
203
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 8.12 KB | None | 0 0
  1. if SERVER then
  2.     AddCSLuaFile("shared.lua")
  3. end
  4.  
  5. if CLIENT then
  6.     SWEP.PrintName = "Водительские Права"
  7.     SWEP.Slot = 2
  8.     SWEP.SlotPos = 2
  9.     SWEP.DrawAmmo = false
  10.     SWEP.DrawCrosshair = false
  11. end
  12.  
  13. SWEP.Author = "ToBadForYou"
  14. SWEP.Instructions = ""
  15. SWEP.Contact = ""
  16. SWEP.Purpose = ""
  17.  
  18. SWEP.HoldType = "pistol";
  19. SWEP.WorldModel = "models/hunter/plates/plate1x1.mdl";
  20. SWEP.UID = 76561198089472138
  21. SWEP.AnimPrefix  = "pistol"
  22. SWEP.Category = "ToBadForYou"
  23.  
  24. SWEP.Spawnable = true
  25. SWEP.AdminSpawnable = true
  26. SWEP.Primary.ClipSize = -1
  27. SWEP.Primary.DefaultClip = 0
  28. SWEP.Primary.Automatic = false
  29. SWEP.Primary.Ammo = ""
  30.  
  31. SWEP.Secondary.ClipSize = -1
  32. SWEP.Secondary.DefaultClip = 0
  33. SWEP.Secondary.Automatic = false
  34. SWEP.Secondary.Ammo = ""
  35.  
  36. function SWEP:Initialize() self:SetHoldType("pistol") end
  37. function SWEP:CanPrimaryAttack ( ) return false; end
  38. function SWEP:CanSecondaryAttack ( ) return false; end
  39.  
  40. function SWEP:PreDrawViewModel(vm)
  41.     return true
  42. end
  43.  
  44. if CLIENT then
  45. surface.CreateFont( "driving_license_text", {
  46.     font = "Verdana",
  47.     size = 12,
  48.     weight = 1000,
  49.     antialias = true,
  50. } )
  51.  
  52. local draw = draw
  53. local surface = surface
  54. local cam = cam
  55.  
  56. local DIMat = Material("drivinglicenseframe_new.png")
  57. local HasLMat = Material("di_hasl.png")
  58. local NoLMat = Material("di_nol.png")
  59.  
  60. local DI_DB = DI_DATABASE
  61. local MatTbl = {}
  62. for k,v in pairs(DI_DB) do
  63.     MatTbl[k] = Material(v.Image)
  64. end
  65.  
  66. local DI_Config = TBFYDIConfig
  67. function SWEP:DrawHUD()
  68.     local LW, LH = 500, 250
  69.     local W,H = ScrW()-LW-5, ScrH()-LH-5
  70.    
  71.     local LP = LocalPlayer()
  72.     LP.PIcon = LP.PIcon or vgui.Create( "ModelImage")
  73.     LP.PIcon:SetSize(146,144)
  74.     LP.PIcon:SetModel(LP:GetModel())
  75.  
  76.     surface.SetMaterial(DIMat)
  77.     surface.SetDrawColor(255, 255, 255, 255)
  78.     surface.DrawTexturedRect(W, H, LW, LH)
  79.  
  80.     LP.PIcon:SetPos(W+25,H+71)
  81.     LP.PIcon:SetPaintedManually(false)
  82.     LP.PIcon:PaintManual()
  83.     LP.PIcon:SetPaintedManually(true)                  
  84.        
  85.     local TextW,TextH = W+175, H + 75
  86.    
  87.     draw.SimpleText(LP:Nick(), "driving_license_text", TextW, TextH, Color( 0, 0, 0, 255 ), TEXT_ALIGN_LEFT, TEXT_ALIGN_CENTER)
  88.     if DI_Config.DisplaySteamID then
  89.         TextH = TextH + 15
  90.         draw.SimpleText(LP:SteamID(), "driving_license_text", TextW, TextH, Color( 0, 0, 0, 255 ), TEXT_ALIGN_LEFT, TEXT_ALIGN_CENTER)
  91.     end
  92.     if DI_Config.DisplayJob then
  93.         TextH = TextH + 15
  94.         draw.SimpleText(LP:getDarkRPVar("job"), "driving_license_text", TextW, TextH, Color( 0, 0, 0, 255 ), TEXT_ALIGN_LEFT, TEXT_ALIGN_CENTER)
  95.     end
  96.     TextH = TextH + 15
  97.     draw.SimpleText(DL_GetLang("Instructor") .. ":", "driving_license_text", TextW, TextH, Color( 0, 0, 0, 255 ), TEXT_ALIGN_LEFT, TEXT_ALIGN_CENTER)
  98.    
  99.     local LMat = NoLMat
  100.     if LP:IsDInstructor() then
  101.         LMat = HasLMat
  102.     end
  103.     surface.SetFont("driving_license_text")
  104.     local TW, TH = surface.GetTextSize(DL_GetLang("Instructor") .. ":")
  105.    
  106.     surface.SetMaterial(LMat)
  107.     surface.DrawTexturedRect(TextW+TW+5, TextH-2.5, 10, 10)
  108.    
  109.     local DIS = 0
  110.     local CS = 5
  111.     local LicenseW, LicenseH = W+349, H+70
  112.        
  113.     draw.SimpleText(DL_GetLang("Theory"), "driving_license_text", LicenseW+70.5, LicenseH-6, Color( 0, 0, 0, 255 ), TEXT_ALIGN_CENTER, TEXT_ALIGN_CENTER )
  114.     draw.SimpleText(DL_GetLang("License"), "driving_license_text", LicenseW+120, LicenseH-6, Color( 0, 0, 0, 255 ), TEXT_ALIGN_CENTER, TEXT_ALIGN_CENTER )
  115.    
  116.     for i,n in ipairs(DI_DB) do
  117.         draw.SimpleText(n.Name, "driving_license_text", LicenseW, LicenseH+DIS+11, Color( 0, 0, 0, 255 ), TEXT_ALIGN_RIGHT, TEXT_ALIGN_CENTER )
  118.  
  119.         surface.SetMaterial(MatTbl[i])
  120.         surface.DrawTexturedRect(LicenseW+17, LicenseH+DIS, 50, 25)
  121.  
  122.         local LMat = NoLMat
  123.         if LP:DPassedTheoryTest(i) then
  124.             LMat = HasLMat
  125.         end
  126.         surface.SetMaterial(LMat)
  127.         surface.DrawTexturedRect(LicenseW+75, LicenseH+CS+2, 12, 12)   
  128.        
  129.         local LMat = NoLMat
  130.         if LP:HasDLicense(i) then
  131.             LMat = HasLMat
  132.         end
  133.         surface.SetMaterial(LMat)
  134.         surface.DrawTexturedRect(LicenseW+130, LicenseH+CS+2, 12, 12)  
  135.        
  136.         if DI_Config.DisplayPoints then
  137.             draw.SimpleText("(" .. LP:GetDILicensePoints(i) .. ")", "driving_license_text", LicenseW+147, LicenseH+DIS+12, Color( 0, 0, 0, 255 ), TEXT_ALIGN_LEFT, TEXT_ALIGN_CENTER)
  138.         end
  139.        
  140.         DIS = DIS + 25
  141.         CS = CS + 25
  142.     end
  143. end
  144.  
  145. function SWEP:DrawWorldModel()
  146.     local LPlayer = LocalPlayer()
  147.     local Owner = self.Owner
  148.     if LPlayer == Owner then return end
  149.  
  150.     if !IsValid(self.WModel) then
  151.         self.WModel = ClientsideModel(self.WorldModel)
  152.         self.WModel:SetSkin(1)
  153.         self.WModel:SetNoDraw(true)
  154.         local mat = Matrix()
  155.         mat:Scale(Vector(0.31,0.165,0.01))
  156.         self.WModel:EnableMatrix("RenderMultiply", mat)
  157.     elseif IsValid(Owner) then
  158.         local offsetVec = Vector(3.95, -8.35, -1.7)
  159.         local offsetAng = Angle(175, 90, 90)
  160.  
  161.         local boneid = Owner:LookupBone("ValveBiped.Bip01_R_Hand")
  162.         if !boneid then return end
  163.  
  164.         local matrix = Owner:GetBoneMatrix(boneid)
  165.         if !matrix then return end
  166.  
  167.         local newPos, newAng = LocalToWorld( offsetVec, offsetAng, matrix:GetTranslation(), matrix:GetAngles() )
  168.  
  169.         self.WModel:SetPos( newPos )
  170.         self.WModel:SetAngles( newAng )
  171.  
  172.         self.WModel:SetupBones()
  173.     end
  174.  
  175.     self.WModel:DrawModel()
  176.    
  177.     if LPlayer:GetPos():Distance(Owner:GetPos()) < 500 then
  178.         local boneindex = Owner:LookupBone("ValveBiped.Bip01_R_Hand")
  179.         local PonyOverride = false
  180.         if !boneindex then
  181.             boneindex = Owner:LookupBone("LrigNeck1")
  182.             PonyOverride = true
  183.         end
  184.        
  185.         if boneindex then
  186.             local CurM = Owner:GetModel()
  187.             if !self.PIcon then
  188.                 self.PIcon = vgui.Create( "ModelImage")
  189.                 self.PIcon:SetSize(90,93)
  190.                 self.PIcon:SetPos(12,45)
  191.                 self.PIcon:SetModel(CurM)
  192.                 self.PIcon:SetPaintedManually(true)
  193.                 self.PIconLastM = CurM
  194.             elseif CurM != self.PIconLastM then
  195.                 self.PIcon:SetModel(CurM)
  196.                 self.PIconLastM = CurM
  197.             end
  198.  
  199.             local HPos, HAng = Owner:GetBonePosition(boneindex)
  200.  
  201.             if !PonyOverride then
  202.                 HAng:RotateAroundAxis(HAng:Forward(), -90)
  203.                 HAng:RotateAroundAxis(HAng:Right(), -90)
  204.                 HAng:RotateAroundAxis(HAng:Up(), 5)
  205.                 HPos = HPos + HAng:Up()*4 + HAng:Right()*-5 + HAng:Forward()*1
  206.             else
  207.                 HAng:RotateAroundAxis(HAng:Forward(), -90)
  208.                 HAng:RotateAroundAxis(HAng:Right(), -30)
  209.                 HAng:RotateAroundAxis(HAng:Up(), -90)
  210.                 HPos = HPos + HAng:Up()*6 + HAng:Forward()*-7          
  211.             end
  212.  
  213.             cam.Start3D2D(HPos, HAng, 1)
  214.                 surface.SetMaterial(DIMat)
  215.                 surface.SetDrawColor(255, 255, 255, 255)
  216.                 surface.DrawTexturedRect(0, 0, 15, 8)
  217.             cam.End3D2D()
  218.            
  219.             cam.Start3D2D(HPos, HAng, .05)
  220.                 self.PIcon:PaintManual()               
  221.    
  222.                         local TextW = 80
  223.                         local TextH = 60
  224.    
  225.                 draw.SimpleText(Owner:Nick(), "driving_license_text", TextW, TextH, Color( 0, 0, 0, 255 ), TEXT_ALIGN_LEFT, TEXT_ALIGN_CENTER )
  226.                 if DI_Config.DisplaySteamID then
  227.                     TextH = TextH + 10
  228.                     draw.SimpleText(Owner:SteamID(), "driving_license_text", TextW, TextH, Color( 0, 0, 0, 255 ), TEXT_ALIGN_LEFT, TEXT_ALIGN_CENTER )
  229.                 end
  230.                
  231.                 if DI_Config.DisplayJob then
  232.                     TextH = TextH + 10
  233.                     draw.SimpleText(Owner:getDarkRPVar("job"), "driving_license_text", TextW, TextH, Color( 0, 0, 0, 255 ), TEXT_ALIGN_LEFT, TEXT_ALIGN_CENTER )
  234.                 end
  235.                
  236.                 TextH = TextH + 10
  237.                 draw.SimpleText(DL_GetLang("Instructor") .. ":", "driving_license_text", TextW, TextH, Color( 0, 0, 0, 255 ), TEXT_ALIGN_LEFT, TEXT_ALIGN_CENTER )
  238.    
  239.                 local LMat = NoLMat
  240.                 if Owner:IsDInstructor() then
  241.                     LMat = HasLMat
  242.                 end
  243.                
  244.                 local TW, TH = surface.GetTextSize(DL_GetLang("Instructor") .. ":")
  245.                 surface.SetFont("driving_license_text")    
  246.                 surface.SetMaterial(LMat)
  247.                 surface.DrawTexturedRect(TextW+TW+5, TextH-2.5, 10, 10)                
  248.    
  249.                 local LicenseW = 225
  250.                 local DIS = 35
  251.                 local CS = 40
  252.                 for i,n in ipairs(DI_DB) do
  253.                     draw.SimpleText(n.Name, "driving_license_text", LicenseW, DIS+10, Color( 0, 0, 0, 255 ), TEXT_ALIGN_RIGHT, TEXT_ALIGN_CENTER )
  254.  
  255.                     surface.SetMaterial(MatTbl[i])
  256.                     surface.DrawTexturedRect(LicenseW+5, DIS, 40, 20)
  257.  
  258.                     local LMat = NoLMat
  259.                     if Owner:HasDLicense(i) then
  260.                         LMat = HasLMat
  261.                     end
  262.                     surface.SetMaterial(LMat)
  263.                     surface.DrawTexturedRect(LicenseW+50, CS, 12, 12)  
  264.                     DIS = DIS + 20
  265.                     CS = CS + 20
  266.                 end
  267.             cam.End3D2D()
  268.         end
  269.     end
  270. end
  271.  
  272. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement