Advertisement
TheDenVxUA

Untitled

Sep 15th, 2019
147
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 7.44 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 = ""
  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:DrawWorldModel()
  41. end
  42.  
  43. function SWEP:PreDrawViewModel(vm)
  44.     return true
  45. end
  46.  
  47. if CLIENT then
  48. surface.CreateFont( "driving_license_text", {
  49.     font = "Tebuchet",
  50.     size = 13,
  51.     weight = 7000,
  52.     antialias = true,
  53. } )
  54.  
  55. local draw = draw
  56. local surface = surface
  57. local cam = cam
  58.  
  59. local DIMat = Material("drivinglicenseframe_new.png")
  60. local HasLMat = Material("di_hasl.png")
  61. local NoLMat = Material("di_nol.png")
  62.  
  63. local DI_DB = DI_DATABASE
  64. local MatTbl = {}
  65. for k,v in pairs(DI_DB) do
  66.     MatTbl[k] = Material(v.Image)
  67. end
  68.  
  69. local DI_Config = TBFYDIConfig
  70. local LangTbl = TBFYDIConfig.Language[DI_Config.LanguageToUse]
  71. function SWEP:DrawHUD()
  72.     local LW, LH = 500, 250
  73.     local W,H = ScrW()-LW-5, ScrH()-LH-5
  74.    
  75.     local LP = LocalPlayer()
  76.     LP.PIcon = LP.PIcon or vgui.Create( "ModelImage")
  77.     LP.PIcon:SetSize(146,144)
  78.     LP.PIcon:SetModel(LP:GetModel())
  79.                    
  80.     surface.SetMaterial(DIMat)
  81.     surface.SetDrawColor(255, 255, 255, 255)
  82.     surface.DrawTexturedRect(W, H, LW, LH)
  83.  
  84.     LP.PIcon:SetPos(W+25,H+71)
  85.     LP.PIcon:SetPaintedManually(false)
  86.     LP.PIcon:PaintManual()
  87.     LP.PIcon:SetPaintedManually(true)                  
  88.        
  89.     local TextW,TextH = W+160, H + 90
  90.    
  91.     draw.SimpleText(LP:Nick(), "driving_license_text", TextW, TextH, Color( 0, 0, 0, 255 ), TEXT_ALIGN_LEFT, TEXT_ALIGN_CENTER )
  92.     if DI_Config.DisplaySteamID then
  93.         TextH = TextH + 15
  94.         draw.SimpleText(LP:SteamID(), "driving_license_text", TextW, TextH, Color( 0, 0, 0, 255 ), TEXT_ALIGN_LEFT, TEXT_ALIGN_CENTER )
  95.     end
  96.     if DI_Config.DisplayJob then
  97.         TextH = TextH + 15
  98.         draw.SimpleText(LP:getDarkRPVar("job"), "driving_license_text", TextW, TextH, Color( 0, 0, 0, 255 ), TEXT_ALIGN_LEFT, TEXT_ALIGN_CENTER )
  99.     end
  100.     TextH = TextH + 50
  101.     draw.SimpleText(LangTbl.Instructor .. ":", "driving_license_text", TextW, TextH, Color( 0, 0, 0, 255 ), TEXT_ALIGN_LEFT, TEXT_ALIGN_CENTER )
  102.    
  103.     local LMat = NoLMat
  104.     if LP:IsDInstructor() then
  105.         LMat = HasLMat
  106.     end
  107.     surface.SetFont("driving_license_text")
  108.     local TW, TH = surface.GetTextSize(LangTbl.Instructor .. ":")  
  109.    
  110.     surface.SetMaterial(LMat)
  111.     surface.DrawTexturedRect(TextW+TW+5, TextH-2.5, 10, 10)
  112.    
  113.     local DIS = 0
  114.     local CS = 5
  115.     local LicenseW, LicenseH = W+349, H+70
  116.        
  117.     draw.SimpleText(LangTbl.Theory, "driving_license_text", LicenseW+70.5, LicenseH-6, Color( 0, 0, 0, 255 ), TEXT_ALIGN_CENTER, TEXT_ALIGN_CENTER )
  118.     draw.SimpleText(LangTbl.License, "driving_license_text", LicenseW+120, LicenseH-6, Color( 0, 0, 0, 255 ), TEXT_ALIGN_CENTER, TEXT_ALIGN_CENTER )
  119.    
  120.     for i,n in ipairs(DI_DB) do
  121.         draw.SimpleText(n.Name, "driving_license_text", LicenseW, LicenseH+DIS+11, Color( 0, 0, 0, 255 ), TEXT_ALIGN_RIGHT, TEXT_ALIGN_CENTER )
  122.                            
  123.         surface.SetMaterial(MatTbl[i])
  124.         surface.DrawTexturedRect(LicenseW+17, LicenseH+DIS, 50, 25)
  125.                            
  126.         local LMat = NoLMat
  127.         if LP:DPassedTheoryTest(i) then
  128.             LMat = HasLMat
  129.         end
  130.         surface.SetMaterial(LMat)
  131.         surface.DrawTexturedRect(LicenseW+75, LicenseH+CS+2, 12, 12)   
  132.        
  133.         local LMat = NoLMat
  134.         if LP:HasDLicense(i) then
  135.             LMat = HasLMat
  136.         end
  137.         surface.SetMaterial(LMat)
  138.         surface.DrawTexturedRect(LicenseW+116, LicenseH+CS+2, 12, 12)  
  139.                
  140.         DIS = DIS + 25
  141.         CS = CS + 25
  142.     end
  143. end
  144.  
  145. hook.Add("PostDrawTranslucentRenderables", "DrawDICards", function()
  146.     local LPlayer = LocalPlayer()
  147.     for k,v in pairs(player.GetAll()) do
  148.         local CurWep = v:GetActiveWeapon()
  149.         if v != LPlayer and IsValid(CurWep) and v:GetActiveWeapon():GetClass() == "driving_license" and v:HasWeapon("driving_license") then
  150.             if LPlayer:GetPos():Distance(v:GetPos()) < 600 then
  151.                 local boneindex = v:LookupBone("ValveBiped.Bip01_R_Hand")
  152.                 local PonyOverride = false
  153.                 if !boneindex then
  154.                     boneindex = v:LookupBone("LrigNeck1")
  155.                     PonyOverride = true
  156.                 end
  157.                 if boneindex then  
  158.                     if !v.PIcon then
  159.                         v.PIcon = vgui.Create( "ModelImage")
  160.                         v.PIcon:SetSize(90,93)
  161.                         v.PIcon:SetModel(v:GetModel())
  162.                     else
  163.                         v.PIcon:SetModel(v:GetModel())
  164.                     end
  165.                    
  166.                     local HPos, HAng = v:GetBonePosition(boneindex)
  167.                    
  168.                     if !PonyOverride then
  169.                         HAng:RotateAroundAxis(HAng:Forward(), -90)
  170.                         HAng:RotateAroundAxis(HAng:Right(), -90)
  171.                         HAng:RotateAroundAxis(HAng:Up(), 5)
  172.                         HPos = HPos + HAng:Up()*4 + HAng:Right()*-5 + HAng:Forward()*1
  173.                     else
  174.                         HAng:RotateAroundAxis(HAng:Forward(), -90)
  175.                         HAng:RotateAroundAxis(HAng:Right(), -30)
  176.                         HAng:RotateAroundAxis(HAng:Up(), -90)
  177.                         HPos = HPos + HAng:Up()*6 + HAng:Forward()*-7          
  178.                     end
  179.                    
  180.                     cam.Start3D2D(HPos, HAng, 1)
  181.                         surface.SetMaterial(DIMat)
  182.                         surface.SetDrawColor(255, 255, 255, 255)
  183.                         surface.DrawTexturedRect(0, 0, 15, 8)
  184.                     cam.End3D2D()
  185.                     cam.Start3D2D(HPos, HAng, .05)
  186.                         v.PIcon:SetPos(12,45)
  187.                         v.PIcon:SetPaintedManually(false)
  188.                         v.PIcon:PaintManual()
  189.                         v.PIcon:SetPaintedManually(true)                   
  190.                        
  191.                         local TextW = 80
  192.                         local TextH = 60
  193.                        
  194.                         draw.SimpleText(v:Nick(), "driving_license_text", TextW, TextH, Color( 0, 0, 0, 255 ), TEXT_ALIGN_LEFT, TEXT_ALIGN_CENTER )
  195.                         if DI_Config.DisplaySteamID then
  196.                             TextH = TextH + 10
  197.                             draw.SimpleText(v:SteamID(), "driving_license_text", TextW, TextH, Color( 0, 0, 0, 255 ), TEXT_ALIGN_LEFT, TEXT_ALIGN_CENTER )
  198.                         end
  199.                         if DI_Config.DisplayJob then
  200.                             TextH = TextH + 10
  201.                             draw.SimpleText(v:getDarkRPVar("job"), "driving_license_text", TextW, TextH, Color( 0, 0, 0, 255 ), TEXT_ALIGN_LEFT, TEXT_ALIGN_CENTER )
  202.                         end
  203.                         TextH = TextH + 25
  204.                         draw.SimpleText(LangTbl.Instructor .. ":", "driving_license_text", TextW, TextH, Color( 0, 0, 0, 255 ), TEXT_ALIGN_LEFT, TEXT_ALIGN_CENTER )
  205.                        
  206.                         local LMat = NoLMat
  207.                         if v:IsDInstructor() then
  208.                             LMat = HasLMat
  209.                         end
  210.                         surface.SetFont("driving_license_text")
  211.                         local TW, TH = surface.GetTextSize(LangTbl.Instructor .. ":")  
  212.                        
  213.                         surface.SetMaterial(LMat)
  214.                         surface.DrawTexturedRect(TextW+TW+5, TextH-2.5, 10, 10)                
  215.                        
  216.                         local LicenseW = 225
  217.                         local DIS = 35
  218.                         local CS = 40
  219.                         for i,n in ipairs(DI_DB) do
  220.                             draw.SimpleText(n.Name, "driving_license_text", LicenseW, DIS+10, Color( 0, 0, 0, 255 ), TEXT_ALIGN_RIGHT, TEXT_ALIGN_CENTER )
  221.                            
  222.                             surface.SetMaterial(MatTbl[i])
  223.                             surface.DrawTexturedRect(LicenseW+5, DIS, 40, 20)
  224.                            
  225.                             local LMat = NoLMat
  226.                             if v:HasDLicense(i) then
  227.                                 LMat = HasLMat
  228.                             end
  229.                             surface.SetMaterial(LMat)
  230.                             surface.DrawTexturedRect(LicenseW+50, CS, 12, 12)  
  231.                             DIS = DIS + 20
  232.                             CS = CS + 20
  233.                         end
  234.                     cam.End3D2D()
  235.                 end
  236.             end
  237.         end
  238.     end
  239. end)
  240. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement