Advertisement
Guest User

Untitled

a guest
Apr 23rd, 2019
197
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.45 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. RegisterNetEvent("scoreboard:getname")
  97. AddEventHandler("scoreboard:getname", function(name)
  98. 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))
  99. Citizen.Wait(1000)
  100. end)
  101. -- end
  102. players = players + 1
  103.  
  104. if v.job == 'ambulance' then
  105. ems = ems + 1
  106. elseif v.job == 'police' then
  107. police = police + 1
  108. elseif v.job == 'taxi' then
  109. taxi = taxi + 1
  110. elseif v.job == 'mechanic' then
  111. mechanic = mechanic + 1
  112. elseif v.job == 'mafia' then
  113. mafia = mafia + 1
  114. elseif v.job == 'biker' then
  115. biker = biker + 1
  116. end
  117. end
  118.  
  119. SendNUIMessage({
  120. action = 'updatePlayerList',
  121. players = table.concat(formattedPlayerList)
  122. })
  123.  
  124. SendNUIMessage({
  125. action = 'updatePlayerJobs',
  126. jobs = {ems = ems, police = police, taxi = taxi, mechanic = mechanic, mafia = mafia, biker = biker, player_count = players}
  127. })
  128.  
  129. SendNUIMessage({
  130. action = 'toggleID',
  131. state = idVisable
  132. })
  133.  
  134. SendNUIMessage({
  135. action = 'toggleJob',
  136. state = jobVisable
  137. })
  138. end
  139.  
  140. Citizen.CreateThread(function()
  141. while true do
  142. Citizen.Wait(0)
  143. if IsControlJustPressed(0, Keys['DELETE']) and IsInputDisabled(0) then
  144. ToggleScoreBoard()
  145. Citizen.Wait(200)
  146. elseif IsControlJustReleased(0, Keys['DELETE']) then
  147. SendNUIMessage({
  148. action = 'close'
  149. })
  150. end
  151.  
  152. if IsControlJustPressed(0, 172) then
  153. SendNUIMessage({
  154. action = 'scroll',
  155. scroll = "up"
  156. })
  157. elseif IsControlJustPressed(0, 173) then
  158. SendNUIMessage({
  159. action = 'scroll',
  160. scroll = "down"
  161. })
  162. end
  163. end
  164. end)
  165.  
  166. Citizen.CreateThread(function()
  167. while true do
  168. Citizen.Wait(300)
  169.  
  170. if IsPauseMenuActive() and not IsPaused then
  171. IsPaused = true
  172. SendNUIMessage({
  173. action = 'close'
  174. })
  175. elseif not IsPauseMenuActive() and IsPaused then
  176. IsPaused = false
  177. end
  178. end
  179. end)
  180.  
  181. function ToggleScoreBoard()
  182. SendNUIMessage({
  183. action = 'toggle'
  184. })
  185. end
  186.  
  187. Citizen.CreateThread(function()
  188. local playMinute, playHour = 0, 0
  189.  
  190. while true do
  191. Citizen.Wait(1000 * 60) -- every minute
  192. playMinute = playMinute + 1
  193.  
  194. if playMinute == 60 then
  195. playMinute = 0
  196. playHour = playHour + 1
  197. end
  198.  
  199. SendNUIMessage({
  200. action = 'updateServerInfo',
  201. playTime = string.format("%02dh %02dm", playHour, playMinute)
  202. })
  203. end
  204. end)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement