Skip to content

Commit

Permalink
Add distance to call (#7)
Browse files Browse the repository at this point in the history
  • Loading branch information
TonybynMp4 committed Oct 17, 2023
1 parent 714a9cc commit 238555c
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 6 deletions.
1 change: 1 addition & 0 deletions client/main.lua
Original file line number Diff line number Diff line change
Expand Up @@ -194,6 +194,7 @@ RegisterNetEvent('qbx-dispatch:client:AddCall', function(Data, CallId)
if Config.OnlyOnDuty and not QBX.PlayerData.job.onduty then return end
if not Data.coords then return end
if Data.speed then Data.speed = (Config.UseMPH and math.ceil(Data.speed * 2.236936) .. " Mph") or (math.ceil(Data.speed * 3.6) .. " Km/h") end
Data.distance = math.round(#(GetEntityCoords(cache.ped) - Data.coords))

SendNUIMessage({
type = "AddCall",
Expand Down
4 changes: 2 additions & 2 deletions fxmanifest.lua
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ game 'gta5'

author 'Tonybyn_Mp4'
description 'Dispatch resource for the Qbox framework'
version '1.2.1'
version '1.2.2'

shared_scripts {
"@qbx_core/import.lua",
Expand Down Expand Up @@ -40,4 +40,4 @@ dependencies {
}

lua54 'yes'
use_experimental_fxv2_oal 'yes'
use_experimental_fxv2_oal 'yes'
15 changes: 11 additions & 4 deletions html/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,15 @@ document.addEventListener('DOMContentLoaded', () => {
});

// returns the locale for a given path (like in the core's lang:t)
function locale(localeindex) {
return locales[localeindex];
function locale(localeindex, args) {
if (!locales || !locales[localeindex]) return localeindex;
let locale = locales[localeindex];
if (args) {
Object.keys(args).forEach(function (key) {
locale = locale.replace('${' + key + '}', args[key]);
});
}
return locale;
}

function NewCall(Id, length, data) {
Expand All @@ -32,8 +39,8 @@ function NewCall(Id, length, data) {
<div class="top-bar-name">${data.title}</div>
</div>
<div class="informations-holder">
<div class="information"><span class="fas fa-stopwatch" style="margin-right: .5vh;"></span> ${locale('justnow')}
</div>
<div class="information"><span class="fas fa-stopwatch" style="margin-right: .5vh;"></span> ${locale('justnow')}</div>
<div class="information"><span class="fas fa-road" style="margin-right: .5vh;"></span> ${locale('distance', {distance: data.distance})}</div>
`

if (data.location || data.heading) {
Expand Down
1 change: 1 addition & 0 deletions locales/en.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
{
"justnow": "A few seconds ago",
"distance": "${distance} meters away",
"automatic": "Automatic gunfire",
"accept": " Respond",
"deny": " Dismiss"
Expand Down
1 change: 1 addition & 0 deletions locales/fr.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
{
"justnow": "A l'instant",
"distance": "à ${distance} mètres",
"automatic": "Tirs d'arme automatique",
"accept": " Répondre",
"deny": " Ignorer"
Expand Down

0 comments on commit 238555c

Please sign in to comment.