Advertisement
Guest User

Untitled

a guest
Jan 22nd, 2019
72
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.49 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. local menuIsShowed = false
  14. local hasEnteredMarker = false
  15. local isInMarker = false
  16.  
  17. ESX = nil
  18.  
  19. Citizen.CreateThread(function()
  20. while ESX == nil do
  21. TriggerEvent('esx:getSharedObject', function(obj) ESX = obj end)
  22. Citizen.Wait(0)
  23. end
  24. end)
  25.  
  26.  
  27.  
  28. AddEventHandler('esx_andreas_chef:hasExitedMarker', function(zone)
  29. ESX.UI.Menu.CloseAll()
  30. end)
  31.  
  32. --------------------------- CREATE MARKERS -----------------------------------
  33.  
  34. Citizen.CreateThread(function()
  35. while true do
  36. Citizen.Wait(1)
  37. local coords = GetEntityCoords(GetPlayerPed(-1))
  38. for i=1, #Config.Zones, 1 do
  39. if(GetDistanceBetweenCoords(coords, Config.Zones[i].x, Config.Zones[i].y, Config.Zones[i].z, true) < Config.DrawDistance) then
  40. DrawMarker(Config.MarkerType, Config.Zones[i].x, Config.Zones[i].y, Config.Zones[i].z, 0.0, 0.0, 0.0, 0, 0.0, 0.0, Config.ZonesSize.x, Config.ZonesSize.y, Config.ZonesSize.z, Config.MarkerColor.r, Config.MarkerColor.g, Config.MarkerColor.b, 100, false, true, 2, false, false, false, false)
  41. end
  42. end
  43. end
  44. end)
  45.  
  46. Citizen.CreateThread(function()
  47. while true do
  48. Citizen.Wait(1)
  49. local coords = GetEntityCoords(GetPlayerPed(-1))
  50. isInMarker = false
  51. local currentZone = nil
  52. for i=1, #Config.Zones, 1 do
  53. if(GetDistanceBetweenCoords(coords, Config.Zones[i].x, Config.Zones[i].y, Config.Zones[i].z, true) < Config.ZonesSize.x / 2) then
  54. isInMarker = true
  55. SetTextComponentFormat('STRING')
  56. AddTextComponentString('Tryck på ~INPUT_CONTEXT~ för att ')
  57. DisplayHelpTextFromStringLabel(0, 0, 1, -1)
  58. end
  59. end
  60. if isInMarker and not hasEnteredMarker then
  61. hasEnteredMarker = true
  62. end
  63. if not isInMarker and hasEnteredMarker then
  64. hasEnteredMarker = false
  65. TriggerEvent('esx_andreas_chef:hasExitedMarker')
  66. end
  67. end
  68. end)
  69.  
  70.  
  71. --------------------------------- KEY CONTROLS -------------------------------
  72.  
  73. Citizen.CreateThread(function()
  74. while true do
  75. Citizen.Wait(10)
  76. if IsControlJustReleased(0, Keys['E']) and isInMarker and not menuIsShowed then
  77. OpenChefMenu()
  78. end
  79. end
  80. end)
  81.  
  82. ------------------------------------FOODS ------------------------------------
  83.  
  84. RegisterNetEvent('esx_andreas_chef:cookHamburger')
  85. AddEventHandler('esx_andreas_chef:cookHamburger', function()
  86. ESX.TriggerServerCallback('esx_andreas_chef:checkHamburger', function(hasItem)
  87. if hasItem then
  88. TaskStartScenarioInPlace(GetPlayerPed(-1), "PROP_HUMAN_BBQ", 0, false)
  89. Citizen.Wait(5000)
  90. TriggerServerEvent('esx_andreas_chef:cookHamburger')
  91. else
  92. ESX.ShowNotification('You don/t have the ingredients needed')
  93. end
  94. end)
  95. end)
  96.  
  97. RegisterNetEvent('esx_andreas_chef:cookSteak')
  98. AddEventHandler('esx_andreas_chef:cookSteak', function()
  99. ESX.TriggerServerCallback('esx_andreas_chef:checkSteak', function(hasItem)
  100. if hasItem then
  101. TaskStartScenarioInPlace(GetPlayerPed(-1), "PROP_HUMAN_BBQ", 0, false)
  102. Citizen.Wait(5000)
  103. TriggerServerEvent('esx_andreas_chef:cookSteak')
  104. else
  105. ESX.ShowNotification('You don/t have the ingredients needed')
  106. end
  107. end)
  108. end)
  109.  
  110. RegisterNetEvent('esx_andreas_chef:cookPizza')
  111. AddEventHandler('esx_andreas_chef:cookPizza', function()
  112. ESX.TriggerServerCallback('esx_andreas_chef:checkPizza', function(hasItem)
  113. if hasItem then
  114. TaskStartScenarioInPlace(GetPlayerPed(-1), "PROP_HUMAN_BBQ", 0, false)
  115. Citizen.Wait(5000)
  116. TriggerServerEvent('esx_andreas_chef:cookPizza')
  117. else
  118. ESX.ShowNotification('You don/t have the ingredients needed')
  119. end
  120. end)
  121. end)
  122. ----------------------------------- MENUS -----------------------------------
  123.  
  124.  
  125. function OpenChefMenu()
  126. ESX.UI.Menu.CloseAll()
  127.  
  128. ESX.UI.Menu.Open(
  129. 'default', GetCurrentResourceName(), 'menu_menu',
  130. {
  131. title = 'Food Menu',
  132. elements = {
  133. {label = 'Hamburger', value = 'hamburger'},
  134. {label = 'Steak', value = 'steak'},
  135. {label = 'Pizza', value = 'pizza'},
  136. }
  137. },
  138. function(data, menu)
  139.  
  140. if data.current.value == 'hamburger' then
  141. TriggerEvent('esx_andreas_chef:cookHamburger')
  142. end
  143.  
  144. if data.current.value == 'steak' then
  145. TriggerEvent('esx_andreas_chef:cookSteak')
  146. end
  147.  
  148. if data.current.value == 'pizza' then
  149. TriggerEvent('esx_andreas_chef:cookPizza')
  150. end
  151. end,
  152. function(data, menu)
  153. menu.close()
  154. end
  155. )
  156. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement