Nice vulnerability in server side
RegisterNetEvent('gramour_atmrobbery:giveMoney')
AddEventHandler('gramour_atmrobbery:giveMoney', function(amount)
local src = source
local xPlayer = ESX.GetPlayerFromId(src)
if xPlayer then
xPlayer.addAccountMoney(Config.Money, amount)
end
end)
Hello,
I am not a lua expert but wouldn’t it make more sense if this code on the server side
starting from server.lua 60
RegisterNetEvent('gramour_atmrobbery:giveMoney')
AddEventHandler('gramour_atmrobbery:giveMoney', function(amount)
local src = source
local xPlayer = ESX.GetPlayerFromId(src)
if xPlayer then
xPlayer.addAccountMoney(Config.Money, amount)
end
end)
was arranged like this?
RegisterNetEvent('gramour_atmrobbery:giveMoney')
AddEventHandler('gramour_atmrobbery:giveMoney', function(amount, atmCoords)
local src = source
local xPlayer = ESX.GetPlayerFromId(src)
local playerCoords = GetEntityCoords(GetPlayerPed(src))
if not xPlayer or not amount then
print('[ATM Robbery] Incorrect data received')
return
end
if amount <= 0 then
print('[ATM Robbery]Invalid amount of money: ' .. amount)
return
end
local distanceThreshold = 3.0 -- Maximum distance of 3 meters from the ATM
-- ATM props
local atmProps = {
`prop_atm_01`,
`prop_atm_02`,
`prop_atm_03`,
`prop_fleeca_atm`
}
-- Check if you are close enough to the ATM
local isNearATM = false
for _, atmProp in pairs(atmProps) do
local closestATM = GetClosestObjectOfType(playerCoords, distanceThreshold, atmProp, false, false, false)
if closestATM ~= 0 then
isNearATM = true
break
end
end
if not isNearATM then
print('[ATM Robbery]The player is not near the ATM!')
return
end
-- All checks passed, money can be added
xPlayer.addAccountMoney(Config.Money, amount)
print('[ATM Robbery] ' .. amount .. ' amount of money was added to the player.')
end)
GetClosestObjectOfType is not a valid native of server side.