2025-02-21 13:54:49 +00:00
Core.Commands . Add ( " cashgive " ,
Loc [ Config.Lan ] . command [ " pay_user " ] , { } , false , function ( source ) TriggerClientEvent ( getScript ( ) .. " :client:ATM:give " , source ) end )
registerCommand ( " polcharge " , {
Loc [ Config.Lan ] . command [ " pay_user " ] , { } , false ,
function ( source )
TriggerClientEvent ( getScript ( ) .. " :client:ATM:give " , source )
end
} )
RegisterServerEvent ( getScript ( ) .. " :server:ATM:use " , function ( amount , billtype , baccount , account , society , gsociety )
2022-08-22 21:32:15 +01:00
local src = source
2025-02-21 13:54:49 +00:00
local Player = getPlayer ( src )
2022-08-22 21:32:15 +01:00
local amount = tonumber ( amount )
2025-02-21 13:54:49 +00:00
local bankScript , newAmount = " " , 0
2022-08-22 21:32:15 +01:00
--Simple transfers from bank to wallet --
if account == " bank " or account == " atm " then
if billtype == " withdraw " then
2025-02-21 13:54:49 +00:00
if Player.bank < amount then
triggerNotify ( nil , Loc [ Config.Lan ] . error [ " bank_low " ] , " error " , src )
elseif Player.bank >= tonumber ( amount ) then
2022-09-02 20:04:22 +08:00
triggerNotify ( nil , Loc [ Config.Lan ] . success [ " draw " ] .. cv ( amount ) .. Loc [ Config.Lan ] . success [ " from_bank " ] , " success " ) -- Don't really need this as phone gets notified when money is withdrawn
2025-02-21 13:54:49 +00:00
chargePlayer ( amount , " bank " , src ) Wait ( 1500 )
fundPlayer ( amount , " cash " , src )
2022-08-22 21:32:15 +01:00
end
elseif billtype == " deposit " then
2025-02-21 13:54:49 +00:00
if Player.cash < amount then
triggerNotify ( nil , Loc [ Config.Lan ] . error [ " no_cash " ] , " error " , src )
elseif Player.cash >= amount then
chargePlayer ( amount , " cash " , src ) Wait ( 1500 )
fundPlayer ( amount , " bank " , src )
2022-09-02 20:04:22 +08:00
triggerNotify ( nil , Loc [ Config.Lan ] . success [ " deposited " ] .. cv ( amount ) .. Loc [ Config.Lan ] . success [ " into_bank " ] , " success " , src )
2022-08-22 21:32:15 +01:00
end
end
-- Transfers from bank to savings account --
elseif account == " savings " then
2025-02-21 13:54:49 +00:00
local getSavingsAccount = MySQL.Sync . fetchAll ( ' SELECT * FROM bank_accounts WHERE citizenid = ? AND account_name = ? ' , { Player.citizenId , ' Savings_ ' .. Player.citizenId , } )
2024-01-07 02:37:55 -05:00
if getSavingsAccount [ 1 ] ~= nil then savbal = tonumber ( getSavingsAccount [ 1 ] . account_balance ) aid = getSavingsAccount [ 1 ] . citizenid end
2022-08-22 21:32:15 +01:00
if billtype == " withdraw " then
if savbal >= amount then
2022-09-18 15:32:10 +01:00
savbal -= amount
2025-02-21 13:54:49 +00:00
fundPlayer ( amount , " cash " , src )
2022-09-02 20:04:22 +08:00
triggerNotify ( nil , " $ " .. cv ( amount ) .. Loc [ Config.Lan ] . success [ " draw_save " ] , " success " , src )
2025-02-21 13:54:49 +00:00
MySQL.Async . execute ( ' UPDATE bank_accounts SET account_balance = ? WHERE citizenid = ? ' , { savbal , Player.citizenId } , function ( success )
2022-08-22 21:32:15 +01:00
if success then return true else return false end
end )
elseif savbal < amount then
2022-09-02 20:04:22 +08:00
triggerNotify ( nil , Loc [ Config.Lan ] . error [ " saving_low " ] , " error " )
2022-08-22 21:32:15 +01:00
end
elseif billtype == " deposit " then
2025-02-21 13:54:49 +00:00
if amount < Player.bank then
2022-09-18 15:32:10 +01:00
savbal += amount
2025-02-21 13:54:49 +00:00
chargePlayer ( amount , " bank " , src )
2022-09-02 20:04:22 +08:00
triggerNotify ( nil , " $ " .. cv ( amount ) .. Loc [ Config.Lan ] . success [ " depos_save " ] , " success " , src )
2025-02-21 13:54:49 +00:00
MySQL.Async . execute ( ' UPDATE bank_accounts SET account_balance = ? WHERE citizenid = ? ' , { savbal , Player.citizenId } , function ( success )
2022-08-22 21:32:15 +01:00
if success then return true else return false end
end )
2022-09-02 20:04:22 +08:00
else triggerNotify ( nil , Loc [ Config.Lan ] . error [ " bank_low " ] , " error " , src )
2022-08-22 21:32:15 +01:00
end
end
--Simple transfers from society account to bank --
elseif account == " society " then
if billtype == " withdraw " then
2025-02-21 13:54:49 +00:00
if tonumber ( society ) < amount then
triggerNotify ( nil , Loc [ Config.Lan ] . error [ " soc_low " ] , " error " , src )
2022-08-22 21:32:15 +01:00
elseif tonumber ( society ) >= amount then
2025-02-21 13:54:49 +00:00
if isStarted ( " Renewed-Banking " ) then
bankScript = " Renewed-Banking "
exports [ ' Renewed-Banking ' ] : removeAccountMoney ( Player.job , amount )
newAmount = exports [ " Renewed-Banking " ] : getAccountMoney ( Player.job )
elseif isStarted ( " qb-banking " ) then
bankScript = " qb-banking "
exports [ " qb-banking " ] : RemoveMoney ( Player.job , amount )
newAmount = exports [ " qb-banking " ] : GetAccountBalance ( Player.job )
elseif isStarted ( " fd_banking " ) then
bankScript = " fd_banking "
exports [ " fd_banking " ] : RemoveMoney ( Player.job , amount )
newAmount = exports [ " fd_banking " ] : GetAccount ( Player.job )
elseif isStarted ( " okokBanking " ) then
bankScript = " okokBanking "
exports [ ' okokBanking ' ] : RemoveMoney ( Player.job , amount )
newAmount = exports [ ' okokBanking ' ] : GetAccount ( Player.job )
end
fundPlayer ( amount , " bank " , src )
debugPrint ( " ^5Debug^7: ^3 " .. bankScript .. " ^7(^3Job^7): ^2Removing ^7$ " .. amount .. " ^2from account ^7'^6 " .. Player.job .. " ^7' ($ " .. newAmount .. " ) " )
triggerNotify ( nil , Loc [ Config.Lan ] . success [ " draw " ] .. cv ( amount ) .. Loc [ Config.Lan ] . success [ " fromthe " ] .. Jobs [ Player.job ] . label .. Loc [ Config.Lan ] . success [ " account " ] , " success " , src )
2022-08-22 21:32:15 +01:00
end
elseif billtype == " deposit " then
2025-02-21 13:54:49 +00:00
if Player.bank < amount then triggerNotify ( nil , Loc [ Config.Lan ] . error [ " nomoney_bank " ] , " error " , src )
elseif Player.bank >= amount then
if isStarted ( " Renewed-Banking " ) then
bankScript = " Renewed-Banking "
exports [ ' Renewed-Banking ' ] : addAccountMoney ( Player.job , amount )
newAmount = exports [ " Renewed-Banking " ] : getAccountMoney ( Player.job )
elseif isStarted ( " qb-banking " ) then
bankScript = " qb-banking "
exports [ " qb-banking " ] : AddMoney ( Player.job , amount )
newAmount = exports [ " qb-banking " ] : GetAccountBalance ( Player.job )
elseif isStarted ( " fd_banking " ) then
bankScript = " fd_banking "
exports.fd_banking : AddMoney ( Player.job , amount )
newAmount = exports [ " fd_banking " ] : GetAccount ( Player.job )
elseif isStarted ( " okokBanking " ) then
bankScript = " okokBanking "
exports [ ' okokBanking ' ] : AddMoney ( Player.job , amount )
newAmount = exports [ ' okokBanking ' ] : GetAccount ( Player.job )
end
chargePlayer ( amount , " bank " , src ) Wait ( 1500 )
debugPrint ( " ^5Debug^7: ^3 " .. bankScript .. " ^7(^3Job^7): ^2Adding ^7$ " .. amount .. " ^2to account ^7'^6 " .. Player.job .. " ^7' ($ " .. newAmount .. " ) " )
triggerNotify ( nil , Loc [ Config.Lan ] . success [ " deposited " ] .. cv ( amount ) .. Loc [ Config.Lan ] . success [ " into " ] .. Jobs [ Player.job ] . label .. Loc [ Config.Lan ] . success [ " account " ] , " success " , src )
2022-08-22 21:32:15 +01:00
end
end
-- Transfer from boss account to players --
2025-02-21 13:54:49 +00:00
--[[ disabled until i work out a system for other frameworks
2022-08-22 21:32:15 +01:00
elseif account == " societytransfer " then
local bannedCharacters = { ' % ' , ' $ ' , ' ; ' }
local newAmount = tostring ( amount )
local newiban = tostring ( baccount )
for _ , v in pairs ( bannedCharacters ) do
newAmount = string.gsub ( newAmount , ' % ' .. v , ' ' )
newiban = string.gsub ( newiban , ' % ' .. v , ' ' )
end
baccount = newiban
amount = tonumber ( newAmount )
2024-01-27 21:57:05 +00:00
local Player = Core.Functions . GetPlayer ( src )
2022-08-22 21:32:15 +01:00
if ( society - amount ) >= 0 then
local query = ' %"account":" ' .. baccount .. ' "% '
local result = MySQL.Sync . fetchAll ( ' SELECT * FROM players WHERE charinfo LIKE ? ' , { query } )
if result [ 1 ] then
2024-01-27 21:57:05 +00:00
local Reciever = Core.Functions . GetPlayerByCitizenId ( result [ 1 ] . citizenid )
2025-02-21 13:54:49 +00:00
if Config.Banking == " renewed " then
exports [ ' Renewed-Banking ' ] : removeAccountMoney ( tostring ( Player.PlayerData . job.name ) , amount )
elseif Config.Banking == " qb-management " then
exports [ " qb-management " ] : RemoveMoney ( tostring ( Player.PlayerData . job.name ) , amount )
elseif Config.Banking == " qb-banking " then
exports [ " qb-banking " ] : RemoveMoney ( tostring ( Player.PlayerData . job.name ) , amount )
elseif Config.Banking == " fd " then
exports.fd_banking : RemoveMoney ( tostring ( Player.PlayerData . job.name ) , amount )
end
2022-08-22 21:32:15 +01:00
if Reciever then
Reciever.Functions . AddMoney ( ' bank ' , amount )
2022-09-02 20:04:22 +08:00
triggerNotify ( nil , Loc [ Config.Lan ] . success [ " sent " ] .. amount .. Loc [ Config.Lan ] . success [ " to " ] .. Reciever.PlayerData . charinfo.firstname .. " " .. Reciever.PlayerData . charinfo.lastname , " success " , src )
triggerNotify ( nil , Loc [ Config.Lan ] . success [ " recieved " ] .. cv ( amount ) .. Loc [ Config.Lan ] . success [ " from " ] .. tostring ( Player.PlayerData . job.label ) .. Loc [ Config.Lan ] . success [ " account " ] , " success " , Reciever.PlayerData . source )
2022-08-22 21:32:15 +01:00
else
local RecieverMoney = json.decode ( result [ 1 ] . money )
2022-09-18 15:32:10 +01:00
RecieverMoney.bank += amount
2022-08-22 21:32:15 +01:00
MySQL.Async . execute ( ' UPDATE players SET money = ? WHERE citizenid = ? ' , { json.encode ( RecieverMoney ) , result [ 1 ] . citizenid } )
end
2022-09-02 20:04:22 +08:00
elseif not result [ 1 ] then triggerNotify ( nil , Loc [ Config.Lan ] . error [ " error_start " ] .. baccount .. Loc [ Config.Lan ] . error [ " error_end " ] , " error " , src )
2022-08-22 21:32:15 +01:00
end
2025-02-21 13:54:49 +00:00
end ] ]
2022-08-22 21:32:15 +01:00
--Simple transfers from gang society account to bank --
elseif account == " gang " then
if billtype == " withdraw " then
2025-02-21 13:54:49 +00:00
if tonumber ( gsociety ) < amount then
triggerNotify ( nil , Loc [ Config.Lan ] . error [ " soc_low " ] , " error " , src )
2022-08-22 21:32:15 +01:00
elseif tonumber ( gsociety ) >= amount then
2025-02-21 13:54:49 +00:00
if isStarted ( " Renewed-Banking " ) then
exports [ ' Renewed-Banking ' ] : removeAccountMoney ( Player.gang , amount )
elseif isStarted ( " qb-banking " ) then
exports [ " qb-banking " ] : RemoveMoney ( Player.gang , amount )
elseif isStarted ( " fd_banking " ) then
exports [ " fd_banking " ] : RemoveGangMoney ( Player.gang , amount )
elseif isStarted ( " okokBanking " ) then
exports [ " okokBanking " ] : RemoveMoney ( Player.gang , amount )
end
2022-08-22 21:32:15 +01:00
end
2025-02-21 13:54:49 +00:00
fundPlayer ( amount , " bank " , src )
triggerNotify ( nil , Loc [ Config.Lan ] . success [ " draw " ] .. cv ( amount ) .. Loc [ Config.Lan ] . success [ " fromthe " ] .. Gangs [ Player.gang ] . label .. Loc [ Config.Lan ] . success [ " account " ] , " success " , src )
2022-08-22 21:32:15 +01:00
elseif billtype == " deposit " then
2025-02-21 13:54:49 +00:00
if Player.bank < amount then
triggerNotify ( nil , Loc [ Config.Lan ] . error [ " nomoney_bank " ] , " error " , src )
elseif Player.bank >= amount then
if isStarted ( " Renewed-Banking " ) then
exports [ ' Renewed-Banking ' ] : addAccountMoney ( Player.gang , amount )
elseif isStarted ( " qb-banking " ) then
exports [ " qb-banking " ] : AddGangMoney ( Player.gang , amount )
elseif isStarted ( " fd_banking " ) then
exports [ " fd_banking " ] : AddGangMoney ( Player.gang , amount )
elseif isStarted ( " okokBanking " ) then
exports [ " okokBanking " ] : AddMoney ( Player.gang , amount )
end
2022-08-22 21:32:15 +01:00
Player.Functions . RemoveMoney ( ' bank ' , amount ) Wait ( 1500 )
2025-02-21 13:54:49 +00:00
triggerNotify ( nil , Loc [ Config.Lan ] . success [ " deposited " ] .. cv ( amount ) .. Loc [ Config.Lan ] . success [ " into " ] .. Gangs [ Player.gang ] . label .. Loc [ Config.Lan ] . success [ " account " ] , " success " , src )
2022-08-22 21:32:15 +01:00
end
end
-- Transfer from gang account to players --
elseif account == " gangtransfer " then
local bannedCharacters = { ' % ' , ' $ ' , ' ; ' }
local newAmount = tostring ( amount )
local newiban = tostring ( baccount )
for _ , v in pairs ( bannedCharacters ) do
newAmount = string.gsub ( newAmount , ' % ' .. v , ' ' )
newiban = string.gsub ( newiban , ' % ' .. v , ' ' )
end
baccount = newiban
amount = tonumber ( newAmount )
2024-01-27 21:57:05 +00:00
local Player = Core.Functions . GetPlayer ( src )
2022-08-22 21:32:15 +01:00
if ( gsociety - amount ) >= 0 then
local query = ' %"account":" ' .. baccount .. ' "% '
local result = MySQL.Sync . fetchAll ( ' SELECT * FROM players WHERE charinfo LIKE ? ' , { query } )
if result [ 1 ] then
2024-01-27 21:57:05 +00:00
local Reciever = Core.Functions . GetPlayerByCitizenId ( result [ 1 ] . citizenid )
2023-12-20 00:45:28 +00:00
if Config.Banking == " renewed " then exports [ ' Renewed-Banking ' ] : removeAccountMoney ( tostring ( Player.PlayerData . gang.name ) , amount )
elseif Config.Banking == " qb-management " then exports [ " qb-management " ] : RemoveGangMoney ( tostring ( Player.PlayerData . gang.name ) , amount )
elseif Config.Banking == " qb-banking " then exports [ " qb-banking " ] : RemoveGangMoney ( tostring ( Player.PlayerData . gang.name ) , amount )
elseif Config.Banking == " fd " then exports.fd_banking : RemoveGangMoney ( tostring ( Player.PlayerData . gang.name ) , amount ) end
2022-08-22 21:32:15 +01:00
if not Reciever then
Reciever.Functions . AddMoney ( ' bank ' , amount )
2022-09-02 20:04:22 +08:00
triggerNotify ( nil , Loc [ Config.Lan ] . success [ " sent " ] .. amount .. Loc [ Config.Lan ] . success [ " to " ] .. Reciever.PlayerData . charinfo.firstname .. " " .. Reciever.PlayerData . charinfo.lastname , " success " , src )
triggerNotify ( nil , Reciever.PlayerData . source , Loc [ Config.Lan ] . success [ " recieved " ] .. cv ( amount ) .. Loc [ Config.Lan ] . success [ " from " ] .. tostring ( Player.PlayerData . gang.label ) .. Loc [ Config.Lan ] . success [ " account " ] , " success " , Reciever.PlayerData . source )
2022-08-22 21:32:15 +01:00
else
local RecieverMoney = json.decode ( result [ 1 ] . money )
2022-09-18 15:32:10 +01:00
RecieverMoney.bank += amount
2022-08-22 21:32:15 +01:00
MySQL.Async . execute ( ' UPDATE players SET money = ? WHERE citizenid = ? ' , { json.encode ( RecieverMoney ) , result [ 1 ] . citizenid } )
end
2022-09-02 20:04:22 +08:00
elseif not result [ 1 ] then triggerNotify ( nil , Loc [ Config.Lan ] . error [ " error_start " ] .. baccount .. Loc [ Config.Lan ] . error [ " error_end " ] , " error " , src )
2022-08-22 21:32:15 +01:00
end
end
elseif account == " transfer " then
local bannedCharacters = { ' % ' , ' $ ' , ' ; ' }
local newAmount = tostring ( amount )
local newiban = tostring ( baccount )
for _ , v in pairs ( bannedCharacters ) do
newAmount = string.gsub ( newAmount , ' % ' .. v , ' ' )
newiban = string.gsub ( newiban , ' % ' .. v , ' ' )
end
baccount = newiban
amount = tonumber ( newAmount )
2024-01-27 21:57:05 +00:00
local Player = Core.Functions . GetPlayer ( src )
2022-08-22 21:32:15 +01:00
if ( Player.PlayerData . money.bank - amount ) >= 0 then
local query = ' %"account":" ' .. baccount .. ' "% '
local result = MySQL.Sync . fetchAll ( ' SELECT * FROM players WHERE charinfo LIKE ? ' , { query } )
if result [ 1 ] then
2024-01-27 21:57:05 +00:00
local Reciever = Core.Functions . GetPlayerByCitizenId ( result [ 1 ] . citizenid )
2022-08-22 21:32:15 +01:00
Player.Functions . RemoveMoney ( ' bank ' , amount )
if Reciever then
Reciever.Functions . AddMoney ( ' bank ' , amount )
2022-09-02 20:04:22 +08:00
triggerNotify ( nil , Loc [ Config.Lan ] . success [ " sent " ] .. cv ( amount ) .. Loc [ Config.Lan ] . success [ " to " ] .. Reciever.PlayerData . charinfo.firstname .. " " .. Reciever.PlayerData . charinfo.lastname , " success " , src )
triggerNotify ( nil , Loc [ Config.Lan ] . success [ " recieved " ] .. cv ( amount ) .. Loc [ Config.Lan ] . success [ " from " ] .. Player.PlayerData . charinfo.firstname .. " " .. Player.PlayerData . charinfo.lastname , " success " , Reciever.PlayerData . source )
2022-08-22 21:32:15 +01:00
else
local RecieverMoney = json.decode ( result [ 1 ] . money )
2022-09-18 15:32:10 +01:00
RecieverMoney.bank += amount
2022-08-22 21:32:15 +01:00
MySQL.Async . execute ( ' UPDATE players SET money = ? WHERE citizenid = ? ' , { json.encode ( RecieverMoney ) , result [ 1 ] . citizenid } )
end
2024-01-07 02:37:55 -05:00
elseif not result [ 1 ] then
2023-12-20 00:45:28 +00:00
triggerNotify ( nil , Loc [ Config.Lan ] . error [ " error_start " ] .. baccount .. Loc [ Config.Lan ] . error [ " error_end " ] , " error " , src )
2022-08-22 21:32:15 +01:00
end
end
end
end )
2025-02-21 13:54:49 +00:00
createCallback ( getScript ( ) .. " :GetInfo " , function ( source )
local Player = getPlayer ( source )
local society , gsociety = 0 , 0
2022-08-22 21:32:15 +01:00
2025-02-21 13:54:49 +00:00
if isStarted ( " Renewed-Banking " ) then
society = exports [ " Renewed-Banking " ] : getAccountMoney ( Player.job )
if Player.gang ~= " none " then
gsociety = exports [ " Renewed-Banking " ] : getAccountMoney ( Player.gang )
2023-12-20 00:45:28 +00:00
end
2025-02-21 13:54:49 +00:00
elseif isStarted ( " qb-banking " ) then
if not exports [ " qb-banking " ] : GetAccount ( Player.job ) then
print ( " Making new bank account in qb-banking for " .. Player.job )
exports [ " qb-banking " ] : CreateJobAccount ( Player.job , 0 ) Wait ( 150 ) -- make new account if return "null"
2022-08-22 21:32:15 +01:00
end
2025-02-21 13:54:49 +00:00
society = exports [ " qb-banking " ] : GetAccountBalance ( Player.job )
if Player.gang ~= " none " then
if not exports [ " qb-banking " ] : GetAccount ( Player.gang ) then
print ( " Making new bank account in qb-banking for " .. Player.gang )
exports [ " qb-banking " ] : CreateGangAccount ( Player.gang , 0 ) Wait ( 150 ) -- make new account if return "null"
society = exports [ " qb-banking " ] : GetAccountBalance ( Player.gang )
2022-08-22 21:32:15 +01:00
end
2025-02-21 13:54:49 +00:00
society = exports [ " qb-banking " ] : GetAccountBalance ( Player.gang )
end
elseif isStarted ( " fd_banking " ) then
society = exports [ " fd_banking " ] : GetAccount ( Player.job )
if Player.gang ~= " none " then
gsociety = exports [ " fd_banking " ] : GetGangAccount ( Player.gang )
end
elseif isStarted ( " okokBanking " ) then
society = exports [ " okokBanking " ] : GetAccount ( Player.job )
if Player.gang ~= " none " then
gsociety = exports [ " okokBanking " ] : GetAccount ( Player.gang )
2022-08-22 21:32:15 +01:00
end
end
2025-02-21 13:54:49 +00:00
2022-08-22 21:32:15 +01:00
-- Grab Savings account info
2025-02-21 13:54:49 +00:00
local result = MySQL.Sync . fetchAll ( ' SELECT * FROM bank_accounts WHERE citizenid = ? AND account_name = ? ' , { Player.citizenId , ' Savings_ ' .. Player.citizenId , } )
2022-08-22 21:32:15 +01:00
if result [ 1 ] then
2024-01-07 02:37:55 -05:00
accountID = result [ 1 ] . citizenid
savingBalance = result [ 1 ] . account_balance
2022-08-22 21:32:15 +01:00
else
2025-02-21 13:54:49 +00:00
MySQL.Async . insert ( ' INSERT INTO bank_accounts (citizenid, account_name, account_balance) VALUES (?, ?, ?) ' , { Player.citizenId , ' Savings_ ' .. Player.citizenId , 0 } , function ( ) completed = true end ) repeat Wait ( 0 ) until completed == true
local result = MySQL.Sync . fetchAll ( ' SELECT * FROM bank_accounts WHERE citizenid = ? AND account_name = ? ' , { Player.citizenId , ' Savings_ ' .. Player.citizenId , } )
2024-01-07 02:37:55 -05:00
accountID = result [ 1 ] . citizenid
savingBalance = result [ 1 ] . account_balance
2022-08-22 21:32:15 +01:00
end
2025-02-21 13:54:49 +00:00
local retTable = {
name = Player.firstname .. ' ' .. Player.lastname ,
cash = Player.cash ,
bank = Player.bank ,
account = Player.account ,
cid = Player.citizenId .. " [ " .. source .. " ] " ,
savbal = savingBalance ,
aid = accountID ,
society = society ,
gsociety = gsociety
}
2022-08-22 21:32:15 +01:00
2025-02-21 13:54:49 +00:00
return retTable
end )
2022-08-22 21:32:15 +01:00
2025-02-21 13:54:49 +00:00
RegisterServerEvent ( getScript ( ) .. " :server:ATM:give " , function ( citizen , price )
2024-01-27 21:57:05 +00:00
local Player = Core.Functions . GetPlayer ( source )
local Reciever = Core.Functions . GetPlayer ( tonumber ( citizen ) )
2022-08-22 21:32:15 +01:00
local amount = tonumber ( price )
local balance = Player.Functions . GetMoney ( " cash " )
if amount and amount > 0 then
if balance >= amount then
Player.Functions . RemoveMoney ( ' cash ' , amount )
2022-09-02 20:04:22 +08:00
triggerNotify ( nil , Loc [ Config.Lan ] . success [ " you_gave " ] .. Reciever.PlayerData . charinfo.firstname .. " $ " .. cv ( amount ) , " success " , source )
2022-08-22 21:32:15 +01:00
Reciever.Functions . AddMoney ( ' cash ' , amount )
2022-09-02 20:04:22 +08:00
triggerNotify ( nil , Loc [ Config.Lan ] . success [ " you_got " ] .. cv ( amount ) .. Loc [ Config.Lan ] . success [ " from " ] .. Player.PlayerData . charinfo.firstname , " success " , tonumber ( citizen ) )
2022-08-22 21:32:15 +01:00
elseif balance < amount then
2022-09-02 20:04:22 +08:00
triggerNotify ( nil , Loc [ Config.Lan ] . error [ " not_enough " ] , " error " , source )
2022-08-22 21:32:15 +01:00
end
2022-09-02 20:04:22 +08:00
else triggerNotify ( nil , Loc [ Config.Lan ] . error [ " zero " ] , ' error ' , source ) end
end )
2023-01-28 14:05:58 +00:00