Add files via upload

This commit is contained in:
Jim Shield
2025-02-22 13:23:43 +00:00
committed by GitHub
parent 2ebfeff554
commit ef6b664890
14 changed files with 1093 additions and 1020 deletions

View File

@@ -1,13 +1,11 @@
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,
registerCommand("cashgive", {
locale("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)
local src = source
local Player = getPlayer(src)
@@ -18,19 +16,19 @@ RegisterServerEvent(getScript()..":server:ATM:use", function(amount, billtype, b
if account == "bank" or account == "atm" then
if billtype == "withdraw" then
if Player.bank < amount then
triggerNotify(nil, Loc[Config.Lan].error["bank_low"], "error", src)
triggerNotify(nil, locale("error" ,"bank_low"), "error", src)
elseif Player.bank >= tonumber(amount) then
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
triggerNotify(nil, locale("success" ,"draw")..cv(amount)..locale("success" ,"from_bank"), "success") -- Don't really need this as phone gets notified when money is withdrawn
chargePlayer(amount, "bank", src) Wait(1500)
fundPlayer(amount, "cash", src)
end
elseif billtype == "deposit" then
if Player.cash < amount then
triggerNotify(nil, Loc[Config.Lan].error["no_cash"], "error", src)
triggerNotify(nil, locale("error" ,"no_cash"), "error", src)
elseif Player.cash >= amount then
chargePlayer(amount, "cash", src) Wait(1500)
fundPlayer(amount, "bank", src)
triggerNotify(nil, Loc[Config.Lan].success["deposited"]..cv(amount)..Loc[Config.Lan].success["into_bank"], "success", src)
triggerNotify(nil, locale("success" ,"deposited")..cv(amount)..locale("success" ,"into_bank"), "success", src)
end
end
-- Transfers from bank to savings account --
@@ -42,29 +40,29 @@ RegisterServerEvent(getScript()..":server:ATM:use", function(amount, billtype, b
if savbal >= amount then
savbal -= amount
fundPlayer(amount, "cash", src)
triggerNotify(nil, "$"..cv(amount)..Loc[Config.Lan].success["draw_save"], "success", src)
MySQL.Async.execute('UPDATE bank_accounts SET account_balance = ? WHERE citizenid = ?', { savbal, Player.citizenId}, function(success)
triggerNotify(nil, "$"..cv(amount)..locale("success" ,"draw_save"), "success", src)
MySQL.Async.execute('UPDATE bank_accounts SET account_balance = ? WHERE citizenid = ?', { savbal, Player.citizenId }, function(success)
if success then return true else return false end
end)
elseif savbal < amount then
triggerNotify(nil, Loc[Config.Lan].error["saving_low"], "error")
triggerNotify(nil, locale("error" ,"saving_low"), "error")
end
elseif billtype == "deposit" then
if amount < Player.bank then
savbal += amount
chargePlayer(amount, "bank", src)
triggerNotify(nil, "$"..cv(amount)..Loc[Config.Lan].success["depos_save"], "success", src)
triggerNotify(nil, "$"..cv(amount)..locale("success", "depos_save"), "success", src)
MySQL.Async.execute('UPDATE bank_accounts SET account_balance = ? WHERE citizenid = ?', { savbal, Player.citizenId}, function(success)
if success then return true else return false end
end)
else triggerNotify(nil, Loc[Config.Lan].error["bank_low"], "error", src)
else triggerNotify(nil, locale("error" ,"bank_low"), "error", src)
end
end
--Simple transfers from society account to bank --
elseif account == "society" then
if billtype == "withdraw" then
if tonumber(society) < amount then
triggerNotify(nil, Loc[Config.Lan].error["soc_low"], "error", src)
triggerNotify(nil, locale("error" ,"soc_low"), "error", src)
elseif tonumber(society) >= amount then
if isStarted("Renewed-Banking") then
@@ -87,10 +85,10 @@ RegisterServerEvent(getScript()..":server:ATM:use", function(amount, billtype, b
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)
triggerNotify(nil, locale("success", "draw")..cv(amount)..locale("success", "fromthe")..Jobs[Player.job].label..locale("success" ,"account"), "success", src)
end
elseif billtype == "deposit" then
if Player.bank < amount then triggerNotify(nil, Loc[Config.Lan].error["nomoney_bank"], "error", src)
if Player.bank < amount then triggerNotify(nil, locale("error", "nomoney_bank"), "error", src)
elseif Player.bank >= amount then
if isStarted("Renewed-Banking") then
bankScript = "Renewed-Banking"
@@ -112,7 +110,7 @@ RegisterServerEvent(getScript()..":server:ATM:use", function(amount, billtype, b
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)
triggerNotify(nil, locale("success", "deposited")..cv(amount)..locale("success", "into")..Jobs[Player.job].label..locale("success", "account"), "success", src)
end
end
-- Transfer from boss account to players --
@@ -145,14 +143,14 @@ RegisterServerEvent(getScript()..":server:ATM:use", function(amount, billtype, b
end
if Reciever then
Reciever.Functions.AddMoney('bank', amount)
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)
triggerNotify(nil, locale("success" ,"sent"]..amount..locale("success" ,"to"]..Reciever.PlayerData.charinfo.firstname.." "..Reciever.PlayerData.charinfo.lastname, "success", src)
triggerNotify(nil, locale("success" ,"recieved"]..cv(amount)..locale("success" ,"from"]..tostring(Player.PlayerData.job.label)..locale("success" ,"account"], "success", Reciever.PlayerData.source)
else
local RecieverMoney = json.decode(result[1].money)
RecieverMoney.bank += amount
MySQL.Async.execute('UPDATE players SET money = ? WHERE citizenid = ?', {json.encode(RecieverMoney), result[1].citizenid})
end
elseif not result[1] then triggerNotify(nil, Loc[Config.Lan].error["error_start"]..baccount..Loc[Config.Lan].error["error_end"], "error", src)
elseif not result[1] then triggerNotify(nil, locale("error" ,"error_start"]..baccount..locale("error" ,"error_end"], "error", src)
end
end]]
@@ -160,7 +158,7 @@ RegisterServerEvent(getScript()..":server:ATM:use", function(amount, billtype, b
elseif account == "gang" then
if billtype == "withdraw" then
if tonumber(gsociety) < amount then
triggerNotify(nil, Loc[Config.Lan].error["soc_low"], "error", src)
triggerNotify(nil, locale("error" ,"soc_low"), "error", src)
elseif tonumber(gsociety) >= amount then
if isStarted("Renewed-Banking") then
exports['Renewed-Banking']:removeAccountMoney(Player.gang, amount)
@@ -174,11 +172,11 @@ RegisterServerEvent(getScript()..":server:ATM:use", function(amount, billtype, b
end
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)
triggerNotify(nil, locale("success" ,"draw")..cv(amount)..locale("success" ,"fromthe")..Gangs[Player.gang].label..locale("success" ,"account"), "success", src)
elseif billtype == "deposit" then
if Player.bank < amount then
triggerNotify(nil, Loc[Config.Lan].error["nomoney_bank"], "error", src)
triggerNotify(nil, locale("error" ,"nomoney_bank"), "error", src)
elseif Player.bank >= amount then
if isStarted("Renewed-Banking") then
exports['Renewed-Banking']:addAccountMoney(Player.gang, amount)
@@ -190,7 +188,7 @@ RegisterServerEvent(getScript()..":server:ATM:use", function(amount, billtype, b
exports["okokBanking"]:AddMoney(Player.gang, amount)
end
Player.Functions.RemoveMoney('bank', amount) Wait(1500)
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)
triggerNotify(nil, locale("success" ,"deposited")..cv(amount)..locale("success" ,"into")..Gangs[Player.gang].label..locale("success" ,"account"), "success", src)
end
end
-- Transfer from gang account to players --
@@ -217,14 +215,14 @@ RegisterServerEvent(getScript()..":server:ATM:use", function(amount, billtype, b
elseif Config.Banking == "fd" then exports.fd_banking:RemoveGangMoney(tostring(Player.PlayerData.gang.name), amount) end
if not Reciever then
Reciever.Functions.AddMoney('bank', amount)
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)
triggerNotify(nil, locale("success" ,"sent")..amount..locale("success" ,"to")..Reciever.PlayerData.charinfo.firstname.." "..Reciever.PlayerData.charinfo.lastname, "success", src)
triggerNotify(nil, Reciever.PlayerData.source, locale("success" ,"recieved")..cv(amount)..locale("success" ,"from")..tostring(Player.PlayerData.gang.label)..locale("success" ,"account"), "success", Reciever.PlayerData.source)
else
local RecieverMoney = json.decode(result[1].money)
RecieverMoney.bank += amount
MySQL.Async.execute('UPDATE players SET money = ? WHERE citizenid = ?', {json.encode(RecieverMoney), result[1].citizenid})
end
elseif not result[1] then triggerNotify(nil, Loc[Config.Lan].error["error_start"]..baccount..Loc[Config.Lan].error["error_end"], "error", src)
elseif not result[1] then triggerNotify(nil, locale("error" ,"error_start")..baccount..locale("error" ,"error_end"), "error", src)
end
end
@@ -249,15 +247,15 @@ RegisterServerEvent(getScript()..":server:ATM:use", function(amount, billtype, b
Player.Functions.RemoveMoney('bank', amount)
if Reciever then
Reciever.Functions.AddMoney('bank', amount)
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)
triggerNotify(nil, locale("success" ,"sent")..cv(amount)..locale("success" ,"to")..Reciever.PlayerData.charinfo.firstname.." "..Reciever.PlayerData.charinfo.lastname, "success", src)
triggerNotify(nil, locale("success" ,"recieved")..cv(amount)..locale("success" ,"from")..Player.PlayerData.charinfo.firstname.." "..Player.PlayerData.charinfo.lastname, "success", Reciever.PlayerData.source)
else
local RecieverMoney = json.decode(result[1].money)
RecieverMoney.bank += amount
MySQL.Async.execute('UPDATE players SET money = ? WHERE citizenid = ?', {json.encode(RecieverMoney), result[1].citizenid})
end
elseif not result[1] then
triggerNotify(nil, Loc[Config.Lan].error["error_start"]..baccount..Loc[Config.Lan].error["error_end"], "error", src)
triggerNotify(nil, locale("error" ,"error_start")..baccount..locale("error" ,"error_end"), "error", src)
end
end
end
@@ -299,17 +297,20 @@ createCallback(getScript()..":GetInfo", function(source)
end
end
-- Savings account is only QBCore for now
if isStarted(QBExport) then
-- Grab Savings account info
local result = MySQL.Sync.fetchAll('SELECT * FROM bank_accounts WHERE citizenid = ? AND account_name = ?', { Player.citizenId, 'Savings_'..Player.citizenId, })
if result[1] then
accountID = result[1].citizenid
savingBalance = result[1].account_balance
else
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, })
accountID = result[1].citizenid
savingBalance = result[1].account_balance
end
if result[1] then
accountID = result[1].citizenid
savingBalance = result[1].account_balance
else
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, })
accountID = result[1].citizenid
savingBalance = result[1].account_balance
end
end
local retTable = {
name = Player.firstname..' '..Player.lastname,
cash = Player.cash,
@@ -326,20 +327,20 @@ createCallback(getScript()..":GetInfo", function(source)
end)
RegisterServerEvent(getScript()..":server:ATM:give", function(citizen, price)
local Player = Core.Functions.GetPlayer(source)
local Reciever = Core.Functions.GetPlayer(tonumber(citizen))
local Player = getPlayer(source)
local Reciever = getPlayer(tonumber(citizen))
local amount = tonumber(price)
local balance = Player.Functions.GetMoney("cash")
local balance = Player.cash
if amount and amount > 0 then
if balance >= amount then
Player.Functions.RemoveMoney('cash', amount)
triggerNotify(nil, Loc[Config.Lan].success["you_gave"]..Reciever.PlayerData.charinfo.firstname.." $"..cv(amount), "success", source)
Reciever.Functions.AddMoney('cash', amount)
triggerNotify(nil, Loc[Config.Lan].success["you_got"]..cv(amount)..Loc[Config.Lan].success["from"]..Player.PlayerData.charinfo.firstname, "success", tonumber(citizen))
chargePlayer(amount, "cash", source)
triggerNotify(nil, locale("success" ,"you_gave")..Reciever.name.." $"..cv(amount), "success", source)
fundPlayer(amount, "cash", Reciever.source)
triggerNotify(nil, locale("success" ,"you_got")..cv(amount)..locale("success" ,"from")..Player.name, "success", tonumber(citizen))
elseif balance < amount then
triggerNotify(nil, Loc[Config.Lan].error["not_enough"], "error", source)
triggerNotify(nil, locale("error" ,"not_enough"), "error", source)
end
else triggerNotify(nil, Loc[Config.Lan].error["zero"], 'error', source) end
else triggerNotify(nil, locale("error" ,"zero"), 'error', source) end
end)