fork(3) download
  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 PlayerData = {}
  14. local GUI = {}
  15. local HasAlreadyEnteredMarker = false
  16. local LastZone = nil
  17. local CurrentAction = nil
  18. local CurrentActionMsg = ''
  19. local CurrentActionData = {}
  20. local OnJob = false
  21. local CurrentCustomer = nil
  22. local CurrentCustomerBlip = nil
  23. local DestinationBlip = nil
  24. local IsNearCustomer = false
  25. local CustomerIsEnteringVehicle = false
  26. local CustomerEnteredVehicle = false
  27. local TargetCoords = nil
  28.  
  29. ESX = nil
  30. GUI.Time = 0
  31.  
  32. Citizen.CreateThread(function()
  33. while ESX == nil do
  34. TriggerEvent('esx:getSharedObject', function(obj) ESX = obj end)
  35. Citizen.Wait(0)
  36. end
  37. end)
  38.  
  39. function DrawSub(msg, time)
  40. ClearPrints()
  41. SetTextEntry_2("STRING")
  42. AddTextComponentString(msg)
  43. DrawSubtitleTimed(time, 1)
  44. end
  45.  
  46. function ShowLoadingPromt(msg, time, type)
  47. Citizen.CreateThread(function()
  48. Citizen.Wait(0)
  49. N_0xaba17d7ce615adbf("STRING")
  50. AddTextComponentString(msg)
  51. N_0xbd12f8228410d9b4(type)
  52. Citizen.Wait(time)
  53. N_0x10d373323e5b9c0d()
  54. end)
  55. end
  56.  
  57. function GetRandomWalkingNPC()
  58.  
  59. local search = {}
  60. local peds = ESX.Game.GetPeds()
  61.  
  62. for i=1, #peds, 1 do
  63. if IsPedHuman(peds[i]) and IsPedWalking(peds[i]) and not IsPedAPlayer(peds[i]) then
  64. table.insert(search, peds[i])
  65. end
  66. end
  67.  
  68. if #search > 0 then
  69. return search[GetRandomIntInRange(1, #search)]
  70. end
  71.  
  72. print('Using fallback code to find walking ped')
  73.  
  74. for i=1, 250, 1 do
  75.  
  76. local ped = GetRandomPedAtCoord(0.0, 0.0, 0.0, math.huge + 0.0, math.huge + 0.0, math.huge + 0.0, 26)
  77.  
  78. if DoesEntityExist(ped) and IsPedHuman(ped) and IsPedWalking(ped) and not IsPedAPlayer(ped) then
  79. table.insert(search, ped)
  80. end
  81.  
  82. end
  83.  
  84. if #search > 0 then
  85. return search[GetRandomIntInRange(1, #search)]
  86. end
  87.  
  88. end
  89.  
  90. function ClearCurrentMission()
  91.  
  92. if DoesBlipExist(CurrentCustomerBlip) then
  93. RemoveBlip(CurrentCustomerBlip)
  94. end
  95.  
  96. if DoesBlipExist(DestinationBlip) then
  97. RemoveBlip(DestinationBlip)
  98. end
  99.  
  100. CurrentCustomer = nil
  101. CurrentCustomerBlip = nil
  102. DestinationBlip = nil
  103. IsNearCustomer = false
  104. CustomerIsEnteringVehicle = false
  105. CustomerEnteredVehicle = false
  106. TargetCoords = nil
  107.  
  108. end
  109.  
  110. function StartTaxiJob()
  111.  
  112. ShowLoadingPromt(_U('taking_service') .. 'Taxi/Uber', 5000, 3)
  113. ClearCurrentMission()
  114.  
  115. OnJob = true
  116.  
  117. end
  118.  
  119. function StopTaxiJob()
  120.  
  121. local playerPed = GetPlayerPed(-1)
  122.  
  123. if IsPedInAnyVehicle(playerPed, false) and CurrentCustomer ~= nil then
  124. local vehicle = GetVehiclePedIsIn(playerPed, false)
  125. TaskLeaveVehicle(CurrentCustomer, vehicle, 0)
  126.  
  127. if CustomerEnteredVehicle then
  128. TaskGoStraightToCoord(CurrentCustomer, TargetCoords.x, TargetCoords.y, TargetCoords.z, 1.0, -1, 0.0, 0.0)
  129. end
  130.  
  131. end
  132.  
  133. ClearCurrentMission()
  134.  
  135. OnJob = false
  136.  
  137. DrawSub(_U('mission_complete'), 5000)
  138.  
  139. end
  140.  
  141. function OpenTaxiActionsMenu()
  142.  
  143. local elements = {
  144. {label = _U('spawn_veh'), value = 'spawn_vehicle'},
  145. {label = _U('deposit_stock'), value = 'put_stock'},
  146. {label = _U('take_stock'), value = 'get_stock'}
  147. }
  148.  
  149. if Config.EnablePlayerManagement and PlayerData.job ~= nil and PlayerData.job.grade_name == 'boss' then
  150. table.insert(elements, {label = _U('boss_actions'), value = 'boss_actions'})
  151. end
  152.  
  153. ESX.UI.Menu.CloseAll()
  154.  
  155. ESX.UI.Menu.Open(
  156. 'default', GetCurrentResourceName(), 'taxi_actions',
  157. {
  158. title = 'Taxi',
  159. elements = elements
  160. },
  161. function(data, menu)
  162.  
  163. if data.current.value == 'put_stock' then
  164. OpenPutStocksMenu()
  165. end
  166.  
  167. if data.current.value == 'get_stock' then
  168. OpenGetStocksMenu()
  169. end
  170.  
  171. if data.current.value == 'spawn_vehicle' then
  172.  
  173. if Config.EnableSocietyOwnedVehicles then
  174.  
  175. local elements = {}
  176.  
  177. ESX.TriggerServerCallback('esx_society:getVehiclesInGarage', function(vehicles)
  178.  
  179. for i=1, #vehicles, 1 do
  180. table.insert(elements, {label = GetDisplayNameFromVehicleModel(vehicles[i].model) .. ' [' .. vehicles[i].plate .. ']', value = vehicles[i]})
  181. end
  182.  
  183. ESX.UI.Menu.Open(
  184. 'default', GetCurrentResourceName(), 'vehicle_spawner',
  185. {
  186. title = _U('spawn_veh'),
  187. align = 'top-left',
  188. elements = elements,
  189. },
  190. function(data, menu)
  191.  
  192. menu.close()
  193.  
  194. local vehicleProps = data.current.value
  195.  
  196. ESX.Game.SpawnVehicle(vehicleProps.model, Config.Zones.VehicleSpawnPoint.Pos, 270.0, function(vehicle)
  197. ESX.Game.SetVehicleProperties(vehicle, vehicleProps)
  198. local playerPed = GetPlayerPed(-1)
  199. TaskWarpPedIntoVehicle(playerPed, vehicle, -1)
  200. end)
  201.  
  202. TriggerServerEvent('esx_society:removeVehicleFromGarage', 'taxi', vehicleProps)
  203.  
  204. end,
  205. function(data, menu)
  206. menu.close()
  207. end
  208. )
  209.  
  210. end, 'taxi')
  211.  
  212. else
  213.  
  214. menu.close()
  215.  
  216. if Config.MaxInService == -1 then
  217.  
  218. local playerPed = GetPlayerPed(-1)
  219. local coords = Config.Zones.VehicleSpawnPoint.Pos
  220.  
  221. ESX.Game.SpawnVehicle('taxi', coords, 225.0, function(vehicle)
  222. TaskWarpPedIntoVehicle(playerPed, vehicle, -1)
  223. end)
  224.  
  225. else
  226.  
  227. ESX.TriggerServerCallback('esx_service:enableService', function(canTakeService, maxInService, inServiceCount)
  228.  
  229. if canTakeService then
  230.  
  231. local playerPed = GetPlayerPed(-1)
  232. local coords = Config.Zones.VehicleSpawnPoint.Pos
  233.  
  234. ESX.Game.SpawnVehicle('taxi', coords, 225.0, function(vehicle)
  235. TaskWarpPedIntoVehicle(playerPed, vehicle, -1)
  236. end)
  237.  
  238. else
  239.  
  240. ESX.ShowNotification(_U('full_service') .. inServiceCount .. '/' .. maxInService)
  241.  
  242. end
  243.  
  244. end, 'taxi')
  245.  
  246. end
  247.  
  248. end
  249.  
  250. end
  251.  
  252. if data.current.value == 'boss_actions' then
  253. TriggerEvent('esx_society:openBossMenu', 'taxi', function(data, menu)
  254. menu.close()
  255. end)
  256. end
  257.  
  258. end,
  259. function(data, menu)
  260.  
  261. menu.close()
  262.  
  263. CurrentAction = 'taxi_actions_menu'
  264. CurrentActionMsg = _U('press_to_open')
  265. CurrentActionData = {}
  266.  
  267. end
  268. )
  269.  
  270. end
  271.  
  272. function OpenMobileTaxiActionsMenu()
  273.  
  274. ESX.UI.Menu.CloseAll()
  275.  
  276. ESX.UI.Menu.Open(
  277. 'default', GetCurrentResourceName(), 'mobile_taxi_actions',
  278. {
  279. title = 'Taxi',
  280. elements = {
  281. {label = _U('billing'), value = 'billing'}
  282. }
  283. },
  284. function(data, menu)
  285.  
  286. if data.current.value == 'billing' then
  287.  
  288. ESX.UI.Menu.Open(
  289. 'dialog', GetCurrentResourceName(), 'billing',
  290. {
  291. title = _U('invoice_amount')
  292. },
  293. function(data, menu)
  294.  
  295. local amount = tonumber(data.value)
  296.  
  297. if amount == nil then
  298. ESX.ShowNotification(_U('amount_invalid'))
  299. else
  300.  
  301. menu.close()
  302.  
  303. local closestPlayer, closestDistance = ESX.Game.GetClosestPlayer()
  304.  
  305. if closestPlayer == -1 or closestDistance > 3.0 then
  306. ESX.ShowNotification(_U('no_players_near'))
  307. else
  308. TriggerServerEvent('esx_billing:sendBill', GetPlayerServerId(closestPlayer), 'society_taxi', 'Taxi', amount)
  309. end
  310.  
  311. end
  312.  
  313. end,
  314. function(data, menu)
  315. menu.close()
  316. end
  317. )
  318.  
  319. end
  320.  
  321. end,
  322. function(data, menu)
  323. menu.close()
  324. end
  325. )
  326.  
  327. end
  328.  
  329. function OpenGetStocksMenu()
  330.  
  331. ESX.TriggerServerCallback('esx_taxijob:getStockItems', function(items)
  332.  
  333. print(json.encode(items))
  334.  
  335. local elements = {}
  336.  
  337. for i=1, #items, 1 do
  338. table.insert(elements, {label = 'x' .. items[i].count .. ' ' .. items[i].label, value = items[i].name})
  339. end
  340.  
  341. ESX.UI.Menu.Open(
  342. 'default', GetCurrentResourceName(), 'stocks_menu',
  343. {
  344. title = 'Taxi Stock',
  345. elements = elements
  346. },
  347. function(data, menu)
  348.  
  349. local itemName = data.current.value
  350.  
  351. ESX.UI.Menu.Open(
  352. 'dialog', GetCurrentResourceName(), 'stocks_menu_get_item_count',
  353. {
  354. title = _U('quantity')
  355. },
  356. function(data2, menu2)
  357.  
  358. local count = tonumber(data2.value)
  359.  
  360. if count == nil then
  361. ESX.ShowNotification(_U('quantity_invalid'))
  362. else
  363. menu2.close()
  364. menu.close()
  365. OpenGetStocksMenu()
  366.  
  367. TriggerServerEvent('esx_taxijob:getStockItem', itemName, count)
  368. end
  369.  
  370. end,
  371. function(data2, menu2)
  372. menu2.close()
  373. end
  374. )
  375.  
  376. end,
  377. function(data, menu)
  378. menu.close()
  379. end
  380. )
  381.  
  382. end)
  383.  
  384. end
  385.  
  386. function OpenPutStocksMenu()
  387.  
  388. ESX.TriggerServerCallback('esx_taxijob:getPlayerInventory', function(inventory)
  389.  
  390. local elements = {}
  391.  
  392. for i=1, #inventory.items, 1 do
  393.  
  394. local item = inventory.items[i]
  395.  
  396. if item.count > 0 then
  397. table.insert(elements, {label = item.label .. ' x' .. item.count, type = 'item_standard', value = item.name})
  398. end
  399.  
  400. end
  401.  
  402. ESX.UI.Menu.Open(
  403. 'default', GetCurrentResourceName(), 'stocks_menu',
  404. {
  405. title = _U('inventory'),
  406. elements = elements
  407. },
  408. function(data, menu)
  409.  
  410. local itemName = data.current.value
  411.  
  412. ESX.UI.Menu.Open(
  413. 'dialog', GetCurrentResourceName(), 'stocks_menu_put_item_count',
  414. {
  415. title = _U('quantity')
  416. },
  417. function(data2, menu2)
  418.  
  419. local count = tonumber(data2.value)
  420.  
  421. if count == nil then
  422. ESX.ShowNotification(_U('quantity_invalid'))
  423. else
  424. menu2.close()
  425. menu.close()
  426. OpenPutStocksMenu()
  427.  
  428. TriggerServerEvent('esx_taxijob:putStockItems', itemName, count)
  429. end
  430.  
  431. end,
  432. function(data2, menu2)
  433. menu2.close()
  434. end
  435. )
  436.  
  437. end,
  438. function(data, menu)
  439. menu.close()
  440. end
  441. )
  442.  
  443. end)
  444.  
  445. end
  446.  
  447.  
  448. RegisterNetEvent('esx:playerLoaded')
  449. AddEventHandler('esx:playerLoaded', function(xPlayer)
  450. PlayerData = xPlayer
  451. end)
  452.  
  453. RegisterNetEvent('esx:setJob')
  454. AddEventHandler('esx:setJob', function(job)
  455. PlayerData.job = job
  456. end)
  457.  
  458. AddEventHandler('esx_taxijob:hasEnteredMarker', function(zone)
  459.  
  460. if zone == 'TaxiActions' then
  461. CurrentAction = 'taxi_actions_menu'
  462. CurrentActionMsg = _U('press_to_open')
  463. CurrentActionData = {}
  464. end
  465.  
  466. if zone == 'VehicleDeleter' then
  467.  
  468. local playerPed = GetPlayerPed(-1)
  469.  
  470. if IsPedInAnyVehicle(playerPed, false) then
  471.  
  472. local vehicle = GetVehiclePedIsIn(playerPed, false)
  473.  
  474. CurrentAction = 'delete_vehicle'
  475. CurrentActionMsg = _U('veh_stored')
  476. CurrentActionData = {vehicle = vehicle}
  477. end
  478. end
  479.  
  480. end)
  481.  
  482. AddEventHandler('esx_taxijob:hasExitedMarker', function(zone)
  483. ESX.UI.Menu.CloseAll()
  484. CurrentAction = nil
  485. end)
  486.  
  487. RegisterNetEvent('esx_phone:loaded')
  488. AddEventHandler('esx_phone:loaded', function(phoneNumber, contacts)
  489.  
  490. local specialContact = {
  491. name = 'Taxi',
  492. number = 'taxi',
  493. base64Icon = 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAYAAABzenr0AAAGGElEQVR4XsWWW2gd1xWGv7Vn5pyRj47ut8iOYlmyWxw1KSZN4riOW6eFuCYldaBtIL1Ag4NNmt5ICORCaNKXlF6oCy0hpSoJKW4bp7Sk6YNb01RuLq4d0pQ0kWQrshVJ1uX46HJ0zpy5rCKfQYgjCUs4kA+GtTd786+ftW8jqsqHibB6TLZn2zeq09ZTWAIWCxACoTI1E+6v+eSpXwHRqkVZPcmqlBzCApLQ8dk3IWVKMQlYcHG81OODNmD6D7d9VQrTSbwsH73lFKePtvOxXSfn48U+Xpb58fl5gPmgl6DiR19PZN4+G7iODY4liIAACqiCHyp+AFvb7ML3uot1QP5yDUim292RtIqfU6Lr8wFVDVV8AsPKRDAxzYkKm2kj5sSFuUT3+v2FXkDXakD6f+7c1NGS7Ml0Pkah6jq8mhvwUy7Cyijg5Aoks6/hTp+k7vRjDJ73dmw8WHxlJRM2y5Nsb3GPDuzsZURbGMsUmRkoUPByCMrKCG7SobJiO01X7OKq6utoe3XX34BaoLDaCljj3faTcu3j3z3T+iADwzNYEmKIWcGAIAtqqkKAxZa2Sja/tY+59/7y48aveQ8A4Woq4Fa3bj7Q1/EgwWRAZ52NMTYCWAZEwIhBUEQgUiVQ8IpKvqj4kVJCyGRCRrb+hvap+gPAo0DuUhWQfx2q29u+t/vPmarbCLwII7qQTEQRLbUtBJ2PAkZARBADqkLBV/I+BGrhpoSN577FWz3P3XbTvRMvAlpuwC4crv5jwtK9RAFSu46+G8cRwESxQ+K2gESAgCiIASHuA8YCBdSUohdCKGCF0H6iGc3MgrEphvKi+6Wp24HABioSjuxFARGobyJ5OMXEiGHW6iLR0EmifhPJDddj3CoqtuwEZSkCc73/RAvTeEOvU5w8gz/Zj2TfoLFFibZvQrI5EOFiPqgAZmzApTINKKgPiW20ffkXtPXfA9Ysmf5/kHn/T0z8e5rpCS5JVQNUN1ayfn2a+qvT2JWboOOXMPg0ms6C2IAAWTc2ACPeupdbm5yb8XNQczOM90DOB0uoa01Ttz5FZ6IL3Ctg9DUIg7Lto2DZ0HIDFEbAz4AaiBRyxZJe9U7kQg84KYbH/JeJESANXPXwXdWffvzu1p+x5VE4/ST4EyAOoEAI6WsAhdx/AYulhJDqAgRm/hPPEVAfnAboeAB6v88jTw/f98SzU8eAwbgC5IGRg3vsW3E7YewYzJwF4wAhikJURGqvBO8ouAFIxBI0gqgPEp9B86+ASSAIEEHhbEnX7eTgnrFbn3iW5+K82EAA+M2V+d2EeRj9K/izIBYgJZGwCO4Gzm/uRQOwDEsI41PSfPZ+xJsBKwFo6dOwpJvezMU84Md5sSmRCM51uacGbUKvHWEjAKIelXaGJqePyopjzFTdx6Ef/gDbjo3FKEoQKN+8/yEqRt8jf67IaNDBnF9FZFwERRGspMM20+XC64nym9AMhSE1G7fjbb0bCQsISi6vFCdPMPzuUwR9AcmOKQ7cew+WZcq3IGEYMZeb4p13sjjmU4TX7Cfdtp0oDAFBbZfk/37N0MALAKbcAKaY4yPeuwy3t2J8MAKDIxDVd1Lz8Ts599vb8Wameen532GspRWIQmXPHV8k0BquvPP3TOSgsRmiCFRAHWh9420Gi7nl34JaBen7O7UWRMD740AQ7yEf8nW78TIeN+7+PCIsOYaqMJHxqKtpJ++D+DA5ARsawEmASqzv1Cz7FjRpbt951tUAOcAHdNEUC7C5NAJo7Dws03CAFMxlkdSRZmCMxaq8ejKuVwSqIJfzA61LmyIgBoxZfgmYmQazKLGumHitRso0ZVkD0aE/FI7UrYv2WUYXjo0ihNhEatA1GBEUIxEWAcKCHhHCVMG8AETlda0ENn3hrm+/6Zh47RBCtXn+mZ/sAXzWjnPHV77zkiXBgl6gFkee+em1wBlgdnEF8sCF5moLI7KwlSIMwABwgbVT21htMNjleheAfPkShEBh/PzQccexdxBT9IPjQAYYZ+3o2OjQ8cQiPb+kVwBCliENXA3sAm6Zj3E/zaq4fD07HmwEmuKYXsUFcDl6Hz7/B1RGfEbPim/bAAAAAElFTkSuQmCC',
  494. }
  495.  
  496. TriggerEvent('esx_phone:addSpecialContact', specialContact.name, specialContact.number, specialContact.base64Icon)
  497.  
  498. end)
  499.  
  500. -- Create Blips
  501. Citizen.CreateThread(function()
  502.  
  503. local blip = AddBlipForCoord(Config.Zones.TaxiActions.Pos.x, Config.Zones.TaxiActions.Pos.y, Config.Zones.TaxiActions.Pos.z)
  504.  
  505. SetBlipSprite (blip, 198)
  506. SetBlipDisplay(blip, 4)
  507. SetBlipScale (blip, 1.0)
  508. SetBlipColour (blip, 5)
  509. SetBlipAsShortRange(blip, true)
  510.  
  511. BeginTextCommandSetBlipName("STRING")
  512. AddTextComponentString("Taxi")
  513. EndTextCommandSetBlipName(blip)
  514.  
  515. end)
  516.  
  517. -- Display markers
  518. Citizen.CreateThread(function()
  519. while true do
  520.  
  521. Wait(0)
  522.  
  523. if PlayerData.job ~= nil and PlayerData.job.name == 'taxi' then
  524.  
  525. local coords = GetEntityCoords(GetPlayerPed(-1))
  526.  
  527. for k,v in pairs(Config.Zones) do
  528. if(v.Type ~= -1 and GetDistanceBetweenCoords(coords, v.Pos.x, v.Pos.y, v.Pos.z, true) < Config.DrawDistance) then
  529. DrawMarker(v.Type, v.Pos.x, v.Pos.y, v.Pos.z, 0.0, 0.0, 0.0, 0, 0.0, 0.0, v.Size.x, v.Size.y, v.Size.z, v.Color.r, v.Color.g, v.Color.b, 100, false, true, 2, false, false, false, false)
  530. end
  531. end
  532.  
  533. end
  534.  
  535. end
  536. end)
  537.  
  538. -- Enter / Exit marker events
  539. Citizen.CreateThread(function()
  540. while true do
  541.  
  542. Wait(0)
  543.  
  544. if PlayerData.job ~= nil and PlayerData.job.name == 'taxi' then
  545.  
  546. local coords = GetEntityCoords(GetPlayerPed(-1))
  547. local isInMarker = false
  548. local currentZone = nil
  549.  
  550. for k,v in pairs(Config.Zones) do
  551. if(GetDistanceBetweenCoords(coords, v.Pos.x, v.Pos.y, v.Pos.z, true) < v.Size.x) then
  552. isInMarker = true
  553. currentZone = k
  554. end
  555. end
  556.  
  557. if (isInMarker and not HasAlreadyEnteredMarker) or (isInMarker and LastZone ~= currentZone) then
  558. HasAlreadyEnteredMarker = true
  559. LastZone = currentZone
  560. TriggerEvent('esx_taxijob:hasEnteredMarker', currentZone)
  561. end
  562.  
  563. if not isInMarker and HasAlreadyEnteredMarker then
  564. HasAlreadyEnteredMarker = false
  565. TriggerEvent('esx_taxijob:hasExitedMarker', LastZone)
  566. end
  567.  
  568. end
  569.  
  570. end
  571. end)
  572.  
  573. -- Taxi Job
  574. Citizen.CreateThread(function()
  575.  
  576. while true do
  577.  
  578. Citizen.Wait(0)
  579.  
  580. local playerPed = GetPlayerPed(-1)
  581.  
  582. if OnJob then
  583.  
  584. if CurrentCustomer == nil then
  585.  
  586. DrawSub(_U('drive_search_pass'), 5000)
  587.  
  588. if IsPedInAnyVehicle(playerPed, false) and GetEntitySpeed(playerPed) > 0 then
  589.  
  590. local waitUntil = GetGameTimer() + GetRandomIntInRange(30000, 45000)
  591.  
  592. while OnJob and waitUntil > GetGameTimer() do
  593. Citizen.Wait(0)
  594. end
  595.  
  596. if OnJob and IsPedInAnyVehicle(playerPed, false) and GetEntitySpeed(playerPed) > 0 then
  597.  
  598. CurrentCustomer = GetRandomWalkingNPC()
  599.  
  600. if CurrentCustomer ~= nil then
  601.  
  602. CurrentCustomerBlip = AddBlipForEntity(CurrentCustomer)
  603.  
  604. SetBlipAsFriendly(CurrentCustomerBlip, 1)
  605. SetBlipColour(CurrentCustomerBlip, 2)
  606. SetBlipCategory(CurrentCustomerBlip, 3)
  607. SetBlipRoute(CurrentCustomerBlip, true)
  608.  
  609. SetEntityAsMissionEntity(CurrentCustomer, true, false)
  610. ClearPedTasksImmediately(CurrentCustomer)
  611. SetBlockingOfNonTemporaryEvents(CurrentCustomer, 1)
  612.  
  613. local standTime = GetRandomIntInRange(60000, 180000)
  614.  
  615. TaskStandStill(CurrentCustomer, standTime)
  616.  
  617. ESX.ShowNotification(_U('customer_found'))
  618.  
  619. end
  620.  
  621. end
  622.  
  623. end
  624.  
  625. else
  626.  
  627. if IsPedFatallyInjured(CurrentCustomer) then
  628.  
  629. ESX.ShowNotification(_U('client_unconcious'))
  630.  
  631. if DoesBlipExist(CurrentCustomerBlip) then
  632. RemoveBlip(CurrentCustomerBlip)
  633. end
  634.  
  635. if DoesBlipExist(DestinationBlip) then
  636. RemoveBlip(DestinationBlip)
  637. end
  638.  
  639. SetEntityAsMissionEntity(CurrentCustomer, false, true)
  640.  
  641. CurrentCustomer = nil
  642. CurrentCustomerBlip = nil
  643. DestinationBlip = nil
  644. IsNearCustomer = false
  645. CustomerIsEnteringVehicle = false
  646. CustomerEnteredVehicle = false
  647. TargetCoords = nil
  648.  
  649. end
  650.  
  651. if IsPedInAnyVehicle(playerPed, false) then
  652.  
  653. local vehicle = GetVehiclePedIsIn(playerPed, false)
  654. local playerCoords = GetEntityCoords(playerPed)
  655. local customerCoords = GetEntityCoords(CurrentCustomer)
  656. local customerDistance = GetDistanceBetweenCoords(playerCoords.x, playerCoords.y, playerCoords.z, customerCoords.x, customerCoords.y, customerCoords.z)
  657.  
  658. if IsPedSittingInVehicle(CurrentCustomer, vehicle) then
  659.  
  660. if CustomerEnteredVehicle then
  661.  
  662. local targetDistance = GetDistanceBetweenCoords(playerCoords.x, playerCoords.y, playerCoords.z, TargetCoords.x, TargetCoords.y, TargetCoords.z)
  663.  
  664. if targetDistance <= 10.0 then
  665.  
  666. TaskLeaveVehicle(CurrentCustomer, vehicle, 0)
  667.  
  668. ESX.ShowNotification(_U('arrive_dest'))
  669.  
  670. TaskGoStraightToCoord(CurrentCustomer, TargetCoords.x, TargetCoords.y, TargetCoords.z, 1.0, -1, 0.0, 0.0)
  671. SetEntityAsMissionEntity(CurrentCustomer, false, true)
  672.  
  673. TriggerServerEvent('esx_taxijob:success')
  674.  
  675. RemoveBlip(DestinationBlip)
  676.  
  677. local scope = function(customer)
  678. ESX.SetTimeout(60000, function()
  679. DeletePed(customer)
  680. end)
  681. end
  682.  
  683. scope(CurrentCustomer)
  684.  
  685. CurrentCustomer = nil
  686. CurrentCustomerBlip = nil
  687. DestinationBlip = nil
  688. IsNearCustomer = false
  689. CustomerIsEnteringVehicle = false
  690. CustomerEnteredVehicle = false
  691. TargetCoords = nil
  692.  
  693. end
  694.  
  695. if TargetCoords ~= nil then
  696. DrawMarker(1, TargetCoords.x, TargetCoords.y, TargetCoords.z - 1.0, 0, 0, 0, 0, 0, 0, 4.0, 4.0, 2.0, 178, 236, 93, 155, 0, 0, 2, 0, 0, 0, 0)
  697. end
  698.  
  699. else
  700.  
  701. RemoveBlip(CurrentCustomerBlip)
  702.  
  703. CurrentCustomerBlip = nil
  704.  
  705. TargetCoords = Config.JobLocations[GetRandomIntInRange(1, #Config.JobLocations)]
  706.  
  707. local street = table.pack(GetStreetNameAtCoord(TargetCoords.x, TargetCoords.y, TargetCoords.z))
  708. local msg = nil
  709.  
  710. if street[2] ~= 0 and street[2] ~= nil then
  711. msg = string.format(_U('take_me_to_near', GetStreetNameFromHashKey(street[1]),GetStreetNameFromHashKey(street[2])))
  712. else
  713. msg = string.format(_U('take_me_to', GetStreetNameFromHashKey(street[1])))
  714. end
  715.  
  716. ESX.ShowNotification(msg)
  717.  
  718. DestinationBlip = AddBlipForCoord(TargetCoords.x, TargetCoords.y, TargetCoords.z)
  719.  
  720. BeginTextCommandSetBlipName("STRING")
  721. AddTextComponentString("Destination")
  722. EndTextCommandSetBlipName(blip)
  723.  
  724. SetBlipRoute(DestinationBlip, true)
  725.  
  726. CustomerEnteredVehicle = true
  727.  
  728. end
  729.  
  730. else
  731.  
  732. DrawMarker(1, customerCoords.x, customerCoords.y, customerCoords.z - 1.0, 0, 0, 0, 0, 0, 0, 4.0, 4.0, 2.0, 178, 236, 93, 155, 0, 0, 2, 0, 0, 0, 0)
  733.  
  734. if not CustomerEnteredVehicle then
  735.  
  736. if customerDistance <= 30.0 then
  737.  
  738. if not IsNearCustomer then
  739. ESX.ShowNotification(_U('close_to_client'))
  740. IsNearCustomer = true
  741. end
  742.  
  743. end
  744.  
  745. if customerDistance <= 100.0 then
  746.  
  747. if not CustomerIsEnteringVehicle then
  748.  
  749. ClearPedTasksImmediately(CurrentCustomer)
  750.  
  751. local seat = 0
  752.  
  753. for i=4, 0, 1 do
  754. if IsVehicleSeatFree(vehicle, seat) then
  755. seat = i
  756. break
  757. end
  758. end
  759.  
  760. TaskEnterVehicle(CurrentCustomer, vehicle, -1, seat, 2.0, 1)
  761.  
  762. CustomerIsEnteringVehicle = true
  763.  
  764. end
  765.  
  766. end
  767.  
  768. end
  769.  
  770. end
  771.  
  772. else
  773.  
  774. DrawSub(_U('return_to_veh'), 5000)
  775.  
  776. end
  777.  
  778. end
  779.  
  780. end
  781.  
  782. end
  783. end)
  784.  
  785. -- Key Controls
  786. Citizen.CreateThread(function()
  787. while true do
  788.  
  789. Citizen.Wait(0)
  790.  
  791. if CurrentAction ~= nil then
  792.  
  793. SetTextComponentFormat('STRING')
  794. AddTextComponentString(CurrentActionMsg)
  795. DisplayHelpTextFromStringLabel(0, 0, 1, -1)
  796.  
  797. if IsControlPressed(0, Keys['E']) and PlayerData.job ~= nil and PlayerData.job.name == 'taxi' and (GetGameTimer() - GUI.Time) > 300 then
  798.  
  799. if CurrentAction == 'taxi_actions_menu' then
  800. OpenTaxiActionsMenu()
  801. end
  802.  
  803. if CurrentAction == 'delete_vehicle' then
  804.  
  805. local playerPed = GetPlayerPed(-1)
  806.  
  807. if Config.EnableSocietyOwnedVehicles then
  808. local vehicleProps = ESX.Game.GetVehicleProperties(CurrentActionData.vehicle)
  809. TriggerServerEvent('esx_society:putVehicleInGarage', 'taxi', vehicleProps)
  810. else
  811. if GetEntityModel(CurrentActionData.vehicle) == GetHashKey('taxi') then
  812. if Config.MaxInService ~= -1 then
  813. TriggerServerEvent('esx_service:disableService', 'taxi')
  814. end
  815. end
  816. end
  817.  
  818. ESX.Game.DeleteVehicle(CurrentActionData.vehicle)
  819.  
  820. end
  821.  
  822. CurrentAction = nil
  823. GUI.Time = GetGameTimer()
  824.  
  825. end
  826.  
  827. end
  828.  
  829. if IsControlPressed(0, Keys['F2']) and Config.EnablePlayerManagement and PlayerData.job ~= nil and PlayerData.job.name == 'taxi' and (GetGameTimer() - GUI.Time) > 150 then
  830. OpenMobileTaxiActionsMenu()
  831. GUI.Time = GetGameTimer()
  832. end
  833.  
  834. if IsControlPressed(0, Keys['DELETE']) and (GetGameTimer() - GUI.Time) > 150 then
  835.  
  836. if OnJob then
  837. StopTaxiJob()
  838. else
  839.  
  840. if PlayerData.job ~= nil and PlayerData.job.name == 'taxi' then
  841.  
  842. local playerPed = GetPlayerPed(-1)
  843.  
  844. if IsPedInAnyVehicle(playerPed, false) then
  845.  
  846. local vehicle = GetVehiclePedIsIn(playerPed, false)
  847.  
  848. if PlayerData.job.grade >= 3 then
  849. StartTaxiJob()
  850. else
  851. if GetEntityModel(vehicle) == GetHashKey('taxi') then
  852. StartTaxiJob()
  853. else
  854. ESX.ShowNotification(_U('must_in_taxi'))
  855. end
  856. end
  857.  
  858. else
  859.  
  860. if PlayerData.job.grade >= 3 then
  861. ESX.ShowNotification(_U('must_in_vehicle'))
  862. else
  863. ESX.ShowNotification(_U('must_in_taxi'))
  864. end
  865.  
  866. end
  867.  
  868. end
  869.  
  870. end
  871.  
  872. GUI.Time = GetGameTimer()
  873.  
  874. end
  875.  
  876. end
  877. end)
  878.  
Runtime error #stdin #stdout #stderr 0s 14120KB
stdin
Standard input is empty
stdout
Standard output is empty
stderr
lua5.3: prog.lua:32: attempt to index a nil value (global 'Citizen')
stack traceback:
	prog.lua:32: in main chunk
	[C]: in ?