Advertisement
Guest User

Untitled

a guest
Nov 20th, 2019
9
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 4.76 KB | None | 0 0
  1. IsPaused = false
  2. ESX = nil
  3.  
  4. Citizen.CreateThread(function()
  5.   while ESX == nil do
  6.     TriggerEvent('esx:getSharedObject', function(obj) ESX = obj end)
  7.     Citizen.Wait(0)
  8.   end
  9. end)
  10.  
  11. -- CONFIG --
  12.  
  13. -- The watermark text --
  14. --servername = "Cops - 0\nTest - 2"
  15. jobs = {}
  16.  
  17. RegisterNetEvent('esx_jobCounter:set')
  18. AddEventHandler('esx_jobCounter:set', function(jobs_online)
  19.     --servername = jobs_online['police'].." - Cops".."\n"..
  20.     --           jobs_online['ambulance'].." - Sani".."\n"..
  21.     --           jobs_online['mechanic'].." - Meca".."\n"..
  22.     --           jobs_online['taxi'].." - Taxi"
  23.  
  24.     jobs = jobs_online
  25.  
  26.     if jobs['police'] < 1 then
  27.         cops_online = 'red'
  28.     elseif jobs['police'] < 5 then
  29.         cops_online = 'yellow'
  30.     elseif jobs['police'] >= 5 then
  31.         cops_online = 'green'
  32.     end
  33.  
  34.     if jobs['ambulance'] < 1 then
  35.         sani_online = 'red'
  36.     elseif jobs['ambulance'] < 5 then
  37.         sani_online = 'yellow'
  38.     elseif jobs['ambulance'] >= 5 then
  39.         sani_online = 'green'
  40.     end
  41.  
  42.     if jobs['mechanic'] < 1 then
  43.         meca_online = 'red'
  44.     elseif jobs['mechanic'] < 5 then
  45.         meca_online = 'yellow'
  46.     elseif jobs['mechanic'] >= 5 then
  47.         meca_online = 'green'
  48.     end
  49.  
  50.     if jobs['taxi'] < 1 then
  51.         taxi_online = 'red'
  52.     elseif jobs['taxi'] < 5 then
  53.         taxi_online = 'yellow'
  54.     elseif jobs['taxi'] >= 5 then
  55.         taxi_online = 'green'
  56.     end
  57.  
  58.     ESX.UI.HUD.UpdateElement('jobsCounter', {
  59.         cops = cops_online,
  60.         sani = sani_online,
  61.         meca = meca_online,
  62.         taxi = taxi_online
  63.     })
  64. end)
  65.  
  66. Citizen.CreateThread(function()
  67.     while true do
  68.         TriggerServerEvent('esx_jobCounter:get')
  69.  
  70.         Wait(30000)
  71.     end
  72. end)
  73.  
  74. --[[ The x and y offset (starting at the top left corner) --
  75. -- Default: 0.005, 0.001
  76. offset = {x = 0.005, y = 0.001}
  77.  
  78. -- Text RGB Color --
  79. -- Default: 64, 64, 64 (gray)
  80. rgb = {r = 164, g = 164, b = 164}
  81.  
  82. -- Text transparency --
  83. -- Default: 255
  84. alpha = 255
  85.  
  86. -- Text scale
  87. -- Default: 0.4
  88. -- NOTE: Number needs to be a float (so instead of 1 do 1.0)
  89. scale = 0.4
  90.  
  91. -- Text Font --
  92. -- 0 - 5 possible
  93. -- Default: 1
  94. font = 4
  95. ]]--
  96. function drawTxt(x,y ,width,height,scale, text, r,g,b,a, outline)
  97.     SetTextFont(0)
  98.     SetTextProportional(0)
  99.     SetTextScale(scale, scale)
  100.     SetTextColour(r, g, b, a)
  101.     SetTextDropShadow(0, 0, 0, 0,255)
  102.     SetTextEdge(1, 0, 0, 0, 255)
  103.     SetTextDropShadow()
  104.     if(outline)then
  105.         SetTextOutline()
  106.     end
  107.     SetTextEntry("STRING")
  108.     AddTextComponentString(text)
  109.     DrawText(x - width/2, y - height/2 + 0.005)
  110. end
  111. RegisterNetEvent('esx:playerLoaded')
  112. AddEventHandler('esx:playerLoaded', function(xPlayer)
  113.  
  114.     ESX.PlayerData = xPlayer
  115.     local jobsOnlineTpl = '<small style="font-size: 20px;">'..
  116.                            '<div style="border-radius: 100px; text-shadow: 2px 0 0 {{cops}}, 0 -2px 0 {{cops}}, 0 2px 0 {{cops}}, -2px 0 0 {{cops}};">πŸš“</div>'..
  117.                            '<div style="border-radius: 100px; text-shadow: 2px 0 0 {{sani}}, 0 -2px 0 {{sani}}, 0 2px 0 {{sani}}, -2px 0 0 {{sani}};">πŸš‘</div>'..
  118.                            '<div style="border-radius: 100px; text-shadow: 2px 0 0 {{meca}}, 0 -2px 0 {{meca}}, 0 2px 0 {{meca}}, -2px 0 0 {{meca}};">πŸ”§</div>'..
  119.                            '<div style="border-radius: 100px; text-shadow: 2px 0 0 {{taxi}}, 0 -2px 0 {{taxi}}, 0 2px 0 {{taxi}}, -2px 0 0 {{taxi}};">πŸš•</div>'..
  120.                            '</small>'
  121.  
  122.     ESX.UI.HUD.RegisterElement('jobsCounter', 20, 0, jobsOnlineTpl, {
  123.         cops = 0,
  124.         sani = 0,
  125.         meca = 0,
  126.         taxi = 0   
  127.     })
  128.  
  129.     if jobs['police'] < 1 then
  130.         cops_online = 'red'
  131.     elseif jobs['police'] < 5 then
  132.         cops_online = 'yellow'
  133.     elseif jobs['police'] >= 5 then
  134.         cops_online = 'green'
  135.     end
  136.  
  137.     if jobs['ambulance'] < 1 then
  138.         sani_online = 'red'
  139.     elseif jobs['ambulance'] < 5 then
  140.         sani_online = 'yellow'
  141.     elseif jobs['ambulance'] >= 5 then
  142.         sani_online = 'green'
  143.     end
  144.  
  145.     if jobs['mechanic'] < 1 then
  146.         meca_online = 'red'
  147.     elseif jobs['mechanic'] < 5 then
  148.         meca_online = 'yellow'
  149.     elseif jobs['mechanic'] >= 5 then
  150.         meca_online = 'green'
  151.     end
  152.  
  153.     if jobs['taxi'] < 1 then
  154.         taxi_online = 'red'
  155.     elseif jobs['taxi'] < 5 then
  156.         taxi_online = 'yellow'
  157.     elseif jobs['taxi'] >= 5 then
  158.         taxi_online = 'green'
  159.     end
  160.  
  161.     ESX.UI.HUD.UpdateElement('jobsCounter', {
  162.         cops = cops_online,
  163.         sani = sani_online,
  164.         meca = meca_online,
  165.         taxi = taxi_online
  166.     })
  167.  
  168. end)
  169.  
  170. Citizen.CreateThread(function()
  171.     while true do
  172.         Wait(200)
  173.  
  174.         drawTxt(0.66, 1.44, 1.0,1.0,0.4, 'text', 255, 255, 255, 255)
  175.    
  176.     end
  177.  
  178. end)
  179.  
  180. -- CODE --
  181. --[[
  182. Citizen.CreateThread(function()
  183.     while true do
  184.         Wait(1)
  185.  
  186.         SetTextColour(rgb.r, rgb.g, rgb.b, alpha)
  187.  
  188.         SetTextFont(font)
  189.         SetTextScale(scale, scale)
  190.         SetTextWrap(0.0, 1.0)
  191.         SetTextCentre(false)
  192.         SetTextDropshadow(2, 2, 0, 0, 0)
  193.         SetTextEdge(1, 0, 0, 0, 205)
  194.         SetTextEntry("STRING")
  195.         AddTextComponentString(servername)
  196.         DrawText(offset.x, offset.y)
  197.     end
  198. end)
  199. ]]--
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement