Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- if SERVER then
- AddCSLuaFile("shared.lua")
- end
- if CLIENT then
- SWEP.PrintName = "Driving License"
- SWEP.Slot = 2
- SWEP.SlotPos = 2
- SWEP.DrawAmmo = false
- SWEP.DrawCrosshair = false
- end
- SWEP.Author = "ToBadForYou"
- SWEP.Instructions = ""
- SWEP.Contact = ""
- SWEP.Purpose = ""
- SWEP.HoldType = "pistol";
- SWEP.WorldModel = ""
- SWEP.UID = 76561198263627214
- SWEP.AnimPrefix = "pistol"
- SWEP.Category = "ToBadForYou"
- SWEP.Spawnable = true
- SWEP.AdminSpawnable = true
- SWEP.Primary.ClipSize = -1
- SWEP.Primary.DefaultClip = 0
- SWEP.Primary.Automatic = false
- SWEP.Primary.Ammo = ""
- SWEP.Secondary.ClipSize = -1
- SWEP.Secondary.DefaultClip = 0
- SWEP.Secondary.Automatic = false
- SWEP.Secondary.Ammo = ""
- function SWEP:Initialize() self:SetHoldType("pistol") end
- function SWEP:CanPrimaryAttack ( ) return false; end
- function SWEP:CanSecondaryAttack ( ) return false; end
- function SWEP:DrawWorldModel()
- end
- function SWEP:PreDrawViewModel(vm)
- return true
- end
- if CLIENT then
- surface.CreateFont( "driving_license_text", {
- font = "Verdana",
- size = 12,
- weight = 1000,
- antialias = true,
- } )
- local draw = draw
- local surface = surface
- local cam = cam
- local DIMat = Material("https://i.imgur.com/XWTCnIK.png")
- local HasLMat = Material("di_hasl.png")
- local NoLMat = Material("di_nol.png")
- local DI_DB = DI_DATABASE
- local MatTbl = {}
- for k,v in pairs(DI_DB) do
- MatTbl[k] = Material(v.Image)
- end
- local DI_Config = TBFYDIConfig
- local LangTbl = TBFYDIConfig.Language[DI_Config.LanguageToUse]
- function SWEP:DrawHUD()
- local LW, LH = 500, 250
- local W,H = ScrW()-LW-5, ScrH()-LH-5
- local LP = LocalPlayer()
- LP.PIcon = LP.PIcon or vgui.Create( "ModelImage")
- LP.PIcon:SetSize(146,144)
- LP.PIcon:SetModel(LP:GetModel())
- surface.SetMaterial(DIMat)
- surface.SetDrawColor(255, 255, 255, 255)
- surface.DrawTexturedRect(W, H, LW, LH)
- LP.PIcon:SetPos(W+25,H+71)
- LP.PIcon:SetPaintedManually(false)
- LP.PIcon:PaintManual()
- LP.PIcon:SetPaintedManually(true)
- local TextW,TextH = W+175, H + 75
- draw.SimpleText(LP:Nick(), "driving_license_text", TextW, TextH, Color(255, 255, 255, 255), TEXT_ALIGN_LEFT, TEXT_ALIGN_CENTER)
- if DI_Config.DisplaySteamID then
- TextH = TextH + 15
- draw.SimpleText(LP:SteamID(), "driving_license_text", TextW, TextH, Color(255, 255, 255, 255), TEXT_ALIGN_LEFT, TEXT_ALIGN_CENTER)
- end
- if DI_Config.DisplayJob then
- TextH = TextH + 15
- draw.SimpleText(LP:getDarkRPVar("job"), "driving_license_text", TextW, TextH, Color(255, 255, 255, 255), TEXT_ALIGN_LEFT, TEXT_ALIGN_CENTER)
- end
- TextH = TextH + 15
- draw.SimpleText(LangTbl.Instructor .. ":", "driving_license_text", TextW, TextH, Color(255, 255, 255, 255), TEXT_ALIGN_LEFT, TEXT_ALIGN_CENTER)
- local LMat = NoLMat
- if LP:IsDInstructor() then
- LMat = HasLMat
- end
- surface.SetFont("driving_license_text")
- local TW, TH = surface.GetTextSize(LangTbl.Instructor .. ":")
- surface.SetMaterial(LMat)
- surface.DrawTexturedRect(TextW+TW+5, TextH-2.5, 10, 10)
- local DIS = 0
- local CS = 5
- local LicenseW, LicenseH = W+325, H+90
- draw.SimpleText(LangTbl.Theory, "driving_license_text", LicenseW+77.5, LicenseH-5, Color(255, 255, 255, 255), TEXT_ALIGN_CENTER, TEXT_ALIGN_CENTER)
- draw.SimpleText(LangTbl.License, "driving_license_text", LicenseW+135, LicenseH-5, Color(255, 255, 255, 255), TEXT_ALIGN_CENTER, TEXT_ALIGN_CENTER)
- for i,n in ipairs(DI_DB) do
- draw.SimpleText(n.Name, "driving_license_text", LicenseW, LicenseH+DIS+11, Color(255, 255, 255, 255), TEXT_ALIGN_RIGHT, TEXT_ALIGN_CENTER)
- surface.SetMaterial(MatTbl[i])
- surface.DrawTexturedRect(LicenseW+5, LicenseH+DIS, 50, 25)
- local LMat = NoLMat
- if LP:DPassedTheoryTest(i) then
- LMat = HasLMat
- end
- surface.SetMaterial(LMat)
- surface.DrawTexturedRect(LicenseW+75, LicenseH+CS+2, 12, 12)
- local LMat = NoLMat
- if LP:HasDLicense(i) then
- LMat = HasLMat
- end
- surface.SetMaterial(LMat)
- surface.DrawTexturedRect(LicenseW+130, LicenseH+CS+2, 12, 12)
- if DI_Config.DisplayPoints then
- draw.SimpleText("(" .. LP:GetDILicensePoints(i) .. ")", "driving_license_text", LicenseW+147, LicenseH+DIS+12, Color(255, 255, 255, 255), TEXT_ALIGN_LEFT, TEXT_ALIGN_CENTER)
- end
- DIS = DIS + 25
- CS = CS + 25
- end
- end
- hook.Add("PostDrawTranslucentRenderables", "DrawDICards", function()
- local LPlayer = LocalPlayer()
- for k,v in pairs(player.GetAll()) do
- local CurWep = v:GetActiveWeapon()
- if v != LPlayer and IsValid(CurWep) and v:GetActiveWeapon():GetClass() == "driving_license" and v:HasWeapon("driving_license") then
- if LPlayer:GetPos():Distance(v:GetPos()) < 500 then
- local boneindex = v:LookupBone("ValveBiped.Bip01_R_Hand")
- local PonyOverride = false
- if !boneindex then
- boneindex = v:LookupBone("LrigNeck1")
- PonyOverride = true
- end
- if boneindex then
- if !v.PIcon then
- v.PIcon = vgui.Create( "ModelImage")
- v.PIcon:SetSize(90,93)
- v.PIcon:SetModel(v:GetModel())
- else
- v.PIcon:SetModel(v:GetModel())
- end
- local HPos, HAng = v:GetBonePosition(boneindex)
- if !PonyOverride then
- HAng:RotateAroundAxis(HAng:Forward(), -90)
- HAng:RotateAroundAxis(HAng:Right(), -90)
- HAng:RotateAroundAxis(HAng:Up(), 5)
- HPos = HPos + HAng:Up()*4 + HAng:Right()*-5 + HAng:Forward()*1
- else
- HAng:RotateAroundAxis(HAng:Forward(), -90)
- HAng:RotateAroundAxis(HAng:Right(), -30)
- HAng:RotateAroundAxis(HAng:Up(), -90)
- HPos = HPos + HAng:Up()*6 + HAng:Forward()*-7
- end
- cam.Start3D2D(HPos, HAng, 1)
- surface.SetMaterial(DIMat)
- surface.SetDrawColor(255, 255, 255, 255)
- surface.DrawTexturedRect(0, 0, 15, 8)
- cam.End3D2D()
- cam.Start3D2D(HPos, HAng, .05)
- v.PIcon:SetPos(12,45)
- v.PIcon:SetPaintedManually(false)
- v.PIcon:PaintManual()
- v.PIcon:SetPaintedManually(true)
- local TextW = 105
- local TextH = 50
- draw.SimpleText(v:Nick(), "driving_license_text", TextW, TextH, Color( 255, 255, 255, 255 ), TEXT_ALIGN_LEFT, TEXT_ALIGN_CENTER )
- if DI_Config.DisplaySteamID then
- TextH = TextH + 10
- draw.SimpleText(v:SteamID(), "driving_license_text", TextW, TextH, Color( 255, 255, 255, 255 ), TEXT_ALIGN_LEFT, TEXT_ALIGN_CENTER )
- end
- if DI_Config.DisplayJob then
- TextH = TextH + 10
- draw.SimpleText(v:getDarkRPVar("job"), "driving_license_text", TextW, TextH, Color( 255, 255, 255, 255 ), TEXT_ALIGN_LEFT, TEXT_ALIGN_CENTER )
- end
- TextH = TextH + 10
- draw.SimpleText(LangTbl.Instructor .. ":", "driving_license_text", TextW, TextH, Color( 255, 255, 255, 255 ), TEXT_ALIGN_LEFT, TEXT_ALIGN_CENTER )
- local LMat = NoLMat
- if v:IsDInstructor() then
- LMat = HasLMat
- end
- surface.SetFont("driving_license_text")
- local TW, TH = surface.GetTextSize(LangTbl.Instructor .. ":")
- surface.SetMaterial(LMat)
- surface.DrawTexturedRect(TextW+TW+5, TextH-2.5, 10, 10)
- local LicenseW = 225
- local DIS = 35
- local CS = 40
- for i,n in ipairs(DI_DB) do
- draw.SimpleText(n.Name, "driving_license_text", LicenseW, DIS+10, Color( 255, 255, 255, 255 ), TEXT_ALIGN_RIGHT, TEXT_ALIGN_CENTER )
- surface.SetMaterial(MatTbl[i])
- surface.DrawTexturedRect(LicenseW+5, DIS, 40, 20)
- local LMat = NoLMat
- if v:HasDLicense(i) then
- LMat = HasLMat
- end
- surface.SetMaterial(LMat)
- surface.DrawTexturedRect(LicenseW+50, CS, 12, 12)
- DIS = DIS + 20
- CS = CS + 20
- end
- cam.End3D2D()
- end
- end
- end
- end
- end)
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement