Skip to content

Commit

Permalink
Removed and added Seized cash in Searching
Browse files Browse the repository at this point in the history
When searching the player, it takes the money if greater than 0
  • Loading branch information
ChristianBDev committed May 24, 2024
1 parent cdb9ce0 commit d90dca1
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 41 deletions.
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
41 changes: 10 additions & 31 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 @@ -683,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 @@ -888,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

0 comments on commit d90dca1

Please sign in to comment.