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

Adding some new events #80

Closed
wants to merge 6 commits into from
Closed
Show file tree
Hide file tree
Changes from all 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
16 changes: 16 additions & 0 deletions client/interactions.lua
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,22 @@ local function isTooFar(player, distance, maxDistance)
return false
end

RegisterNetEvent('police:client:checkBank', function()
local coords = GetEntityCoords(cache.ped)
local player, _, distance = lib.getClosestPlayer(coords)
if isTooFar(player, distance) then return end
local playerId = GetPlayerServerId(player)
TriggerServerEvent('police:server:checkBank', playerId)
end)

RegisterNetEvent('police:client:checkLicenses', function()
local coords = GetEntityCoords(cache.ped)
local player, _, distance = lib.getClosestPlayer(coords)
if isTooFar(player, distance) then return end
local playerId = GetPlayerServerId(player)
TriggerServerEvent('police:server:checkLicenses', playerId)
end)

RegisterNetEvent('police:client:SearchPlayer', function()
local coords = GetEntityCoords(cache.ped)
local player, _, distance = lib.getClosestPlayer(coords)
Expand Down
35 changes: 35 additions & 0 deletions server/main.lua
Original file line number Diff line number Diff line change
Expand Up @@ -321,6 +321,41 @@ RegisterNetEvent('police:server:FlaggedPlateTriggered', function(radar, plate, s
end
end)

RegisterNetEvent('police:server:checkBank', function(playerId)
local src = source
if isTargetTooFar(src, playerId, 2.5) then return end

local player = exports.qbx_core:GetPlayer(src)
local searchedPlayer = exports.qbx_core:GetPlayer(playerId)
if not player or not searchedPlayer then return end

if searchedPlayer then
TriggerClientEvent('chat:addMessage', source, {
template = '<div class="chat-message success">Player has $'..searchedPlayer.PlayerData.money.bank..' in his bank account.</div>',
})
end
end)

RegisterNetEvent('police:server:checkLicenses', function(playerId)
local src = source
if isTargetTooFar(src, playerId, 2.5) then return end

local searchedPlayer = exports.qbx_core:GetPlayer(playerId)
if searchedPlayer then
local licences = searchedPlayer.PlayerData.metadata.licences
local str = ""

for k,v in pairs(licences) do
if k and v then
str = str .. k:gsub("^%l", string.upper) .. ', '
end
end
TriggerClientEvent('chat:addMessage', source, {
template = '<div class="chat-message success">Player Licenses: ' .. (#str == 0 and "No Licenses" or str:sub(1,#str-2)) .. '</div>',
})
end
end)

RegisterNetEvent('police:server:SearchPlayer', function(playerId)
local src = source
if isTargetTooFar(src, playerId, 2.5) then return end
Expand Down
Loading