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

Update SearchPlayer main.lua #520

Closed
wants to merge 1 commit into from
Closed
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
27 changes: 12 additions & 15 deletions server/main.lua
Original file line number Diff line number Diff line change
Expand Up @@ -674,22 +674,19 @@ RegisterNetEvent('qb-policejob:server:evidence', function(currentEvidence)
})
end)

RegisterNetEvent('police:server:SearchPlayer', function()
RegisterNetEvent('police:server:SearchPlayer', function(playerId)
local src = source
local Player = QBCore.Functions.GetPlayer(src)
if not Player then return end
local PlayerData = Player.PlayerData
if PlayerData.job.type ~= 'leo' then return end
local player, distance = QBCore.Functions.GetClosestPlayer(src)
if player ~= -1 and distance < 2.5 then
local SearchedPlayer = QBCore.Functions.GetPlayer(tonumber(player))
if not SearchedPlayer then return end
exports['qb-inventory']:OpenInventoryById(src, tonumber(player))
TriggerClientEvent('QBCore:Notify', src, Lang:t('info.cash_found', { cash = SearchedPlayer.PlayerData.money['cash'] }))
TriggerClientEvent('QBCore:Notify', player, Lang:t('info.being_searched'))
else
TriggerClientEvent('QBCore:Notify', src, Lang:t('error.none_nearby'), 'error')
end
local playerPed = GetPlayerPed(src)
local targetPed = GetPlayerPed(playerId)
local playerCoords = GetEntityCoords(playerPed)
local targetCoords = GetEntityCoords(targetPed)

local SearchedPlayer = QBCore.Functions.GetPlayer(playerId)
TriggerClientEvent('inventory:client:OpenInventory', playerId)
if not QBCore.Functions.GetPlayer(src) or not SearchedPlayer then return end

TriggerClientEvent('QBCore:Notify', src, Lang:t("info.cash_found", {cash = SearchedPlayer.PlayerData.money["cash"]}))
TriggerClientEvent('QBCore:Notify', SearchedPlayer.PlayerData.source, Lang:t("info.being_searched"))
end)

RegisterNetEvent('police:server:policeAlert', function(text)
Expand Down
Loading