Skip to content

Commit

Permalink
fix DOM manipulation & exports (#8)
Browse files Browse the repository at this point in the history
  • Loading branch information
TonybynMp4 committed Oct 17, 2023
1 parent 238555c commit 0ce2271
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 10 deletions.
8 changes: 4 additions & 4 deletions client/main.lua
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ local function fight(ped)
if CheckJob(Config.Events.fight.jobwhitelist, QBX.PlayerData.job) and QBX.PlayerData.job.onduty then return end

fightAntiSpam = true
exports['qbx-dispatch']:Fight()
exports.qbx_dispatch:Fight()
SetTimeout(30 * 1000, function() -- Wait 30 seconds to avoid spam.
fightAntiSpam = false
end)
Expand All @@ -129,9 +129,9 @@ local function shotfired(ped)

shotsfiredAntiSpam = true
if cache.vehicle then
exports['qbx-dispatch']:DriveBy()
exports.qbx_dispatch:DriveBy()
else
exports['qbx-dispatch']:Shooting()
exports.qbx_dispatch:Shooting()
end
SetTimeout(30 * 1000, function() -- Wait 30 seconds to avoid spam.
shotsfiredAntiSpam = false
Expand Down Expand Up @@ -195,7 +195,7 @@ RegisterNetEvent('qbx-dispatch:client:AddCall', function(Data, CallId)
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",
id = CallId,
Expand Down
1 change: 1 addition & 0 deletions config.lua
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ Config.AllowAnonCalls = true -- Requires UseNpwd = true, Allow anonymous Texts t

Config.UseMPH = false -- Use MPH instead of KMH

-- These need to be tested and might spam the dispatch
Config.Events = {
fight = {
enabled = true,
Expand Down
15 changes: 9 additions & 6 deletions html/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,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-road" style="margin-right: .5vh;"></span> ${locale('distance', {distance: data.distance})}</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 Expand Up @@ -141,10 +141,13 @@ function NewCall(Id, length, data) {
UpdateCalls();

setTimeout(() => {
document.getElementById(Id).classList.add("removing");
const call = document.getElementById(Id);
if (!call) return;
call.classList.add("removing");

setTimeout(() => {
document.getElementById(Id).remove();
if (!call) return;
call.remove();
UpdateCalls();
}, 1500);
}, length);
Expand All @@ -153,7 +156,7 @@ function NewCall(Id, length, data) {
function UpdateCalls() {
const calls = document.getElementsByClassName('dispatch-call')
if (calls.length == 0) return;
Object.keys(calls).forEach(function(call, index) {
Object.values(calls).forEach(function(call, index) {
if (index == 0) return;
const callButtons = call.getElementsByClassName('call-buttons')[0];
if (callButtons) {
Expand All @@ -177,7 +180,7 @@ function RemoveCall() {
const calls = document.getElementsByClassName('dispatch-call')
if (calls.length == 0) return;
if (calls[0].classList.contains("animate__slideOutRight")) return;
calls[0].classList.add("animate__slideOutRight");
calls[0].classList.add("removing");

setTimeout(() => {
calls[0].remove();
Expand Down

0 comments on commit 0ce2271

Please sign in to comment.