Advertisement
Guest User

Default

a guest
Apr 23rd, 2019
87
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.63 KB | None | 0 0
  1. local Keys = {
  2. ["ESC"] = 322, ["F1"] = 288, ["F2"] = 289, ["F3"] = 170, ["F5"] = 166, ["F6"] = 167, ["F7"] = 168, ["F8"] = 169, ["F9"] = 56, ["F10"] = 57,
  3. ["~"] = 243, ["1"] = 157, ["2"] = 158, ["3"] = 160, ["4"] = 164, ["5"] = 165, ["6"] = 159, ["7"] = 161, ["8"] = 162, ["9"] = 163, ["-"] = 84, ["="] = 83, ["BACKSPACE"] = 177,
  4. ["TAB"] = 37, ["Q"] = 44, ["W"] = 32, ["E"] = 38, ["R"] = 45, ["T"] = 245, ["Y"] = 246, ["U"] = 303, ["P"] = 199, ["["] = 39, ["]"] = 40, ["ENTER"] = 18,
  5. ["CAPS"] = 137, ["A"] = 34, ["S"] = 8, ["D"] = 9, ["F"] = 23, ["G"] = 47, ["H"] = 74, ["K"] = 311, ["L"] = 182,
  6. ["LEFTSHIFT"] = 21, ["Z"] = 20, ["X"] = 73, ["C"] = 26, ["V"] = 0, ["B"] = 29, ["N"] = 249, ["M"] = 244, [","] = 82, ["."] = 81,
  7. ["LEFTCTRL"] = 36, ["LEFTALT"] = 19, ["SPACE"] = 22, ["RIGHTCTRL"] = 70,
  8. ["HOME"] = 213, ["PAGEUP"] = 10, ["PAGEDOWN"] = 11, ["DELETE"] = 178,
  9. ["LEFT"] = 174, ["RIGHT"] = 175, ["TOP"] = 27, ["DOWN"] = 173,
  10. ["NENTER"] = 201, ["N4"] = 108, ["N5"] = 60, ["N6"] = 107, ["N+"] = 96, ["N-"] = 97, ["N7"] = 117, ["N8"] = 61, ["N9"] = 118
  11. }
  12. local idVisable = nil
  13. local jobVisable = nil
  14. ESX = nil
  15.  
  16. Citizen.CreateThread(function()
  17. while ESX == nil do
  18. TriggerEvent('esx:getSharedObject', function(obj) ESX = obj end)
  19. Citizen.Wait(0)
  20. end
  21.  
  22. Citizen.Wait(2000)
  23. ESX.TriggerServerCallback('esx_scoreboard:getConnectedPlayers', function(connectedPlayers)
  24. UpdatePlayerTable(connectedPlayers)
  25. end)
  26. end)
  27.  
  28. Citizen.CreateThread(function()
  29. Citizen.Wait(500)
  30. SendNUIMessage({
  31. action = 'updateServerInfo',
  32. maxPlayers = Config.MaxPlayers,
  33. uptime = 'unknown',
  34. playTime = '00h 00m'
  35. })
  36. end)
  37.  
  38. RegisterNetEvent('esx_scoreboard:updateConnectedPlayers')
  39. AddEventHandler('esx_scoreboard:updateConnectedPlayers', function(connectedPlayers)
  40. UpdatePlayerTable(connectedPlayers)
  41. end)
  42.  
  43. RegisterNetEvent('esx_scoreboard:updatePing')
  44. AddEventHandler('esx_scoreboard:updatePing', function(connectedPlayers)
  45. SendNUIMessage({
  46. action = 'updatePing',
  47. players = connectedPlayers
  48. })
  49. end)
  50.  
  51. RegisterNetEvent('esx_scoreboard:toggleID')
  52. AddEventHandler('esx_scoreboard:toggleID', function(state)
  53. if state == 'true' then
  54. idVisable = true
  55. elseif state == 'false' then
  56. idVisable = false
  57. else
  58. idVisable = false
  59. end
  60. SendNUIMessage({
  61. action = 'toggleID',
  62. state = idVisable
  63. })
  64. end)
  65.  
  66. RegisterNetEvent('uptime:tick')
  67. AddEventHandler('uptime:tick', function(uptime)
  68. SendNUIMessage({
  69. action = 'updateServerInfo',
  70. uptime = uptime
  71. })
  72. end)
  73.  
  74. RegisterNetEvent('esx_scoreboard:toggleJob')
  75. AddEventHandler('esx_scoreboard:toggleJob', function(state)
  76. if state == 'true' then
  77. jobVisable = true
  78. elseif state == 'false' then
  79. jobVisable = false
  80. else
  81. jobVisable = false
  82. end
  83. SendNUIMessage({
  84. action = 'toggleJob',
  85. state = jobVisable
  86. })
  87. end)
  88.  
  89. function UpdatePlayerTable(connectedPlayers)
  90. local formattedPlayerList = {}
  91. local ems, police, taxi, mechanic, mafia, biker, players = 0, 0, 0, 0, 0, 0, 0
  92.  
  93. for k,v in pairs(connectedPlayers) do
  94. --lunkloafgrumble added
  95. -- TriggerServerEvent("scoreboard:sendid", v.id)
  96. -- Citizen.Wait(1000)
  97. -- RegisterNetEvent("scoreboard:getname")
  98. -- AddEventHandler("scoreboard:getname", function(name)
  99. -- table.insert(formattedPlayerList, ('<tr><td>%s</td><td class="pid">%s</td><td class="sjob">%s</td><td class="ping">%s</td></tr>'):format(name, v.id, v.jobLabel, v.ping))
  100. -- end)
  101. table.insert(formattedPlayerList, ('<tr><td>%s</td><td class="pid">%s</td><td class="sjob">%s</td><td class="ping">%s</td></tr>'):format(v.name, v.id, v.jobLabel, v.ping))
  102. -- end
  103. players = players + 1
  104.  
  105. if v.job == 'ambulance' then
  106. ems = ems + 1
  107. elseif v.job == 'police' then
  108. police = police + 1
  109. elseif v.job == 'taxi' then
  110. taxi = taxi + 1
  111. elseif v.job == 'mechanic' then
  112. mechanic = mechanic + 1
  113. elseif v.job == 'mafia' then
  114. mafia = mafia + 1
  115. elseif v.job == 'biker' then
  116. biker = biker + 1
  117. end
  118. end
  119.  
  120. SendNUIMessage({
  121. action = 'updatePlayerList',
  122. players = table.concat(formattedPlayerList)
  123. })
  124.  
  125. SendNUIMessage({
  126. action = 'updatePlayerJobs',
  127. jobs = {ems = ems, police = police, taxi = taxi, mechanic = mechanic, mafia = mafia, biker = biker, player_count = players}
  128. })
  129.  
  130. SendNUIMessage({
  131. action = 'toggleID',
  132. state = idVisable
  133. })
  134.  
  135. SendNUIMessage({
  136. action = 'toggleJob',
  137. state = jobVisable
  138. })
  139. end
  140.  
  141. Citizen.CreateThread(function()
  142. while true do
  143. Citizen.Wait(0)
  144. if IsControlJustPressed(0, Keys['DELETE']) and IsInputDisabled(0) then
  145. ToggleScoreBoard()
  146. Citizen.Wait(200)
  147. elseif IsControlJustReleased(0, Keys['DELETE']) then
  148. SendNUIMessage({
  149. action = 'close'
  150. })
  151. end
  152.  
  153. if IsControlJustPressed(0, 172) then
  154. SendNUIMessage({
  155. action = 'scroll',
  156. scroll = "up"
  157. })
  158. elseif IsControlJustPressed(0, 173) then
  159. SendNUIMessage({
  160. action = 'scroll',
  161. scroll = "down"
  162. })
  163. end
  164. end
  165. end)
  166.  
  167. Citizen.CreateThread(function()
  168. while true do
  169. Citizen.Wait(300)
  170.  
  171. if IsPauseMenuActive() and not IsPaused then
  172. IsPaused = true
  173. SendNUIMessage({
  174. action = 'close'
  175. })
  176. elseif not IsPauseMenuActive() and IsPaused then
  177. IsPaused = false
  178. end
  179. end
  180. end)
  181.  
  182. function ToggleScoreBoard()
  183. SendNUIMessage({
  184. action = 'toggle'
  185. })
  186. end
  187.  
  188. Citizen.CreateThread(function()
  189. local playMinute, playHour = 0, 0
  190.  
  191. while true do
  192. Citizen.Wait(1000 * 60) -- every minute
  193. playMinute = playMinute + 1
  194.  
  195. if playMinute == 60 then
  196. playMinute = 0
  197. playHour = playHour + 1
  198. end
  199.  
  200. SendNUIMessage({
  201. action = 'updateServerInfo',
  202. playTime = string.format("%02dh %02dm", playHour, playMinute)
  203. })
  204. end
  205. end)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement