mirror of
https://github.com/jimathy/jim-payments.git
synced 2026-08-17 06:16:02 +01:00
place start functions behind onResourceStart()
ESX helper
This commit is contained in:
@@ -1,10 +1,49 @@
|
|||||||
registerCommand("cashgive", {
|
onResourceStart(function()
|
||||||
locale("command" , "pay_user"), {}, false,
|
registerCommand("cashgive", {
|
||||||
function(source)
|
locale("command" , "pay_user"), {}, false,
|
||||||
TriggerClientEvent(getScript()..":client:ATM:give", source)
|
function(source)
|
||||||
end
|
TriggerClientEvent(getScript()..":client:ATM:give", source)
|
||||||
})
|
end
|
||||||
|
})
|
||||||
|
|
||||||
|
createCallback(getScript()..":GetInfo", function(source)
|
||||||
|
local Player = getPlayer(source)
|
||||||
|
local society, gsociety = 0, 0
|
||||||
|
|
||||||
|
society = getSocietyAccount(Player.job)
|
||||||
|
if Player.gang ~= "none" then
|
||||||
|
gsociety = getSocietyAccount(Player.gang)
|
||||||
|
end
|
||||||
|
|
||||||
|
-- Savings account is only QBCore for now
|
||||||
|
if isStarted(QBExport) and not isStarted(QBXExport) 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
|
||||||
|
end
|
||||||
|
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
|
||||||
|
}
|
||||||
|
|
||||||
|
return retTable
|
||||||
|
end)
|
||||||
|
end, true)
|
||||||
|
|
||||||
RegisterServerEvent(getScript()..":server:ATM:use", function(amount, billtype, baccount, account, society, gsociety)
|
RegisterServerEvent(getScript()..":server:ATM:use", function(amount, billtype, baccount, account, society, gsociety)
|
||||||
local src = source
|
local src = source
|
||||||
@@ -207,44 +246,6 @@ RegisterServerEvent(getScript()..":server:ATM:use", function(amount, billtype, b
|
|||||||
end
|
end
|
||||||
end)
|
end)
|
||||||
|
|
||||||
createCallback(getScript()..":GetInfo", function(source)
|
|
||||||
local Player = getPlayer(source)
|
|
||||||
local society, gsociety = 0, 0
|
|
||||||
|
|
||||||
society = getSocietyAccount(Player.job)
|
|
||||||
if Player.gang ~= "none" then
|
|
||||||
gsociety = getSocietyAccount(Player.gang)
|
|
||||||
end
|
|
||||||
|
|
||||||
-- Savings account is only QBCore for now
|
|
||||||
if isStarted(QBExport) and not isStarted(QBXExport) 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
|
|
||||||
end
|
|
||||||
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
|
|
||||||
}
|
|
||||||
|
|
||||||
return retTable
|
|
||||||
end)
|
|
||||||
|
|
||||||
RegisterServerEvent(getScript()..":server:ATM:give", function(citizen, price)
|
RegisterServerEvent(getScript()..":server:ATM:give", function(citizen, price)
|
||||||
local Player = getPlayer(source)
|
local Player = getPlayer(source)
|
||||||
local Reciever = getPlayer(tonumber(citizen))
|
local Reciever = getPlayer(tonumber(citizen))
|
||||||
|
|||||||
@@ -9,26 +9,33 @@ onResourceStart(function()
|
|||||||
if Items and not Items["payticket"] then
|
if Items and not Items["payticket"] then
|
||||||
debugPrint("^1Error^7: ^2Unable to find ^7'^3payticket^7' ^2item it in the Shared^7")
|
debugPrint("^1Error^7: ^2Unable to find ^7'^3payticket^7' ^2item it in the Shared^7")
|
||||||
end
|
end
|
||||||
end, true)
|
|
||||||
|
|
||||||
registerCommand("cashregister", {
|
registerCommand("cashregister", {
|
||||||
locale("command", "cash_reg"), {}, false,
|
locale("command", "cash_reg"), {}, false,
|
||||||
function(source)
|
function(source)
|
||||||
TriggerClientEvent(getScript()..":client:Charge", source, {}, true)
|
TriggerClientEvent(getScript()..":client:Charge", source, {}, true)
|
||||||
end
|
|
||||||
})
|
|
||||||
|
|
||||||
createCallback(getScript()..":MakePlayerList", function(source)
|
|
||||||
local onlineList = {}
|
|
||||||
for _, v in pairs(GetPlayers()) do
|
|
||||||
if v ~= nil or type(v) ~= "number" then
|
|
||||||
local Player = getPlayer(v)
|
|
||||||
onlineList[#onlineList+1] = { value = tonumber(v), text = "["..v.."] - "..Player.name }
|
|
||||||
Wait(10)
|
|
||||||
end
|
end
|
||||||
|
})
|
||||||
|
|
||||||
|
createCallback(getScript()..":MakePlayerList", function(source)
|
||||||
|
local onlineList = {}
|
||||||
|
for _, v in pairs(GetPlayers()) do
|
||||||
|
if v ~= nil or type(v) ~= "number" then
|
||||||
|
local Player = getPlayer(v)
|
||||||
|
onlineList[#onlineList+1] = { value = tonumber(v), text = "["..v.."] - "..Player.name }
|
||||||
|
Wait(10)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
return onlineList
|
||||||
|
end)
|
||||||
|
|
||||||
|
|
||||||
|
if Config.General.Usebzzz then
|
||||||
|
createUseableItem('terminal', function(source, item)
|
||||||
|
TriggerClientEvent(getScript()..":client:Charge", source, {}, true)
|
||||||
|
end)
|
||||||
end
|
end
|
||||||
return onlineList
|
end, true)
|
||||||
end)
|
|
||||||
|
|
||||||
RegisterServerEvent(getScript()..":server:Charge", function(citizen, price, billtype, img, outside, gang)
|
RegisterServerEvent(getScript()..":server:Charge", function(citizen, price, billtype, img, outside, gang)
|
||||||
local src = source
|
local src = source
|
||||||
@@ -94,11 +101,3 @@ RegisterServerEvent(getScript()..":server:PayPopup", function(data)
|
|||||||
triggerNotify(nil, billed.firstname..locale("error", "decline_pay")..data.amount..locale("success", "payment"), "error", data.biller)
|
triggerNotify(nil, billed.firstname..locale("error", "decline_pay")..data.amount..locale("success", "payment"), "error", data.biller)
|
||||||
end
|
end
|
||||||
end)
|
end)
|
||||||
|
|
||||||
CreateThread(function()
|
|
||||||
if Config.General.Usebzzz then
|
|
||||||
createUseableItem('terminal', function(source, item)
|
|
||||||
TriggerClientEvent(getScript()..":client:Charge", source, {}, true)
|
|
||||||
end)
|
|
||||||
end
|
|
||||||
end)
|
|
||||||
@@ -1,9 +1,11 @@
|
|||||||
registerCommand("polcharge", {
|
onResourceStart(function()
|
||||||
locale("command", "charge"), {}, false,
|
registerCommand("polcharge", {
|
||||||
function(source)
|
locale("command", "charge"), {}, false,
|
||||||
TriggerClientEvent(getScript()..":client:PolCharge", source)
|
function(source)
|
||||||
end
|
TriggerClientEvent(getScript()..":client:PolCharge", source)
|
||||||
})
|
end
|
||||||
|
})
|
||||||
|
end, true)
|
||||||
|
|
||||||
RegisterServerEvent(getScript()..":server:PolCharge", function(citizen, price)
|
RegisterServerEvent(getScript()..":server:PolCharge", function(citizen, price)
|
||||||
local src = source
|
local src = source
|
||||||
@@ -19,7 +21,7 @@ RegisterServerEvent(getScript()..":server:PolCharge", function(citizen, price)
|
|||||||
print("^3Warning^7: ^2Can't find player's job in ^7'Config.Polcharge.FineJobs', ^2defaulting to 0.25 (25% commission)^7")
|
print("^3Warning^7: ^2Can't find player's job in ^7'Config.Polcharge.FineJobs', ^2defaulting to 0.25 (25% commission)^7")
|
||||||
end
|
end
|
||||||
local commission = math.floor(price * commPercent)
|
local commission = math.floor(price * commPercent)
|
||||||
print(commission)
|
|
||||||
if price > 0 then
|
if price > 0 then
|
||||||
if not Config.PolCharge.FineJobConfirmation then
|
if not Config.PolCharge.FineJobConfirmation then
|
||||||
polCharge({
|
polCharge({
|
||||||
|
|||||||
Reference in New Issue
Block a user