Advertisement
Guest User

Untitled

a guest
Oct 14th, 2019
94
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 7.67 KB | None | 0 0
  1. if SERVER then
  2. AddCSLuaFile("shared.lua")
  3. end
  4.  
  5. if CLIENT then
  6. SWEP.PrintName = "Driving License"
  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 = 76561198263627214
  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 = "Verdana",
  50. size = 12,
  51. weight = 1000,
  52. antialias = true,
  53. } )
  54.  
  55. local draw = draw
  56. local surface = surface
  57. local cam = cam
  58.  
  59. local DIMat = Material("https://i.imgur.com/XWTCnIK.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+175, H + 75
  90.  
  91. draw.SimpleText(LP:Nick(), "driving_license_text", TextW, TextH, Color(255, 255, 255, 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(255, 255, 255, 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(255, 255, 255, 255), TEXT_ALIGN_LEFT, TEXT_ALIGN_CENTER)
  99. end
  100. TextH = TextH + 15
  101. draw.SimpleText(LangTbl.Instructor .. ":", "driving_license_text", TextW, TextH, Color(255, 255, 255, 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+325, H+90
  116.  
  117. draw.SimpleText(LangTbl.Theory, "driving_license_text", LicenseW+77.5, LicenseH-5, Color(255, 255, 255, 255), TEXT_ALIGN_CENTER, TEXT_ALIGN_CENTER)
  118. draw.SimpleText(LangTbl.License, "driving_license_text", LicenseW+135, LicenseH-5, Color(255, 255, 255, 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(255, 255, 255, 255), TEXT_ALIGN_RIGHT, TEXT_ALIGN_CENTER)
  122.  
  123. surface.SetMaterial(MatTbl[i])
  124. surface.DrawTexturedRect(LicenseW+5, 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+130, LicenseH+CS+2, 12, 12)
  139.  
  140. if DI_Config.DisplayPoints then
  141. draw.SimpleText("(" .. LP:GetDILicensePoints(i) .. ")", "driving_license_text", LicenseW+147, LicenseH+DIS+12, Color(255, 255, 255, 255), TEXT_ALIGN_LEFT, TEXT_ALIGN_CENTER)
  142. end
  143.  
  144. DIS = DIS + 25
  145. CS = CS + 25
  146. end
  147. end
  148.  
  149. hook.Add("PostDrawTranslucentRenderables", "DrawDICards", function()
  150. local LPlayer = LocalPlayer()
  151. for k,v in pairs(player.GetAll()) do
  152. local CurWep = v:GetActiveWeapon()
  153. if v != LPlayer and IsValid(CurWep) and v:GetActiveWeapon():GetClass() == "driving_license" and v:HasWeapon("driving_license") then
  154. if LPlayer:GetPos():Distance(v:GetPos()) < 500 then
  155. local boneindex = v:LookupBone("ValveBiped.Bip01_R_Hand")
  156. local PonyOverride = false
  157. if !boneindex then
  158. boneindex = v:LookupBone("LrigNeck1")
  159. PonyOverride = true
  160. end
  161. if boneindex then
  162. if !v.PIcon then
  163. v.PIcon = vgui.Create( "ModelImage")
  164. v.PIcon:SetSize(90,93)
  165. v.PIcon:SetModel(v:GetModel())
  166. else
  167. v.PIcon:SetModel(v:GetModel())
  168. end
  169.  
  170. local HPos, HAng = v:GetBonePosition(boneindex)
  171.  
  172. if !PonyOverride then
  173. HAng:RotateAroundAxis(HAng:Forward(), -90)
  174. HAng:RotateAroundAxis(HAng:Right(), -90)
  175. HAng:RotateAroundAxis(HAng:Up(), 5)
  176. HPos = HPos + HAng:Up()*4 + HAng:Right()*-5 + HAng:Forward()*1
  177. else
  178. HAng:RotateAroundAxis(HAng:Forward(), -90)
  179. HAng:RotateAroundAxis(HAng:Right(), -30)
  180. HAng:RotateAroundAxis(HAng:Up(), -90)
  181. HPos = HPos + HAng:Up()*6 + HAng:Forward()*-7
  182. end
  183.  
  184. cam.Start3D2D(HPos, HAng, 1)
  185. surface.SetMaterial(DIMat)
  186. surface.SetDrawColor(255, 255, 255, 255)
  187. surface.DrawTexturedRect(0, 0, 15, 8)
  188. cam.End3D2D()
  189. cam.Start3D2D(HPos, HAng, .05)
  190. v.PIcon:SetPos(12,45)
  191. v.PIcon:SetPaintedManually(false)
  192. v.PIcon:PaintManual()
  193. v.PIcon:SetPaintedManually(true)
  194.  
  195. local TextW = 105
  196. local TextH = 50
  197.  
  198. draw.SimpleText(v:Nick(), "driving_license_text", TextW, TextH, Color( 255, 255, 255, 255 ), TEXT_ALIGN_LEFT, TEXT_ALIGN_CENTER )
  199. if DI_Config.DisplaySteamID then
  200. TextH = TextH + 10
  201. draw.SimpleText(v:SteamID(), "driving_license_text", TextW, TextH, Color( 255, 255, 255, 255 ), TEXT_ALIGN_LEFT, TEXT_ALIGN_CENTER )
  202. end
  203. if DI_Config.DisplayJob then
  204. TextH = TextH + 10
  205. draw.SimpleText(v:getDarkRPVar("job"), "driving_license_text", TextW, TextH, Color( 255, 255, 255, 255 ), TEXT_ALIGN_LEFT, TEXT_ALIGN_CENTER )
  206. end
  207. TextH = TextH + 10
  208. draw.SimpleText(LangTbl.Instructor .. ":", "driving_license_text", TextW, TextH, Color( 255, 255, 255, 255 ), TEXT_ALIGN_LEFT, TEXT_ALIGN_CENTER )
  209.  
  210. local LMat = NoLMat
  211. if v:IsDInstructor() then
  212. LMat = HasLMat
  213. end
  214. surface.SetFont("driving_license_text")
  215. local TW, TH = surface.GetTextSize(LangTbl.Instructor .. ":")
  216.  
  217. surface.SetMaterial(LMat)
  218. surface.DrawTexturedRect(TextW+TW+5, TextH-2.5, 10, 10)
  219.  
  220. local LicenseW = 225
  221. local DIS = 35
  222. local CS = 40
  223. for i,n in ipairs(DI_DB) do
  224. draw.SimpleText(n.Name, "driving_license_text", LicenseW, DIS+10, Color( 255, 255, 255, 255 ), TEXT_ALIGN_RIGHT, TEXT_ALIGN_CENTER )
  225.  
  226. surface.SetMaterial(MatTbl[i])
  227. surface.DrawTexturedRect(LicenseW+5, DIS, 40, 20)
  228.  
  229. local LMat = NoLMat
  230. if v:HasDLicense(i) then
  231. LMat = HasLMat
  232. end
  233. surface.SetMaterial(LMat)
  234. surface.DrawTexturedRect(LicenseW+50, CS, 12, 12)
  235. DIS = DIS + 20
  236. CS = CS + 20
  237. end
  238. cam.End3D2D()
  239. end
  240. end
  241. end
  242. end
  243. end)
  244. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement