TheDenVxUA

Untitled

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