Skip to content

Commit

Permalink
refactor: use lib.triggerClientEvent (#523)
Browse files Browse the repository at this point in the history
* refactor(bridge/server): use lib.triggerClientEvent

* refactor(server): use lib.triggerClientEvent
  • Loading branch information
solareon authored Jul 25, 2024
1 parent 244ecea commit 061e2dd
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 14 deletions.
8 changes: 4 additions & 4 deletions bridge/qb/server/functions.lua
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ local function AddItem(itemName, item)

QBX.Shared.Items[itemName] = item

TriggerClientEvent('QBCore:Client:OnSharedUpdate', -1, 'Items', itemName, item)
lib.triggerClientEvent('QBCore:Client:OnSharedUpdate', -1, 'Items', itemName, item)
TriggerEvent('QBCore:Server:UpdateObject')
return true, 'success'
end
Expand All @@ -164,7 +164,7 @@ local function UpdateItem(itemName, item)
return false, 'item_not_exists'
end
QBX.Shared.Items[itemName] = item
TriggerClientEvent('QBCore:Client:OnSharedUpdate', -1, 'Items', itemName, item)
lib.triggerClientEvent('QBCore:Client:OnSharedUpdate', -1, 'Items', itemName, item)
TriggerEvent('QBCore:Server:UpdateObject')
return true, 'success'
end
Expand Down Expand Up @@ -199,7 +199,7 @@ local function AddItems(items)
end

if not shouldContinue then return false, message, errorItem end
TriggerClientEvent('QBCore:Client:OnSharedUpdateMultiple', -1, 'Items', items)
lib.triggerClientEvent('QBCore:Client:OnSharedUpdateMultiple', -1, 'Items', items)
TriggerEvent('QBCore:Server:UpdateObject')
return true, message, nil
end
Expand All @@ -221,7 +221,7 @@ local function RemoveItem(itemName)

QBX.Shared.Items[itemName] = nil

TriggerClientEvent('QBCore:Client:OnSharedUpdate', -1, 'Items', itemName, nil)
lib.triggerClientEvent('QBCore:Client:OnSharedUpdate', -1, 'Items', itemName, nil)
TriggerEvent('QBCore:Server:UpdateObject')
return true, 'success'
end
Expand Down
20 changes: 10 additions & 10 deletions server/groups.lua
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ function CreateJobs(newJobs)
for jobName, job in pairs(newJobs) do
jobs[jobName] = job
TriggerEvent('qbx_core:server:onJobUpdate', jobName, job)
TriggerClientEvent('qbx_core:client:onJobUpdate', -1, jobName, job)
lib.triggerClientEvent('qbx_core:client:onJobUpdate', -1, jobName, job)
end
end

Expand All @@ -63,7 +63,7 @@ function RemoveJob(jobName)

jobs[jobName] = nil
TriggerEvent('qbx_core:server:onJobUpdate', jobName, nil)
TriggerClientEvent('qbx_core:client:onJobUpdate', -1, jobName, nil)
lib.triggerClientEvent('qbx_core:client:onJobUpdate', -1, jobName, nil)
return true, 'success'
end

Expand All @@ -75,7 +75,7 @@ function CreateGangs(newGangs)
for gangName, gang in pairs(newGangs) do
gangs[gangName] = gang
TriggerEvent('qbx_core:server:onGangUpdate', gangName, gang)
TriggerClientEvent('qbx_core:client:onGangUpdate', -1, gangName, gang)
lib.triggerClientEvent('qbx_core:client:onGangUpdate', -1, gangName, gang)
end
end

Expand All @@ -97,7 +97,7 @@ function RemoveGang(gangName)
gangs[gangName] = nil

TriggerEvent('qbx_core:server:onGangUpdate', gangName, nil)
TriggerClientEvent('qbx_core:client:onGangUpdate', -1, gangName, nil)
lib.triggerClientEvent('qbx_core:client:onGangUpdate', -1, gangName, nil)
return true, 'success'
end

Expand Down Expand Up @@ -151,7 +151,7 @@ local function upsertJobData(name, data)
}
end
TriggerEvent('qbx_core:server:onJobUpdate', name, jobs[name])
TriggerClientEvent('qbx_core:client:onJobUpdate', -1, name, jobs[name])
lib.triggerClientEvent('qbx_core:client:onJobUpdate', -1, name, jobs[name])
end

exports('UpsertJobData', upsertJobData)
Expand All @@ -168,7 +168,7 @@ local function upsertGangData(name, data)
}
end
TriggerEvent('qbx_core:server:onGangUpdate', name, gangs[name])
TriggerClientEvent('qbx_core:client:onGangUpdate', -1, name, gangs[name])
lib.triggerClientEvent('qbx_core:client:onGangUpdate', -1, name, gangs[name])
end

exports('UpsertGangData', upsertGangData)
Expand All @@ -183,7 +183,7 @@ local function upsertJobGrade(name, grade, data)
end
jobs[name].grades[grade] = data
TriggerEvent('qbx_core:server:onJobUpdate', name, jobs[name])
TriggerClientEvent('qbx_core:client:onJobUpdate', -1, name, jobs[name])
lib.triggerClientEvent('qbx_core:client:onJobUpdate', -1, name, jobs[name])
end

exports('UpsertJobGrade', upsertJobGrade)
Expand All @@ -198,7 +198,7 @@ local function upsertGangGrade(name, grade, data)
end
gangs[name].grades[grade] = data
TriggerEvent('qbx_core:server:onGangUpdate', name, gangs[name])
TriggerClientEvent('qbx_core:client:onGangUpdate', -1, name, gangs[name])
lib.triggerClientEvent('qbx_core:client:onGangUpdate', -1, name, gangs[name])
end

exports('UpsertGangGrade', upsertGangGrade)
Expand All @@ -212,7 +212,7 @@ local function removeJobGrade(name, grade)
end
jobs[name].grades[grade] = nil
TriggerEvent('qbx_core:server:onJobUpdate', name, jobs[name])
TriggerClientEvent('qbx_core:client:onJobUpdate', -1, name, jobs[name])
lib.triggerClientEvent('qbx_core:client:onJobUpdate', -1, name, jobs[name])
end

exports('RemoveJobGrade', removeJobGrade)
Expand All @@ -226,7 +226,7 @@ local function removeGangGrade(name, grade)
end
gangs[name].grades[grade] = nil
TriggerEvent('qbx_core:server:onGangUpdate', name, gangs[name])
TriggerClientEvent('qbx_core:client:onGangUpdate', -1, name, gangs[name])
lib.triggerClientEvent('qbx_core:client:onGangUpdate', -1, name, gangs[name])
end

exports('RemoveGangGrade', removeGangGrade)

0 comments on commit 061e2dd

Please sign in to comment.