Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Translation to pt-br and loadmodel for low specs #73

Closed
wants to merge 15 commits into from
Closed
Changes from 10 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 29 additions & 11 deletions client/main.lua
Original file line number Diff line number Diff line change
@@ -29,13 +29,13 @@ end

local function confirmationCheck()
local alert = lib.alertDialog({
header = 'Wait a minute!',
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These are not language files. The default language for prompts is English.
If you want to translate this messages, create keys in locales/en.json and locales/es.json.

content = 'Are you sure you wish to proceed?',
header = 'Espere um minuto!',
content = 'Tem certeza de que deseja prosseguir?',
centered = true,
cancel = true,
labels = {
cancel = 'No',
confirm = 'Yes',
cancel = 'Não',
confirm = 'Sim',
}
})
return alert
@@ -46,9 +46,9 @@ local function showVehicleFinanceMenu(data)
local vehLabel = VEHICLES[data.vehicle].brand..' '..VEHICLES[data.vehicle].name
local vehFinance = {
{
title = 'Finance Information',
title = locale('menus.veh_finance_title'),
icon = 'circle-info',
description = string.format('Name: %s\nPlate: %s\nRemaining Balance: $%s\nRecurring Payment Amount: $%s\nPayments Left: %s', vehLabel, data.vehiclePlate, lib.math.groupdigits(data.balance), lib.math.groupdigits(data.paymentAmount), data.paymentsLeft),
description = string.format('Nome: %s\nPlaca: %s\nSaldo restante: R$%s\nValor das parcelas: R$%s\nParcelas restantes: %s', vehLabel, data.vehiclePlate, lib.math.groupdigits(data.balance), lib.math.groupdigits(data.paymentAmount), data.paymentsLeft),
readOnly = true,
},
{
@@ -152,16 +152,19 @@ end
---@param targetShowroomVehicle integer vehicleName
---@param buyVehicle string model
local function openFinance(targetShowroomVehicle, buyVehicle)
local dialog = lib.inputDialog(VEHICLES[buyVehicle].brand:upper()..' '..VEHICLES[buyVehicle].name:upper()..' - $'..getVehPrice(targetShowroomVehicle), {
local dialog = lib.inputDialog(VEHICLES[buyVehicle].brand:upper()..' '..VEHICLES[buyVehicle].name:upper()..' - R$'..getVehPrice(targetShowroomVehicle), {
{
type = 'number',
label = locale('menus.financesubmit_downpayment')..sharedConfig.finance.minimumDown..'%',
placeholder = string.format('%.2f', math.ceil(VEHICLES[buyVehicle].price * sharedConfig.finance.minimumDown / 100)),
default = math.ceil(VEHICLES[buyVehicle].price * sharedConfig.finance.minimumDown / 100),
min = VEHICLES[buyVehicle].price * sharedConfig.finance.minimumDown / 100,
max = VEHICLES[buyVehicle].price
},
{
type = 'number',
label = locale('menus.financesubmit_totalpayment')..sharedConfig.finance.maximumPayments,
default = 2,
min = 2,
max = sharedConfig.finance.maximumPayments
}
@@ -273,7 +276,7 @@ end
---@param targetVehicle integer
local function openCustomFinance(targetVehicle)
local vehicle = config.shops[insideShop].showroomVehicles[targetVehicle].vehicle
local dialog = lib.inputDialog(getVehBrand(targetVehicle):upper()..' '..vehicle:upper()..' - $'..getVehPrice(targetVehicle), {
local dialog = lib.inputDialog(getVehBrand(targetVehicle):upper()..' '..vehicle:upper()..' - R$'..getVehPrice(targetVehicle), {
{
type = 'number',
label = locale('menus.financesubmit_downpayment')..sharedConfig.finance.minimumDown..'%',
@@ -337,6 +340,7 @@ local function openVehicleSellMenu(targetVehicle)
local swapOption = {
title = locale('menus.swap_header'),
description = locale('menus.swap_txt'),
icon = 'right-left',
onSelect = openVehicleCategoryMenu,
args = {
targetVehicle = targetVehicle
@@ -349,6 +353,7 @@ local function openVehicleSellMenu(targetVehicle)
options[#options + 1] = {
title = locale('menus.test_header'),
description = locale('menus.freeuse_test_txt'),
icon = 'fas fa-car',
event = 'qbx_vehicleshop:client:testDrive',
args = {
vehicle = vehicle
@@ -360,6 +365,7 @@ local function openVehicleSellMenu(targetVehicle)
options[#options + 1] = {
title = locale('menus.freeuse_buy_header'),
description = locale('menus.freeuse_buy_txt'),
icon = 'dollar-sign',
serverEvent = 'qbx_vehicleshop:server:buyShowroomVehicle',
args = {
buyVehicle = vehicle
@@ -371,6 +377,7 @@ local function openVehicleSellMenu(targetVehicle)
options[#options + 1] = {
title = locale('menus.finance_header'),
description = locale('menus.freeuse_finance_txt'),
icon = 'fa-solid fa-file-invoice-dollar',
onSelect = function()
openFinance(targetVehicle, vehicle)
end
@@ -382,6 +389,7 @@ local function openVehicleSellMenu(targetVehicle)
options[1] = {
title = locale('menus.managed_sell_header'),
description = locale('menus.managed_sell_txt'),
icon = 'fa-solid fa-hand-holding-dollar',
onSelect = function()
sellVehicle(vehicle)
end,
@@ -391,6 +399,7 @@ local function openVehicleSellMenu(targetVehicle)
options[#options + 1] = {
title = locale('menus.test_header'),
description = locale('menus.managed_test_txt'),
icon = 'fas fa-car',
onSelect = function()
startTestDrive(vehicle)
end
@@ -401,6 +410,7 @@ local function openVehicleSellMenu(targetVehicle)
options[#options + 1] = {
title = locale('menus.finance_header'),
description = locale('menus.managed_finance_txt'),
icon = 'fa-solid fa-file-invoice-dollar',
onSelect = function()
openCustomFinance(targetVehicle)
end
@@ -412,7 +422,8 @@ local function openVehicleSellMenu(targetVehicle)

lib.registerContext({
id = 'vehicleMenu',
title = getVehBrand(targetVehicle):upper()..' '..getVehName(targetVehicle):upper()..' - $'..getVehPrice(targetVehicle),
title = getVehBrand(targetVehicle):upper()..' '..getVehName(targetVehicle):upper(),
description = '**R$'..getVehPrice(targetVehicle)..'**',
options = options
})
lib.showContext('vehicleMenu')
@@ -423,18 +434,23 @@ end
local function startTestDriveTimer(time)
local gameTimer = GetGameTimer()
local timeMs = time * 1000
local outVeh = false
while not IsPedInAnyVehicle(cache.ped, false) do Wait(0) end

CreateThread(function()
while inTestDrive do
local currentGameTime = GetGameTimer()
local secondsLeft = currentGameTime - gameTimer
if currentGameTime < gameTimer + timeMs and secondsLeft >= timeMs - 50 then
if currentGameTime < gameTimer + timeMs and secondsLeft >= timeMs - 50 or outVeh then
TriggerServerEvent('qbx_vehicleshop:server:deleteVehicle', testDriveVeh)
testDriveVeh = 0
inTestDrive = false
exports.qbx_core:Notify(locale('general.testdrive_complete'), 'success')
end
qbx.drawText2d({ text = locale('general.testdrive_timer')..math.ceil(time - secondsLeft / 1000), coords = vec2(1.0, 1.38), scale = 0.5})
if not IsPedInAnyVehicle(cache.ped, false) or IsPlayerDead(cache.playerId) then
outVeh = true
end
Wait(0)
end
end)
@@ -507,7 +523,7 @@ end
---@param coords vector4
---@return number vehicleEntity
local function createShowroomVehicle(model, coords)
lib.requestModel(model, 1000)
lib.requestModel(model, 5000)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Perhabs may be worth use requestModelTimeout

local veh = CreateVehicle(model, coords.x, coords.y, coords.z, coords.w, false, false)
SetModelAsNoLongerNeeded(model)
SetVehicleOnGroundProperly(veh)
@@ -598,6 +614,8 @@ RegisterNetEvent('qbx_vehicleshop:client:testDrive', function(args)
local plate = 'TEST'..lib.string.random('1111')
local netId = lib.callback.await('qbx_vehicleshop:server:spawnVehicle', false, args.vehicle, testDrive.spawn, plate)
testDriveVeh = netId
while not NetworkGetEntityFromNetworkId(netId) do Wait(100) end
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lib.waitFor should be better option


exports.qbx_core:Notify(locale('general.testdrive_timenoti', testDrive.limit), 'inform')
startTestDriveTimer(testDrive.limit * 60)
end)
2 changes: 1 addition & 1 deletion config/client.lua
Original file line number Diff line number Diff line change
@@ -2,7 +2,7 @@ return {
useTarget = false,
debugPoly = false,
enableFreeUseBuy = true, -- Allows players to buy from NPC shops
requestModelTimeout = 5000, -- load model timeout for oxlib
requestModelTimeout = 100000, -- load model timeout for oxlib
enableTestDrive = true,

finance = {
2 changes: 1 addition & 1 deletion config/server.lua
Original file line number Diff line number Diff line change
@@ -3,7 +3,7 @@ return {
finance = {
paymentWarning = 10, -- time in minutes that player has to make payment before repo
paymentInterval = 24, -- time in hours between payment being due
preventSelling = false, -- prevents players from using /transfervehicle if financed
preventSelling = true, -- prevents players from using /transfervehicle if financed
},
saleTimeout = 60000 -- Delay between attempts to sell/gift a vehicle. Prevents abuse
}
1 change: 1 addition & 0 deletions locales/en.json
Original file line number Diff line number Diff line change
@@ -41,6 +41,7 @@
"goback_header": "Go Back",
"veh_price": "Price: $",
"veh_platetxt": "Plate: ",
"veh_finance_title": "Finance Information",
"veh_finance": "Vehicle Payment",
"veh_finance_balance": "Total Balance Remaining",
"veh_finance_currency": "$",
84 changes: 84 additions & 0 deletions locales/pt-br.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
{
"error": {
"testdrive_alreadyin": "Já está em um test drive",
"testdrive_return": "Este não é o seu veículo de test drive",
"Invalid_ID": "ID de jogador fornecido inválido",
"playertoofar": "Este jogador não está perto o suficiente",
"notenoughmoney": "Dinheiro insuficiente",
"minimumallowed": "O pagamento mínimo permitido é $",
"overpaid": "Você pagou a mais",
"alreadypaid": "O veículo já está quitado",
"notworth": "O veículo não vale tanto",
"downtoosmall": "Pagamento inicial muito pequeno",
"exceededmax": "Excedido o valor máximo de pagamento",
"repossessed": "Seu veículo com placa %s foi recuperado",
"buyerinfo": "Não foi possível obter informações do comprador",
"notinveh": "Você deve estar no veículo que deseja transferir",
"vehinfo": "Não foi possível obter informações do veículo",
"notown": "Você não possui este veículo",
"buyertoopoor": "O comprador não tem dinheiro suficiente",
"nofinanced": "Você não possui nenhum veículo financiado",
"financed": "Este veículo está financiado",
"buyerdeclined": "O jogador recusou a transação",
"sale_timeout": "Espere um pouco antes de negociar seu veículo"
},
"success": {
"purchased": "Parabéns pela compra!",
"earned_commission": "Você ganhou $ %s de comissão",
"gifted": "Você presenteou seu veículo",
"received_gift": "Você recebeu um veículo de presente",
"soldfor": "Você vendeu seu veículo por $",
"boughtfor": "Você comprou um veículo por $"
},
"menus": {
"vehHeader_header": "Opções do Veículo",
"vehHeader_txt": "Interaja com o veículo atual",
"financed_header": "Veículos Financiados",
"finance_txt": "Veja seus veículos possuídos",
"returnTestDrive_header": "Finalizar Test Drive",
"categories_header": "Categorias",
"goback_header": "Voltar",
"veh_price": "Preço: $",
"veh_platetxt": "Placa: ",
"veh_finance_title": "Informações de Financiamento",
"veh_finance": "Pagamento do Veículo",
"veh_finance_balance": "Saldo Total Restante",
"veh_finance_currency": "$",
"veh_finance_total": "Pagamentos Totais Restantes",
"veh_finance_reccuring": "Valor do Pagamento Recorrente",
"veh_finance_pay": "Efetuar um pagamento",
"veh_finance_payoff": "Quitar veículo",
"veh_finance_payment": "Valor do Pagamento ($)",
"submit_text": "Enviar",
"test_header": "Test Drive",
"finance_header": "Financiar Veículo",
"owned_vehicles_header": "Veículos Possuídos",
"swap_header": "Trocar Veículo",
"swap_txt": "Troque o veículo atualmente selecionado",
"financesubmit_downpayment": "Valor do Pagamento Inicial - Mín ",
"financesubmit_totalpayment": "Pagamentos Totais - Máx ",
"freeuse_test_txt": "Teste o veículo atualmente selecionado",
"freeuse_buy_header": "Comprar Veículo",
"freeuse_buy_txt": "Compre o veículo atualmente selecionado",
"freeuse_finance_txt": "Financie o veículo atualmente selecionado",
"managed_test_txt": "Permita que o jogador faça um test drive",
"managed_sell_header": "Vender Veículo",
"managed_sell_txt": "Venda o veículo para o jogador",
"managed_finance_txt": "Financie o veículo para o jogador",
"submit_ID": "ID do Servidor (#)",
"keypress_showFinanceMenu": "[E] Abrir Menu de Finanças",
"keypress_vehicleViewMenu": "[E] Visualizar Veículo"
},
"general": {
"testdrive_timer": "Tempo Restante do Test Drive: ",
"vehinteraction": "Interação com o Veículo",
"testdrive_timenoti": "Você tem %s minutos restantes",
"testdrive_complete": "Test drive do veículo concluído",
"paymentduein": "Seu pagamento do veículo vence em %s minutos",
"command_transfervehicle": "Presenteie ou venda seu veículo",
"command_transfervehicle_help": "ID do comprador",
"command_transfervehicle_amount": "Valor da venda (opcional)",
"transfervehicle_confirm": "Confirmar a troca de %s %s por $ %s"
}
}

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the last line should be empty

16 changes: 4 additions & 12 deletions server/main.lua
Original file line number Diff line number Diff line change
@@ -93,16 +93,9 @@ lib.callback.register('qbx_vehicleshop:server:GetVehiclesByName', function(sourc
local src = source
local player = exports.qbx_core:GetPlayer(src)
if not player then return end
local vehicles = FetchVehicleEntitiesByCitizenId(player.PlayerData.citizenid)
local financeVehicles = FetchFinancedVehicleEntitiesByCitizenId(player.PlayerData.citizenid)
for _, v in pairs(financeVehicles) do
vehicles[v.vehicleId].balance = v.balance
vehicles[v.vehicleId].paymentamount = v.paymentamount
vehicles[v.vehicleId].paymentsleft = v.paymentsleft
vehicles[v.vehicleId].financetime = v.financetime
end
if vehicles[1] then
return vehicles
if #financeVehicles > 0 then
return financeVehicles
end
end)

@@ -412,12 +405,11 @@ end)
RegisterNetEvent('qbx_vehicleshop:server:checkFinance', function()
local src = source
local player = exports.qbx_core:GetPlayer(src)
local result = FetchFinancedVehicleEntitiesByCitizenId(player.PlayerData.citizenid)
if not result[1] then return end
local vehicles = FetchFinancedVehicleEntitiesByCitizenId(player.PlayerData.citizenid)
if not vehicles[1] then return end

exports.qbx_core:Notify(src, locale('general.paymentduein', config.finance.paymentWarning))
Wait(config.finance.paymentWarning * 60000)
local vehicles = FetchFinancedVehicleEntitiesByCitizenId(player.PlayerData.citizenid)
for _, v in pairs(vehicles) do
local plate = v.plate
DeleteVehicleEntity(v.id)
2 changes: 1 addition & 1 deletion server/storage.lua
Original file line number Diff line number Diff line change
@@ -93,7 +93,7 @@ end
---@param citizenId string
---@return VehicleFinancingEntity
function FetchFinancedVehicleEntitiesByCitizenId(citizenId)
return MySQL.query.await('SELECT vehicle_financing.* FROM vehicle_financing INNER JOIN player_vehicles ON player_vehicles.citizenid = ? WHERE vehicle_financing.vehicleId = player_vehicles.id AND vehicle_financing.balance > 0 AND vehicle_financing.financetime > 1', {citizenId})
return MySQL.query.await('SELECT player_vehicles.vehicle, player_vehicles.plate, vehicle_financing.* FROM player_vehicles LEFT JOIN vehicle_financing ON player_vehicles.id = vehicle_financing.vehicleId WHERE citizenid = ?', {citizenId})
end

---@param license string
Loading