From 2f3bd4734b91e5f1f06fd0b8176337b2f15773c4 Mon Sep 17 00:00:00 2001 From: ElPumpo Date: Mon, 13 Aug 2018 14:20:19 +0200 Subject: [PATCH] Moved NPC job to F6 menu --- client/main.lua | 157 ++++++++++++++++++++++++------------------------ locales/br.lua | 2 + locales/de.lua | 2 + locales/en.lua | 2 + locales/fi.lua | 2 + locales/fr.lua | 2 + locales/pl.lua | 2 + locales/sv.lua | 5 +- 8 files changed, 96 insertions(+), 78 deletions(-) diff --git a/client/main.lua b/client/main.lua index 1ed4ab50..918b42e3 100644 --- a/client/main.lua +++ b/client/main.lua @@ -279,60 +279,98 @@ end function OpenMobileTaxiActionsMenu() - ESX.UI.Menu.CloseAll() + ESX.UI.Menu.CloseAll() - ESX.UI.Menu.Open( - 'default', GetCurrentResourceName(), 'mobile_taxi_actions', - { - title = 'Taxi', - align = 'top-left', - elements = { - {label = _U('billing'), value = 'billing'} - } - }, - function(data, menu) + ESX.UI.Menu.Open('default', GetCurrentResourceName(), 'mobile_taxi_actions', + { + title = 'Taxi', + align = 'top-left', + elements = { + { label = _U('billing'), value = 'billing' }, + { label = _U('start_job'), value = 'start_job' } + } + }, function(data, menu) - if data.current.value == 'billing' then + if data.current.value == 'billing' then - ESX.UI.Menu.Open( - 'dialog', GetCurrentResourceName(), 'billing', - { - title = _U('invoice_amount') - }, - function(data, menu) + ESX.UI.Menu.Open('dialog', GetCurrentResourceName(), 'billing', { + title = _U('invoice_amount') + }, function(data, menu) - local amount = tonumber(data.value) + local amount = tonumber(data.value) + if amount == nil then + ESX.ShowNotification(_U('amount_invalid')) + else + menu.close() + local closestPlayer, closestDistance = ESX.Game.GetClosestPlayer() + if closestPlayer == -1 or closestDistance > 3.0 then + ESX.ShowNotification(_U('no_players_near')) + else + TriggerServerEvent('esx_billing:sendBill', GetPlayerServerId(closestPlayer), 'society_taxi', 'Taxi', amount) + ESX.ShowNotification(_U('billing_sent')) + end - if amount == nil then - ESX.ShowNotification(_U('amount_invalid')) - else + end - menu.close() + end, function(data, menu) + menu.close() + end) - local closestPlayer, closestDistance = ESX.Game.GetClosestPlayer() + elseif data.current.value == 'start_job' then + + if OnJob then + StopTaxiJob() + else - if closestPlayer == -1 or closestDistance > 3.0 then - ESX.ShowNotification(_U('no_players_near')) - else - TriggerServerEvent('esx_billing:sendBill', GetPlayerServerId(closestPlayer), 'society_taxi', 'Taxi', amount) - end + if PlayerData.job ~= nil and PlayerData.job.name == 'taxi' then - end + local playerPed = PlayerPedId() + if IsPedInAnyVehicle(playerPed, false) then - end, - function(data, menu) - menu.close() - end - ) + local vehicle = GetVehiclePedIsIn(playerPed, false) + if PlayerData.job.grade >= 3 then + StartTaxiJob() + else + if IsInAuthorizedVehicle() then + StartTaxiJob() + else + ESX.ShowNotification(_U('must_in_taxi')) + end + end - end + else - end, - function(data, menu) - menu.close() - end - ) + if PlayerData.job.grade >= 3 then + ESX.ShowNotification(_U('must_in_vehicle')) + else + ESX.ShowNotification(_U('must_in_taxi')) + end + end + + end + + end + + end + + end, function(data, menu) + menu.close() + end) + +end + +function IsInAuthorizedVehicle() + local playerPed = PlayerPedId() + local vehModel = GetEntityModel(GetVehiclePedIsIn(playerPed, false)) + + for i=1, #Config.AuthorizedVehicles, 1 do + if vehModel == GetHashKey(Config.AuthorizedVehicles[i].model) then + return true + end + end + + return false end function OpenGetStocksMenu() @@ -818,7 +856,7 @@ Citizen.CreateThread(function() TriggerServerEvent('esx_society:putVehicleInGarage', 'taxi', vehicleProps) ESX.Game.DeleteVehicle(CurrentActionData.vehicle) else - if GetEntityModel(CurrentActionData.vehicle) == GetHashKey('taxi') then + if IsInAuthorizedVehicle() then ESX.Game.DeleteVehicle(CurrentActionData.vehicle) if Config.MaxInService ~= -1 then @@ -837,41 +875,6 @@ Citizen.CreateThread(function() if IsControlJustReleased(0, Keys['F6']) and GetLastInputMethod(2) and not IsDead and Config.EnablePlayerManagement and PlayerData.job ~= nil and PlayerData.job.name == 'taxi' then OpenMobileTaxiActionsMenu() - elseif IsControlJustReleased(0, Keys['DELETE']) and GetLastInputMethod(2) and not IsDead then - - if OnJob then - StopTaxiJob() - else - - if PlayerData.job ~= nil and PlayerData.job.name == 'taxi' then - - local playerPed = PlayerPedId() - if IsPedInAnyVehicle(playerPed, false) then - - local vehicle = GetVehiclePedIsIn(playerPed, false) - if PlayerData.job.grade >= 3 then - StartTaxiJob() - else - if GetEntityModel(vehicle) == GetHashKey('taxi') then - StartTaxiJob() - else - ESX.ShowNotification(_U('must_in_taxi')) - end - end - - else - - if PlayerData.job.grade >= 3 then - ESX.ShowNotification(_U('must_in_vehicle')) - else - ESX.ShowNotification(_U('must_in_taxi')) - end - - end - - end - - end end end end) diff --git a/locales/br.lua b/locales/br.lua index 714c9a79..ba064905 100644 --- a/locales/br.lua +++ b/locales/br.lua @@ -17,8 +17,10 @@ Locales['br'] = { ['amount_invalid'] = 'Valor inválido', ['press_to_open'] = 'Pressione ~INPUT_CONTEXT~ para acessar o menu', ['billing'] = 'Faturamento', + ['billing_sent'] = 'the bill has been registered!', ['invoice_amount'] = 'Valor da fatura', ['no_players_near'] = 'Nenhum jogador nas proximidades', + ['start_job'] = 'start / stop driving NPC jobs', ['drive_search_pass'] = 'Dirigindo em busca de ~y~passageiros', ['customer_found'] = 'Você ~g~encontrou~s~ um passageiro, dirija até o destino', ['client_unconcious'] = 'Seu passageiro está ~r~insconsciente~w~. Procure por outro.', diff --git a/locales/de.lua b/locales/de.lua index 0af860aa..2b68db63 100644 --- a/locales/de.lua +++ b/locales/de.lua @@ -17,8 +17,10 @@ Locales['de'] = { ['amount_invalid'] = 'Betrag ungültig', ['press_to_open'] = 'Drücke ~INPUT_CONTEXT~ um das Menü zu öffnen', ['billing'] = 'Rechnung', + ['billing_sent'] = 'the bill has been registered!', ['invoice_amount'] = 'Rechnugsbetrag', ['no_players_near'] = 'Kein Spieler in der Nähe', + ['start_job'] = 'start / stop driving NPC jobs', ['drive_search_pass'] = 'Auf der Suche nach ~y~Passagieren', ['customer_found'] = 'du hast einen Passagier ~g~gefunden~s~ , Fahre in zum Ziel', ['client_unconcious'] = 'dein Passagier ist ~r~bewusstlos~s~. Suche nach einem anderen.', diff --git a/locales/en.lua b/locales/en.lua index e749d5d4..c0d6ac20 100644 --- a/locales/en.lua +++ b/locales/en.lua @@ -17,8 +17,10 @@ Locales['en'] = { ['amount_invalid'] = 'amount invalid', ['press_to_open'] = 'press ~INPUT_CONTEXT~ to access the menu', ['billing'] = 'billing', + ['billing_sent'] = 'the bill has been registered!', ['invoice_amount'] = 'invoice amount', ['no_players_near'] = 'no players nearby', + ['start_job'] = 'start / stop driving NPC jobs', ['drive_search_pass'] = 'driving in search of ~y~passengers', ['customer_found'] = 'you have ~g~found~s~ a customer, drive until last', ['client_unconcious'] = 'your client is ~r~unconscious~s~. Look for another one.', diff --git a/locales/fi.lua b/locales/fi.lua index 243f5e77..f11f442b 100644 --- a/locales/fi.lua +++ b/locales/fi.lua @@ -17,8 +17,10 @@ Locales['fi'] = { ['amount_invalid'] = 'virheellinen summa', ['press_to_open'] = 'paina ~INPUT_CONTEXT~ avataksesi valikko', ['billing'] = 'Laskutus', + ['billing_sent'] = 'the bill has been registered!', ['invoice_amount'] = 'laskun määrä', ['no_players_near'] = 'ei pelaajia lähellä', + ['start_job'] = 'start / stop driving NPC jobs', ['drive_search_pass'] = 'Ajele ympäriinsä etsi uusia ~y~asiakkaita', ['customer_found'] = 'Sinä ~g~löysit~s~ asiakkaan, aja lähemmäksi', ['client_unconcious'] = 'Sinun asiakkaasi on ~r~tajuton~s~. Etsi uusi.', diff --git a/locales/fr.lua b/locales/fr.lua index cc1a381c..d6b4d58f 100644 --- a/locales/fr.lua +++ b/locales/fr.lua @@ -17,8 +17,10 @@ Locales['fr'] = { ['amount_invalid'] = 'montant invalide', ['press_to_open'] = 'appuyez sur ~INPUT_CONTEXT~ pour accéder au menu', ['billing'] = 'facuration', + ['billing_sent'] = 'the bill has been registered!', ['invoice_amount'] = 'montant de la facture', ['no_players_near'] = 'aucun joueur à proximité', + ['start_job'] = 'start / stop driving NPC jobs', ['drive_search_pass'] = 'conduisez à la recherche de ~y~passagers', ['customer_found'] = 'vous avez ~g~trouvé~s~ un client, conduisez jusqu\'à ce dernier', ['client_unconcious'] = 'votre client est ~r~inconscient~w~. Cherchez-en un autre.', diff --git a/locales/pl.lua b/locales/pl.lua index 3d3e0a06..f3430079 100644 --- a/locales/pl.lua +++ b/locales/pl.lua @@ -17,8 +17,10 @@ Locales['pl'] = { ['amount_invalid'] = 'wartość nieprawidłowa', ['press_to_open'] = 'naciśnij ~INPUT_CONTEXT~ aby wejść do menu', ['billing'] = 'rachunek', + ['billing_sent'] = 'the bill has been registered!', ['invoice_amount'] = 'wartość należności', ['no_players_near'] = 'brak graczy w pobliżu', + ['start_job'] = 'start / stop driving NPC jobs', ['drive_search_pass'] = 'jazda w poszukiwaniu ~y~pasażerów', ['customer_found'] = '~g~Znalazłeś~s~ klienta, jedź do niego', ['client_unconcious'] = 'twój jest ~r~nieprzytomny xD~s~. Poszukaj innego.', diff --git a/locales/sv.lua b/locales/sv.lua index 92427b3e..79eff121 100644 --- a/locales/sv.lua +++ b/locales/sv.lua @@ -11,14 +11,17 @@ Locales['sv'] = { ['spawn_veh'] = 'plocka ut taxi', ['spawnpoint_blocked'] = 'det är ett fordon som blockerar spawnpointen!', ['only_taxi'] = 'du kan endast lagra ~y~taxi fordon~s~ här..', + ['taking_service'] = 'du deltog tjänst: ', ['full_service'] = 'du kan inte delta tjänst: ', ['amount_invalid'] = 'ogiltig mängd!', ['press_to_open'] = 'tryck ~INPUT_CONTEXT~ för att öppna menyn.', ['billing'] = 'skapa räkning', + ['billing_sent'] = 'räkningen har registrerats!', ['invoice_amount'] = 'faktureringsbelopp', ['no_players_near'] = 'det finns ingen spelare i närheten!', - ['drive_search_pass'] = 'åk runt för att hitta ~y~kunder~s~', + ['start_job'] = 'starta / sluta köra NPC', + ['drive_search_pass'] = 'Åtk runt för att hitta ~y~kunder~s~', ['customer_found'] = 'du har ~g~hittat~s~ en kund!', ['client_unconcious'] = 'din kund är ~r~medvetslös~s~. Hitta en ny.', ['arrive_dest'] = 'du har ~g~anlänt~s~ till din destination',