Advertisement
Guest User

Untitled

a guest
May 19th, 2019
120
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.53 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.  
  13. ESX = nil
  14. local GUI = {}
  15. local HasAlreadyEnteredMarker = false
  16. local LastZone = nil
  17. GUI.Time = 0
  18. local CurrentAction = nil
  19. local CurrentActionMsg = ''
  20. local CurrentActionData = {}
  21.  
  22. Citizen.CreateThread(function()
  23. while ESX == nil do
  24. TriggerEvent('esx:getSharedObject', function(obj) ESX = obj end)
  25. Citizen.Wait(0)
  26. end
  27. end)
  28.  
  29. RegisterNetEvent("esx_blanchisseur:notify")
  30. AddEventHandler("esx_blanchisseur:notify", function(icon, type, sender, title, text)
  31. Citizen.CreateThread(function()
  32. Wait(1)
  33. SetNotificationTextEntry("STRING");
  34. AddTextComponentString(text);
  35. SetNotificationMessage(icon, icon, true, type, sender, title, text);
  36. DrawNotification(false, true);
  37. end)
  38. end)
  39.  
  40. function OpenBlanchisseurMenu()
  41.  
  42. local elements = { }
  43. table.insert(elements, {label = _U('wash'), value = 'wash_money'})
  44.  
  45. ESX.UI.Menu.CloseAll()
  46.  
  47. ESX.UI.Menu.Open(
  48. 'default', GetCurrentResourceName(), 'whitening',
  49. {
  50. title = _U('Notification'),
  51. align = 'top-left',
  52. elements = elements,
  53. },
  54.  
  55. function(data, menu)
  56.  
  57. if data.current.value == 'wash_money' then
  58.  
  59. ESX.UI.Menu.Open(
  60. 'dialog', GetCurrentResourceName(), 'wash_money_amount_',
  61. {
  62. title = _U('wash_money_amount')
  63. },
  64. function(data, menu)
  65.  
  66. local amount = tonumber(data.value)
  67.  
  68. if amount == nil then
  69. TriggerEvent("esx_blanchisseur:notify", "CHAR_LESTER_DEATHWISH", 1, _U('Notification'), false, _U('invalid_amount'))
  70. ESX.UI.Menu.CloseAll()
  71. else
  72. menu.close()
  73. TriggerServerEvent('esx_blanchisseur:washMoney', amount)
  74. ESX.UI.Menu.CloseAll()
  75. end
  76.  
  77. end,
  78. function(data, menu)
  79. menu.close()
  80. end
  81. )
  82.  
  83. end
  84. end,
  85. function(data, menu)
  86.  
  87. menu.close()
  88.  
  89. CurrentAction = 'whitening'
  90. CurrentActionData = { }
  91. end
  92. )
  93.  
  94. end
  95.  
  96. AddEventHandler('esx_blanchisseur:hasEnteredMarker', function(zone)
  97. CurrentAction = 'whitening'
  98. CurrentActionMsg = _U('press_menu')
  99. CurrentActionData = {zone = zone}
  100. end)
  101.  
  102. AddEventHandler('esx_blanchisseur:hasExitedMarker', function(zone)
  103. CurrentAction = nil
  104. TriggerServerEvent('esx_blanchisseur:stopWhitening')
  105. end)
  106.  
  107. Citizen.CreateThread(function()
  108. while true do
  109. Wait(0)
  110. local coords = GetEntityCoords(GetPlayerPed(-1))
  111. local isInMarker = false
  112. local currentZone = nil
  113.  
  114. for k,v in pairs(Config.Zones) do
  115. if(GetDistanceBetweenCoords(coords, v.x, v.y, v.z, true) < Config.MarkerSize.x / 2) then
  116. isInMarker = true
  117. currentZone = k
  118. percent = v.percent
  119. end
  120. end
  121.  
  122. if isInMarker and not HasAlreadyEnteredMarker then
  123. HasAlreadyEnteredMarker = true
  124. TriggerEvent('esx_blanchisseur:hasEnteredMarker', currentZone)
  125. end
  126. if not isInMarker and HasAlreadyEnteredMarker then
  127. HasAlreadyEnteredMarker = false
  128. TriggerEvent('esx_blanchisseur:hasExitedMarker', LastZone)
  129. end
  130. end
  131. end)
  132.  
  133. -- Create Blips
  134. if Config.Blip then
  135. Citizen.CreateThread(function ()
  136. for k,v in ipairs(Config.Zones)do
  137. local blip = AddBlipForCoord(v.x, v.y, v.z)
  138. SetBlipSprite (blip, 134)
  139. SetBlipDisplay(blip, 4)
  140. SetBlipScale (blip, 1.0)
  141. SetBlipColour (blip, 5)
  142. SetBlipAsShortRange(blip, true)
  143.  
  144. BeginTextCommandSetBlipName('STRING')
  145. AddTextComponentString(_U('blanchisseurblip'))
  146. EndTextCommandSetBlipName(blip)
  147. end
  148. end)
  149. end
  150.  
  151. -- Key Controls
  152. Citizen.CreateThread(function()
  153. while true do
  154. Citizen.Wait(0)
  155. if CurrentAction ~= nil then
  156.  
  157. SetTextComponentFormat('STRING')
  158. AddTextComponentString(CurrentActionMsg)
  159. DisplayHelpTextFromStringLabel(0, 0, 1, -1)
  160.  
  161. if IsControlJustReleased(0, 38) and (GetGameTimer() - GUI.Time) > 1000 then
  162. heure = tonumber(GetClockHours())
  163. GUI.Time = GetGameTimer()
  164.  
  165. if CurrentAction == 'whitening' then
  166. if Config.Hours then
  167. if heure > Config.openHours and heure < Config.closeHours then
  168. if Config.Menu then
  169. OpenBlanchisseurMenu()
  170. else
  171. TriggerServerEvent('esx_blanchisseur:startWhitening', percent)
  172. end
  173. else
  174. TriggerServerEvent('esx_blanchisseur:Nothere')
  175. end
  176. else
  177. if Config.Menu then
  178. OpenBlanchisseurMenu()
  179. else
  180. TriggerServerEvent('esx_blanchisseur:startWhitening', percent)
  181. end
  182. end
  183. end
  184.  
  185. CurrentAction = nil
  186. end
  187.  
  188. end
  189. end
  190. end)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement