Advertisement
Guest User

Untitled

a guest
Jun 28th, 2017
83
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 12.65 KB | None | 0 0
  1. /*-----------------------------------------------------------
  2. In-Game Scoreboard
  3.  
  4. Copyright © 2017 Patryk (Paxon57) Chruśniak
  5. All Rights Reserved
  6. -------------------------------------------------------------*/
  7.  
  8. include("shared.lua")
  9. include("config.lua")
  10. include("scoreboard_fonts.lua")
  11.  
  12. local joinTime = CurTime()
  13. local hUpTime = 0
  14. local mUpTime = 0
  15. local Connected = player.GetAll()
  16.  
  17. local MaxScroll = math.Clamp(#Connected - 6,0,200)
  18. local AScroll = -MaxScroll
  19. local CurScroll = 0
  20.  
  21. local AutoScroll = paxsbcfg.AutoScroll
  22. local UseKey = false
  23.  
  24. local SortMode = 1
  25. local Inverted = false
  26.  
  27. local function stringtime(time)
  28. if time >= 60 and time % 60 == 0 then
  29. hUpTime = math.floor(time / 3600)
  30. mUpTime = (time-(hUpTime*3600)) / 60
  31. end
  32. if hUpTime==1 then return tostring(hUpTime).." hour, "..tostring(mUpTime).." minutes!" end
  33. return tostring(hUpTime).." heures, "..tostring(mUpTime).." minutes!"
  34. end
  35.  
  36. hook.Add( "KeyPress", "paxsb_keypressuse", function( ply, key )
  37. if !timer.Exists("waitforit") and ( key == IN_USE ) then
  38. UseKey = true
  39. timer.Create("waitforit",0.1, 1, function()end)
  40. end
  41. end )
  42.  
  43. --function ENT:Initialize()
  44. -- local scale = Vector( 0.1, 1, 1 )
  45.  
  46. -- local mat = Matrix()
  47. -- mat:Scale( scale )
  48. -- self:EnableMatrix( "RenderMultiply", mat )
  49. --end
  50.  
  51. function ENT:Draw()
  52.  
  53. self:DrawModel()
  54.  
  55. local function GetCursorPos()
  56. local cursorpos = util.IntersectRayWithPlane(LocalPlayer():EyePos(),LocalPlayer():GetAimVector(),self:GetPos(),self:GetUp())
  57. if not isvector(cursorpos) then return Vector(0,0,0) end
  58.  
  59. local m1 = self:GetBoneMatrix(0)
  60. local m2 = Matrix()
  61. m2:SetTranslation(cursorpos)
  62. local mlocal = m1:GetInverseTR()*m2
  63. cursorpos = mlocal:GetTranslation()
  64. cursorpos = cursorpos + Vector(145,150,0)
  65. cursorpos = Vector(0, cursorpos.y, cursorpos.x)
  66. return cursorpos
  67. end
  68.  
  69. local cursorpos = GetCursorPos()
  70.  
  71. local Connected = player.GetAll()
  72. local GroupConnected = Connected
  73. local MaxScroll = math.Clamp(#Connected - 6,0,200)
  74. --------------------------------------------------------------------------------------------------------------
  75. if UseKey == true then
  76. --AutoScrollSwitch
  77. if cursorpos.y >= 51.5 and cursorpos.y <= 61.5 and cursorpos.z >= 110 and cursorpos.z <= 120 then
  78. if AutoScroll == true then
  79. AutoScroll = false
  80. else
  81. AutoScroll = true
  82. end
  83. --Scroll Up
  84. elseif cursorpos.y >= 65.6 and cursorpos.y <= 74.6 and cursorpos.z >= 105.5 and cursorpos.z <= 114.5 then
  85. CurScroll = CurScroll - 1
  86. if CurScroll < 0 then CurScroll = 0 end
  87. --Scroll Down
  88. elseif cursorpos.y >= 65.6 and cursorpos.y <= 74.6 and cursorpos.z >= 115.5 and cursorpos.z <= 124.5 then
  89. CurScroll = CurScroll + 1
  90. if CurScroll > MaxScroll then CurScroll = MaxScroll end
  91. --Srting Modes
  92. elseif cursorpos.y >= 86.3 and cursorpos.y <= 106.3 and cursorpos.z >= 20.5 and cursorpos.z <= 33.5 then
  93.  
  94. if SortMode == 0 and !Inverted then
  95. Inverted = true
  96. elseif SortMode == 0 and Inverted then
  97. Inverted = false
  98. else
  99. SortMode = 0
  100. Inverted = false
  101. end
  102.  
  103. elseif cursorpos.y >= 204 and cursorpos.y <= 226 and cursorpos.z >= 20.5 and cursorpos.z <= 33.5 then
  104. if SortMode == 1 and !Inverted then
  105. Inverted = true
  106. elseif SortMode == 1 and Inverted then
  107. Inverted = false
  108. else
  109. SortMode = 1
  110. Inverted = false
  111. end
  112.  
  113. elseif cursorpos.y >= 230 and cursorpos.y <= 246 and cursorpos.z >= 20.5 and cursorpos.z <= 33.5 then
  114. if SortMode == 2 and !Inverted then
  115. Inverted = true
  116. elseif SortMode == 2 and Inverted then
  117. Inverted = false
  118. else
  119. SortMode = 2
  120. Inverted = false
  121. end
  122.  
  123. elseif cursorpos.y >= 248.5 and cursorpos.y <= 273.5 and cursorpos.z >= 20.5 and cursorpos.z <= 33.5 then
  124. if SortMode == 3 and !Inverted then
  125. Inverted = true
  126. elseif SortMode == 3 and Inverted then
  127. Inverted = false
  128. else
  129. SortMode = 3
  130. Inverted = false
  131. end
  132.  
  133. elseif cursorpos.y >= 277.5 and cursorpos.y <= 294.5 and cursorpos.z >= 20.5 and cursorpos.z <= 33.5 then
  134. if SortMode == 4 and !Inverted then
  135. Inverted = true
  136. elseif SortMode == 4 and Inverted then
  137. Inverted = false
  138. else
  139. SortMode = 4
  140. Inverted = false
  141. end
  142. end
  143. UseKey = false
  144. end
  145. -------------------------------------------------------------------------------------------------------------
  146.  
  147. if SortMode == 0 then
  148. if !Inverted then
  149. table.sort(Connected, function(a,b) return a:Name() > b:Name() end )
  150. else
  151. table.sort(Connected, function(a,b) return a:Name() < b:Name() end )
  152. end
  153. elseif SortMode == 2 then
  154. if !Inverted then
  155. table.sort(Connected, function(a,b) return a:Frags() > b:Frags() end )
  156. else
  157. table.sort(Connected, function(a,b) return a:Frags() < b:Frags() end )
  158. end
  159. elseif SortMode == 3 then
  160. if !Inverted then
  161. table.sort(Connected, function(a,b) return a:Deaths() > b:Deaths() end )
  162. else
  163. table.sort(Connected, function(a,b) return a:Deaths() < b:Deaths() end )
  164. end
  165. elseif SortMode == 4 then
  166. if !Inverted then
  167. table.sort(Connected, function(a,b) return a:Ping() < b:Ping() end )
  168. else
  169. table.sort(Connected, function(a,b) return a:Ping() > b:Ping() end )
  170. end
  171. end
  172.  
  173. if AutoScroll == true then
  174. if !timer.Exists("scroll") then
  175. timer.Create("scroll", 1.5, 1, function()
  176. CurScroll = math.abs(AScroll)
  177. AScroll = AScroll + 1
  178. if AScroll >= MaxScroll then AScroll = -MaxScroll end
  179. end)
  180. end
  181. end
  182.  
  183. local uptime = math.Round(CurTime() - joinTime)
  184. uptime = uptime * 180
  185. local time = SysTime()
  186.  
  187. self:SetRenderBounds(Vector(-150,-150,-1),Vector(150,150,1))
  188. self:DrawModel()
  189.  
  190. local pos = self:GetPos() + self:GetForward()*-144 + self:GetUp()*1 + self:GetRight()*150
  191. local ang = self:GetAngles()
  192. ang:RotateAroundAxis(self:GetUp(),-90)
  193. ang:RotateAroundAxis(self:GetRight(),180)
  194. ang:RotateAroundAxis(self:GetForward(),180)
  195. cam.Start3D2D(pos,ang,0.1)
  196.  
  197. draw.RoundedBox(25,0,0,3000,1500,paxsbcfg.Color)
  198.  
  199. draw.RoundedBox(15,15,15,2970,140,Color(paxsbcfg.Color.r + 15,paxsbcfg.Color.g + 15,paxsbcfg.Color.b + 15))
  200. draw.RoundedBox(15,15,180,800,320,Color(paxsbcfg.Color.r + 25,paxsbcfg.Color.g + 25,paxsbcfg.Color.b + 25))
  201. draw.RoundedBox(15,15,520,800,500,Color(paxsbcfg.Color.r + 35,paxsbcfg.Color.g + 35,paxsbcfg.Color.b + 35))
  202. draw.RoundedBox(15,835,175,2145,1310,Color(paxsbcfg.Color.r + 45,paxsbcfg.Color.g + 45,paxsbcfg.Color.b + 45))
  203. draw.RoundedBox(15,15,1285,800,200,Color(paxsbcfg.Color.r + 15,paxsbcfg.Color.g + 15,paxsbcfg.Color.b + 15))
  204. draw.RoundedBox(15,15,1050,800,200,Color(paxsbcfg.Color.r + 25,paxsbcfg.Color.g + 25,paxsbcfg.Color.b + 25))
  205. ----ARROWS
  206. draw.RoundedBox(15,15,1050,800,200,Color(paxsbcfg.Color.r + 25,paxsbcfg.Color.g + 25,paxsbcfg.Color.b + 25))
  207. draw.RoundedBox(15,656,1055,90,90,paxsbcfg.Color)
  208. draw.RoundedBox(15,656,1155,90,90,paxsbcfg.Color)
  209.  
  210. if AutoScroll == true then
  211. draw.RoundedBox(15,515,1100,100,100,paxsbcfg.FontColor)
  212. else
  213. draw.RoundedBox(15,515,1100,100,100,paxsbcfg.FontColor)
  214. draw.RoundedBox(15,525,1110,80,80,Color(paxsbcfg.Color.r + 25,paxsbcfg.Color.g + 25,paxsbcfg.Color.b + 25))
  215. end
  216.  
  217. draw.SimpleText("Bienvenue, "..LocalPlayer():GetName(),"paxwelcome",50,25,paxsbcfg.FontColor,TEXT_ALIGN_LEFT,TEXT_ALIGN_TOP)
  218. draw.SimpleText("Joueurs en ligne:","paxwelcome",415,570,paxsbcfg.FontColor,TEXT_ALIGN_CENTER,TEXT_ALIGN_TOP)
  219. draw.SimpleText(tostring(#Connected).."/"..tostring(game.MaxPlayers()),"paxplayers",415,770,paxsbcfg.FontColor,TEXT_ALIGN_CENTER,TEXT_ALIGN_TOP)
  220. draw.SimpleText("Serveur: ","paxdata",415,200,paxsbcfg.FontColor,TEXT_ALIGN_CENTER,TEXT_ALIGN_TOP)
  221. draw.SimpleText(GetHostName(),"paxservername",415,270,paxsbcfg.FontColor,TEXT_ALIGN_CENTER,TEXT_ALIGN_TOP)
  222. draw.SimpleText("Gamemode: "..tostring(gmod.GetGamemode().Name),"paxdata",415,340,paxsbcfg.FontColor,TEXT_ALIGN_CENTER,TEXT_ALIGN_TOP)
  223. draw.SimpleText("Map: "..game.GetMap(),"paxdata",415,410,paxsbcfg.FontColor,TEXT_ALIGN_CENTER,TEXT_ALIGN_TOP)
  224. draw.SimpleText("En ligne depuis: "..stringtime(uptime),"paxwelcome",2975,25,paxsbcfg.FontColor,TEXT_ALIGN_RIGHT,TEXT_ALIGN_TOP)
  225. draw.SimpleText("AutoScroll","paxwelcome",50,1150,paxsbcfg.FontColor,TEXT_ALIGN_LEFT,TEXT_ALIGN_CENTER)
  226. draw.SimpleText("˄","paxclock",700,1090,paxsbcfg.FontColor,TEXT_ALIGN_CENTER,TEXT_ALIGN_CENTER)
  227. draw.SimpleText("˅","paxclock",700,1190,paxsbcfg.FontColor,TEXT_ALIGN_CENTER,TEXT_ALIGN_CENTER)
  228. draw.SimpleText(os.date( "%H:%M:%S" , os.time() ),"paxclock",415,1385,paxsbcfg.FontColor,TEXT_ALIGN_CENTER,TEXT_ALIGN_CENTER)
  229.  
  230. draw.RoundedBox(15,850,190,2115,160,Color(paxsbcfg.Color.r + 15,paxsbcfg.Color.g + 15,paxsbcfg.Color.b + 15))
  231.  
  232. ---Sort
  233. if SortMode == 0 then
  234. draw.RoundedBox(15,863,205,200,130,Color(paxsbcfg.Color.r + 35,paxsbcfg.Color.g + 35,paxsbcfg.Color.b + 35))
  235. elseif SortMode == 1 and paxsbcfg.GroupOrJob == 0 then
  236. draw.RoundedBox(15,2040,205,220,130,Color(paxsbcfg.Color.r + 35,paxsbcfg.Color.g + 35,paxsbcfg.Color.b + 35))
  237. elseif SortMode == 1 and paxsbcfg.GroupOrJob == 1 then
  238. draw.RoundedBox(15,2115,205,150,130,Color(paxsbcfg.Color.r + 35,paxsbcfg.Color.g + 35,paxsbcfg.Color.b + 35))
  239. elseif SortMode == 2 then
  240. draw.RoundedBox(15,2300,205,160,130,Color(paxsbcfg.Color.r + 35,paxsbcfg.Color.g + 35,paxsbcfg.Color.b + 35))
  241. elseif SortMode == 3 then
  242. draw.RoundedBox(15,2485,205,250,130,Color(paxsbcfg.Color.r + 35,paxsbcfg.Color.g + 35,paxsbcfg.Color.b + 35))
  243. elseif SortMode == 4 then
  244. draw.RoundedBox(15,2775,205,170,130,Color(paxsbcfg.Color.r + 35,paxsbcfg.Color.g + 35,paxsbcfg.Color.b + 35))
  245. end
  246.  
  247. draw.SimpleText("Nom","paxplyinfo",865,225,paxsbcfg.FontColor,TEXT_ALIGN_LEFT,TEXT_ALIGN_TOP)
  248. if paxsbcfg.GroupOrJob == 0 then
  249. draw.SimpleText("Groupe","paxplyinfo",2250,225,paxsbcfg.FontColor,TEXT_ALIGN_RIGHT,TEXT_ALIGN_TOP)
  250. else
  251. draw.SimpleText("Job","paxplyinfo",2250,225,paxsbcfg.FontColor,TEXT_ALIGN_RIGHT,TEXT_ALIGN_TOP)
  252. end
  253. draw.SimpleText("Ping","paxplyinfo",2935,225,paxsbcfg.FontColor,TEXT_ALIGN_RIGHT,TEXT_ALIGN_TOP)
  254. draw.SimpleText("Kills","paxplyinfo",2450,225,paxsbcfg.FontColor,TEXT_ALIGN_RIGHT,TEXT_ALIGN_TOP)
  255. draw.SimpleText("Deaths","paxplyinfo",2725,225,paxsbcfg.FontColor,TEXT_ALIGN_RIGHT,TEXT_ALIGN_TOP)
  256.  
  257. for i, v in pairs(Connected) do
  258. if i % 2 == 0 then
  259. paxPlayerTileColor = Color(paxsbcfg.Color.r + 15,paxsbcfg.Color.g + 15,paxsbcfg.Color.b + 15)
  260. else
  261. paxPlayerTileColor = Color(paxsbcfg.Color.r + 25,paxsbcfg.Color.g + 25,paxsbcfg.Color.b + 25)
  262. end
  263. if i > CurScroll and i <= 6 + CurScroll then
  264. draw.RoundedBox(15,850,190 + 180*(i-CurScroll),2115,160,paxPlayerTileColor)
  265. draw.SimpleText(v:GetName(),"paxplyinfo",865,230 + 180*(i-CurScroll),paxsbcfg.FontColor,TEXT_ALIGN_LEFT,TEXT_ALIGN_TOP)
  266. if paxsbcfg.GroupOrJob == 0 then
  267. draw.SimpleText(v:GetUserGroup(),"paxplyinfo",2250,230 + 180*(i-CurScroll),paxsbcfg.FontColor,TEXT_ALIGN_RIGHT,TEXT_ALIGN_TOP)
  268. else
  269. draw.SimpleText(v:getJobTable().name,"paxplyinfo",2250,230 + 180*(i-CurScroll),paxsbcfg.FontColor,TEXT_ALIGN_RIGHT,TEXT_ALIGN_TOP)
  270. end
  271. draw.SimpleText(v:Ping(),"paxplyinfo",2935,230 + 180*(i-CurScroll),paxsbcfg.FontColor,TEXT_ALIGN_RIGHT,TEXT_ALIGN_TOP)
  272. draw.SimpleText(v:Frags(),"paxplyinfo",2450,230 + 180*(i-CurScroll),paxsbcfg.FontColor,TEXT_ALIGN_RIGHT,TEXT_ALIGN_TOP)
  273. draw.SimpleText(v:Deaths(),"paxplyinfo",2725,230 + 180*(i-CurScroll),paxsbcfg.FontColor,TEXT_ALIGN_RIGHT,TEXT_ALIGN_TOP)
  274. end
  275. end
  276. cam.End3D2D()
  277. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement