From 9fabb62be3dc91c3bb6269c7b314c25dcf8a3f1e Mon Sep 17 00:00:00 2001 From: ElPumpo Date: Sun, 2 Dec 2018 16:54:32 +0100 Subject: [PATCH] Await vehicle to load, resolves #80 --- client/main.lua | 39 +++++++++++++++++++++++++++++++++++++++ locales/br.lua | 1 + locales/en.lua | 1 + locales/fi.lua | 1 + locales/fr.lua | 1 + locales/pl.lua | 1 + locales/sv.lua | 1 + 7 files changed, 45 insertions(+) diff --git a/client/main.lua b/client/main.lua index c65a09aa..71ec665e 100644 --- a/client/main.lua +++ b/client/main.lua @@ -390,6 +390,7 @@ function OpenShopMenu() local playerPed = PlayerPedId() DeleteShopInsideVehicles() + WaitForVehicleToLoad(vehicleData.model) ESX.Game.SpawnLocalVehicle(vehicleData.model, Config.Zones.ShopInside.Pos, Config.Zones.ShopInside.Heading, function (vehicle) table.insert(LastVehicles, vehicle) @@ -399,6 +400,7 @@ function OpenShopMenu() end) DeleteShopInsideVehicles() + WaitForVehicleToLoad(firstVehicleData.model) ESX.Game.SpawnLocalVehicle(firstVehicleData.model, Config.Zones.ShopInside.Pos, Config.Zones.ShopInside.Heading, function (vehicle) table.insert(LastVehicles, vehicle) @@ -408,6 +410,27 @@ function OpenShopMenu() end +function WaitForVehicleToLoad(modelHash) + modelHash = (type(modelHash) == 'number' and modelHash or GetHashKey(modelHash)) + + if not HasModelLoaded(modelHash) then + RequestModel(modelHash) + + while not HasModelLoaded(modelHash) do + Citizen.Wait(1) + + DisableControlAction(0, Keys['TOP'], true) + DisableControlAction(0, Keys['DOWN'], true) + DisableControlAction(0, Keys['LEFT'], true) + DisableControlAction(0, Keys['RIGHT'], true) + DisableControlAction(0, 176, true) -- ENTER key + DisableControlAction(0, Keys['BACKSPACE'], true) + + drawLoadingText(_U('shop_awaiting_model'), 255, 255, 255, 255) + end + end +end + function OpenResellerMenu() ESX.UI.Menu.CloseAll() @@ -1025,3 +1048,19 @@ Citizen.CreateThread(function() EnableInteriorProp(interiorID, 'csr_beforeMission') -- Load large window RefreshInterior(interiorID) end) + +function drawLoadingText(text, red, green, blue, alpha) + SetTextFont(4) + SetTextProportional(0) + SetTextScale(0.0, 0.5) + SetTextColour(red, green, blue, alpha) + SetTextDropShadow(0, 0, 0, 0, 255) + SetTextEdge(1, 0, 0, 0, 255) + SetTextDropShadow() + SetTextOutline() + SetTextCentre(true) + + BeginTextCommandDisplayText("STRING") + AddTextComponentSubstringPlayerName(text) + EndTextCommandDisplayText(0.5, 0.5) +end \ No newline at end of file diff --git a/locales/br.lua b/locales/br.lua index 1a61e781..eb72cf15 100644 --- a/locales/br.lua +++ b/locales/br.lua @@ -11,6 +11,7 @@ Locales['br'] = { ['buy_vehicle_shop'] = 'comprar %s por $%s?', ['buy_vehicle'] = 'comprar veículo', ['car_dealer'] = 'Concessionária de carros', + ['shop_awaiting_model'] = 'the vehicle is currently ~g~DOWNLOADING & LOADING~s~ please wait', ['create_bill'] = 'criar recibo', ['dealer_boss'] = 'Concessionária de carros - Chefe', ['delivered'] = 'veículo ~g~entregue~s~ para o revendedor', diff --git a/locales/en.lua b/locales/en.lua index d28ee59b..02078493 100644 --- a/locales/en.lua +++ b/locales/en.lua @@ -11,6 +11,7 @@ Locales['en'] = { ['buy_vehicle_shop'] = 'do you want to purchase %s for $%s?', ['buy_vehicle'] = 'buy vehicle', ['car_dealer'] = 'car Dealership', + ['shop_awaiting_model'] = 'the vehicle is currently ~g~DOWNLOADING & LOADING~s~ please wait', ['create_bill'] = 'create bill', ['dealer_boss'] = 'car Dealer - Boss', ['delivered'] = 'the vehicle has been ~g~delivered~s~ to the dealer', diff --git a/locales/fi.lua b/locales/fi.lua index 56be2ca2..3af97356 100644 --- a/locales/fi.lua +++ b/locales/fi.lua @@ -11,6 +11,7 @@ Locales['fi'] = { ['buy_vehicle_shop'] = 'haluatko ostaa ajoneuvon %s hintaan $%s?', ['buy_vehicle'] = 'osta ajoneuvo', ['car_dealer'] = 'autokauppa', + ['shop_awaiting_model'] = 'the vehicle is currently ~g~DOWNLOADING & LOADING~s~ please wait', ['create_bill'] = 'tee lasku', ['dealer_boss'] = 'autokauppa - Pomo', ['delivered'] = 'ajoneuvo on ~g~kuljetettu~s~ myyjälle', diff --git a/locales/fr.lua b/locales/fr.lua index 7a77e70e..6b5bb8d5 100644 --- a/locales/fr.lua +++ b/locales/fr.lua @@ -11,6 +11,7 @@ Locales['fr'] = { ['buy_vehicle_shop'] = 'acheter %s pour $%s?', ['buy_vehicle'] = 'acheter véhicule', ['car_dealer'] = 'concessionnaire', + ['shop_awaiting_model'] = 'the vehicle is currently ~g~DOWNLOADING & LOADING~s~ please wait', ['create_bill'] = 'créer facture', ['dealer_boss'] = 'concessionnaire - Patron', ['delivered'] = 'véhicule ~g~rendu~s~ au concessionnaire', diff --git a/locales/pl.lua b/locales/pl.lua index f2275f38..bbc6f76e 100644 --- a/locales/pl.lua +++ b/locales/pl.lua @@ -11,6 +11,7 @@ Locales['pl'] = { ['buy_vehicle_shop'] = 'czy chcesz kupić %s za $%s?', ['buy_vehicle'] = 'kup pojazd', ['car_dealer'] = 'sprzedawca Aut', + ['shop_awaiting_model'] = 'the vehicle is currently ~g~DOWNLOADING & LOADING~s~ please wait', ['create_bill'] = 'stwórz fakture', ['dealer_boss'] = 'salon samochodowy - Szef', ['delivered'] = 'pojazd został ~g~dostarczony~s~ do salonu', diff --git a/locales/sv.lua b/locales/sv.lua index 38a1346d..2d7e6a1e 100644 --- a/locales/sv.lua +++ b/locales/sv.lua @@ -11,6 +11,7 @@ Locales['sv'] = { ['buy_vehicle_shop'] = 'vill du köpa in %s för %s SEK?', ['buy_vehicle'] = 'Köp in fordon', ['car_dealer'] = 'bilförsäljare', + ['shop_awaiting_model'] = 'ditt fordon håller på att ~g~LADDA NER & LÄSA IN~s~ vänta tills det är klart', ['create_bill'] = 'ge faktura', ['dealer_boss'] = 'chefmeny', ['delivered'] = 'fordonet har ~g~lämnats tillbaka~s~ till bilförsäljaren',