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

Fixed PlayerStatus for the statuses to come back & fixes Search Player while taking money if > 0 #510

Closed
wants to merge 3 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
10 changes: 0 additions & 10 deletions client/interactions.lua
Original file line number Diff line number Diff line change
Expand Up @@ -86,16 +86,6 @@ RegisterNetEvent('police:client:PutInVehicle', function()
end
end)

RegisterNetEvent('police:client:SeizeCash', function()
local player, distance = QBCore.Functions.GetClosestPlayer()
if player ~= -1 and distance < 2.5 then
local playerId = GetPlayerServerId(player)
TriggerServerEvent('police:server:SeizeCash', playerId)
else
QBCore.Functions.Notify(Lang:t('error.none_nearby'), 'error')
end
end)

RegisterNetEvent('police:client:SeizeDriverLicense', function()
local player, distance = QBCore.Functions.GetClosestPlayer()
if player ~= -1 and distance < 2.5 then
Expand Down
2 changes: 1 addition & 1 deletion client/job.lua
Original file line number Diff line number Diff line change
Expand Up @@ -354,7 +354,7 @@ RegisterNetEvent('police:client:CheckStatus', function()
QBCore.Functions.TriggerCallback('police:GetPlayerStatus', function(result)
if result then
for _, v in pairs(result) do
QBCore.Functions.Notify('' .. v .. '')
QBCore.Functions.Notify('Player comes back with ' .. v)
end
end
end, playerId)
Expand Down
5 changes: 3 additions & 2 deletions locales/en.lua
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,8 @@ local Translations = {
no_driver_license = 'No drivers license',
not_cuffed_dead = 'Civilian isn\'t cuffed or dead',
fine_yourself = 'You Cannot Fine Yourself',
not_online = 'This person is not online'
not_online = 'This person is not online',
no_status = 'No status found for the person',
},
success = {
uncuffed = 'You have been uncuffed',
Expand Down Expand Up @@ -117,7 +118,7 @@ local Translations = {
officer_down = 'Officer %{lastname} | %{callsign} Down',
fine_issued = 'Fine has been issued to offender succesfully',
received_fine = 'State Debt Recovery has automatically recovered the fines owed...',
camera_speed= 'Speed camera #%{radarid} - Marked vehicle'
camera_speed = 'Speed camera #%{radarid} - Marked vehicle'

},
evidence = {
Expand Down
45 changes: 13 additions & 32 deletions server/main.lua
Original file line number Diff line number Diff line change
Expand Up @@ -249,16 +249,6 @@ QBCore.Commands.Add('clearblood', Lang:t('commands.clearblood'), {}, false, func
end
end)

QBCore.Commands.Add('seizecash', Lang:t('commands.seizecash'), {}, false, function(source)
local src = source
local Player = QBCore.Functions.GetPlayer(src)
if Player.PlayerData.job.type == 'leo' and Player.PlayerData.job.onduty then
TriggerClientEvent('police:client:SeizeCash', src)
else
TriggerClientEvent('QBCore:Notify', src, Lang:t('error.on_duty_police_only'), 'error')
end
end)

QBCore.Commands.Add('sc', Lang:t('commands.softcuff'), {}, false, function(source)
local src = source
local Player = QBCore.Functions.GetPlayer(src)
Expand Down Expand Up @@ -542,14 +532,16 @@ QBCore.Functions.CreateCallback('police:server:isPlayerDead', function(_, cb, pl
cb(Player.PlayerData.metadata['isdead'])
end)

QBCore.Functions.CreateCallback('police:GetPlayerStatus', function(_, cb, playerId)
QBCore.Functions.CreateCallback('police:GetPlayerStatus', function(source, cb, playerId)
local Player = QBCore.Functions.GetPlayer(playerId)
local statList = {}
if Player then
if PlayerStatus[Player.PlayerData.source] and next(PlayerStatus[Player.PlayerData.source]) then
for k in pairs(PlayerStatus[Player.PlayerData.source]) do
statList[#statList + 1] = PlayerStatus[Player.PlayerData.source][k].text
end
else
TriggerClientEvent('QBCore:Notify', source, Lang:t('error.no_status'), 'error')
end
end
cb(statList)
Expand Down Expand Up @@ -681,11 +673,19 @@ RegisterNetEvent('police:server:SearchPlayer', function()
local PlayerData = Player.PlayerData
if PlayerData.job.type ~= 'leo' then return end
local player, distance = QBCore.Functions.GetClosestPlayer(src)
player = tonumber(player)
if player ~= -1 and distance < 2.5 then
local SearchedPlayer = QBCore.Functions.GetPlayer(tonumber(player))
local SearchedPlayer = QBCore.Functions.GetPlayer(player)
if not SearchedPlayer then return end
exports['qb-inventory']:OpenInventoryById(src, tonumber(player))
local moneyAmount = SearchedPlayer.PlayerData.money['cash']
TriggerClientEvent('QBCore:Notify', src, Lang:t('info.cash_found', { cash = SearchedPlayer.PlayerData.money['cash'] }))
if moneyAmount > 0 then
local info = { cash = moneyAmount }
SearchedPlayer.Functions.RemoveMoney('cash', moneyAmount, 'police-cash-seized')
exports['qb-inventory']:AddItem(src, 'moneybag', 1, false, info, 'police-cash-seized')
TriggerClientEvent('QBCore:Notify', SearchedPlayer.PlayerData.source, Lang:t('info.cash_confiscated'))
end
exports['qb-inventory']:OpenInventoryById(src, player)
TriggerClientEvent('QBCore:Notify', player, Lang:t('info.being_searched'))
else
TriggerClientEvent('QBCore:Notify', src, Lang:t('error.none_nearby'), 'error')
Expand Down Expand Up @@ -886,25 +886,6 @@ end)
-- end
-- end)

RegisterNetEvent('police:server:SeizeCash', function(playerId)
local src = source
local playerPed = GetPlayerPed(src)
local targetPed = GetPlayerPed(playerId)
local playerCoords = GetEntityCoords(playerPed)
local targetCoords = GetEntityCoords(targetPed)
if #(playerCoords - targetCoords) > 2.5 then return DropPlayer(src, 'Attempted exploit abuse') end
local Player = QBCore.Functions.GetPlayer(src)
local SearchedPlayer = QBCore.Functions.GetPlayer(playerId)
if not Player or not SearchedPlayer then return end
if Player.PlayerData.job.type ~= 'leo' then return end
local moneyAmount = SearchedPlayer.PlayerData.money['cash']
local info = { cash = moneyAmount }
SearchedPlayer.Functions.RemoveMoney('cash', moneyAmount, 'police-cash-seized')
exports['qb-inventory']:AddItem(src, 'moneybag', 1, false, info, 'police:server:SeizeCash')
TriggerClientEvent('qb-inventory:client:ItemBox', src, QBCore.Shared.Items['moneybag'], 'add')
TriggerClientEvent('QBCore:Notify', SearchedPlayer.PlayerData.source, Lang:t('info.cash_confiscated'))
end)

RegisterNetEvent('police:server:SeizeDriverLicense', function(playerId)
local src = source
local playerPed = GetPlayerPed(src)
Expand Down
Loading