mirror of
https://github.com/jimathy/jim-payments.git
synced 2026-08-17 06:16:02 +01:00
Compare commits
28 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
f9029f0951 | ||
|
|
65f51520fb | ||
|
|
7e92b852cf | ||
|
|
a63b40c11f | ||
|
|
644294546e | ||
|
|
4dbe600680 | ||
|
|
9d5086e5d5 | ||
|
|
b06cb05266 | ||
|
|
f16a0b0d1f | ||
|
|
48003e09a6 | ||
|
|
95459f63a8 | ||
|
|
0065af7c9d | ||
|
|
74990226a9 | ||
|
|
2e5bcc4d86 | ||
|
|
185c641f60 | ||
|
|
3e036d6996 | ||
|
|
a4a67da493 | ||
|
|
2dc29de368 | ||
|
|
8379179631 | ||
|
|
e3e8d71bea | ||
|
|
07c0195d26 | ||
|
|
0df97ac406 | ||
|
|
ad4f5dd203 | ||
|
|
76ff8dcfec | ||
|
|
61fc56d82d | ||
|
|
b4d185105d | ||
|
|
4e16ff4e04 | ||
|
|
7d059c27d0 |
29
README.md
29
README.md
@@ -1,14 +1,16 @@
|
|||||||
# jim-payments
|
# jim-payments
|
||||||
QBCore based payment system
|
QBCore based payment system
|
||||||
|
|
||||||
|
If you think I did a good job here, consider donating as it keeps by lights on and my cat fat:
|
||||||
|
https://ko-fi.com/jixelpatterns
|
||||||
|
--------------
|
||||||
|
|
||||||
If you use a different phone/invoice system let me know and I will add support for it as best I can!
|
If you use a different phone/invoice system let me know and I will add support for it as best I can!
|
||||||
--------------
|
|
||||||
|
|
||||||
Enchanced QB-Input payment system from my other scripts now free on its own
|
Enchanced QB-Input payment system from my other scripts now free on its own
|
||||||
|
|
||||||
 
|
 
|
||||||
|
 
|
||||||
# Installation
|
# Installation
|
||||||
|
|
||||||
To make use of this payment system you need trigger the event
|
To make use of this payment system you need trigger the event
|
||||||
@@ -44,8 +46,25 @@ Go to [qb] > qb-phone > client > main.lua
|
|||||||
|
|
||||||
- Add this line:
|
- Add this line:
|
||||||
|
|
||||||
```TriggerServerEvent('jim-payments:Tickets:Give', amount, society)```
|
```TriggerServerEvent('jim-payments:Tickets:Give', data)```
|
||||||
|
|
||||||
--------------
|
--------------
|
||||||
|
|
||||||
NOTE: If you are converting from my older job scripts, I recommend removing the previous triggers from qb-phone
|
The latest banking systems are very simple to use and add,
|
||||||
|
simply look in the atms.lua and change the config options at the top
|
||||||
|
|
||||||
|
Choose wether to use atm's, choose wether to use banking locations
|
||||||
|
Choose wether to add bank blips (if you want to disable qb-banking)
|
||||||
|
Choose wether to add ATM blips (if you like $ signs)
|
||||||
|
|
||||||
|
|
||||||
|
--------------
|
||||||
|
|
||||||
|
New Commission system added
|
||||||
|
|
||||||
|
This brings more config options to find tune the script
|
||||||
|
|
||||||
|
Choose wether people get commission from every sale
|
||||||
|
Choose if EVERY worker gets Commission that is on duty
|
||||||
|
Choose if Commission is limited by MinAmountForTicket
|
||||||
|
Choose if the worker charging the customer gets double commission
|
||||||
|
|||||||
80
atms.lua
80
atms.lua
@@ -3,13 +3,6 @@ local QBCore = exports['qb-core']:GetCoreObject()
|
|||||||
-- This script is a simple replacement for QB-Banking and QB-ATMs
|
-- This script is a simple replacement for QB-Banking and QB-ATMs
|
||||||
-- It uses QB-Input and server callbacks to retreive info about accounts and cash
|
-- It uses QB-Input and server callbacks to retreive info about accounts and cash
|
||||||
-- This requires QB-Target and has the location of every ATM, ATM prop and bank window
|
-- This requires QB-Target and has the location of every ATM, ATM prop and bank window
|
||||||
-- If Config.useATM = false, then none of this load
|
|
||||||
|
|
||||||
--Specific to ATM config options
|
|
||||||
Config.useATM = true
|
|
||||||
Config.useBanks = true
|
|
||||||
Config.BankBlips = true
|
|
||||||
Config.ATMBlips = false
|
|
||||||
|
|
||||||
Config.ATMModels = {"prop_atm_01", "prop_atm_02", "prop_atm_03", "prop_fleeca_atm" }
|
Config.ATMModels = {"prop_atm_01", "prop_atm_02", "prop_atm_03", "prop_fleeca_atm" }
|
||||||
|
|
||||||
@@ -94,7 +87,6 @@ Config.BankLocations = {
|
|||||||
--vector3(252.41, 221.41, 106.29)
|
--vector3(252.41, 221.41, 106.29)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
local function cv(amount)
|
local function cv(amount)
|
||||||
local formatted = amount
|
local formatted = amount
|
||||||
while true do
|
while true do
|
||||||
@@ -107,19 +99,6 @@ local function cv(amount)
|
|||||||
end
|
end
|
||||||
local function createBlips()
|
local function createBlips()
|
||||||
if Config.useATM then
|
if Config.useATM then
|
||||||
if Config.BankBlips then
|
|
||||||
for k, v in pairs(Config.BankLocations) do
|
|
||||||
blip = AddBlipForCoord(v)
|
|
||||||
SetBlipSprite(blip, 108)
|
|
||||||
SetBlipDisplay(blip, 4)
|
|
||||||
SetBlipScale(blip, 0.55)
|
|
||||||
SetBlipColour(blip, 2)
|
|
||||||
SetBlipAsShortRange(blip, true)
|
|
||||||
BeginTextCommandSetBlipName("STRING")
|
|
||||||
AddTextComponentString("Bank")
|
|
||||||
EndTextCommandSetBlipName(blip)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
if Config.ATMBlips then
|
if Config.ATMBlips then
|
||||||
for k, v in pairs(Config.ATMLocations) do
|
for k, v in pairs(Config.ATMLocations) do
|
||||||
blip = AddBlipForCoord(v)
|
blip = AddBlipForCoord(v)
|
||||||
@@ -134,25 +113,41 @@ local function createBlips()
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
if Config.useBanks then
|
||||||
|
if Config.BankBlips then
|
||||||
|
for k, v in pairs(Config.BankLocations) do
|
||||||
|
blip = AddBlipForCoord(v)
|
||||||
|
SetBlipSprite(blip, 108)
|
||||||
|
SetBlipDisplay(blip, 4)
|
||||||
|
SetBlipScale(blip, 0.55)
|
||||||
|
SetBlipColour(blip, 2)
|
||||||
|
SetBlipAsShortRange(blip, true)
|
||||||
|
BeginTextCommandSetBlipName("STRING")
|
||||||
|
AddTextComponentString("Bank")
|
||||||
|
EndTextCommandSetBlipName(blip)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
AddEventHandler('onResourceStart', function(resource) if GetCurrentResourceName() == resource then createBlips() end end)
|
AddEventHandler('onResourceStart', function(resource) if GetCurrentResourceName() == resource then createBlips() end end)
|
||||||
|
|
||||||
RegisterNetEvent('QBCore:Client:OnPlayerLoaded', function() createBlips() end)
|
RegisterNetEvent('QBCore:Client:OnPlayerLoaded', function() createBlips() end)
|
||||||
|
|
||||||
|
local bossroles = {}
|
||||||
|
local gangroles = {}
|
||||||
Citizen.CreateThread(function()
|
Citizen.CreateThread(function()
|
||||||
local bossroles = {}
|
if Config.useATM or Config.useBanks then
|
||||||
for k, v in pairs(Config.Jobs) do
|
for k, v in pairs(QBCore.Shared.Jobs) do ---Grabs the list of jobs
|
||||||
for l, b in pairs(QBCore.Shared.Jobs[tostring(k)].grades) do
|
for l, b in pairs(QBCore.Shared.Jobs[tostring(k)].grades) do -- Grabs the list of grades
|
||||||
if QBCore.Shared.Jobs[tostring(k)].grades[l].isboss == true then
|
if QBCore.Shared.Jobs[tostring(k)].grades[l].isboss == true then -- Checks the grade if is boss
|
||||||
if bossroles[tostring(k)] ~= nil then
|
if bossroles[tostring(k)] ~= nil then -- checks if the line exists
|
||||||
if bossroles[tostring(k)] > tonumber(l) then bossroles[tostring(k)] = tonumber(l) end
|
if bossroles[tostring(k)] > tonumber(l) then bossroles[tostring(k)] = tonumber(l) end -- the
|
||||||
else bossroles[tostring(k)] = tonumber(l)
|
else bossroles[tostring(k)] = tonumber(l)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
local gangroles = {}
|
|
||||||
for k, v in pairs(QBCore.Shared.Gangs) do
|
for k, v in pairs(QBCore.Shared.Gangs) do
|
||||||
for l, b in pairs(QBCore.Shared.Gangs[tostring(k)].grades) do
|
for l, b in pairs(QBCore.Shared.Gangs[tostring(k)].grades) do
|
||||||
if tostring(k) ~= "none" then
|
if tostring(k) ~= "none" then
|
||||||
@@ -162,17 +157,17 @@ Citizen.CreateThread(function()
|
|||||||
else gangroles[tostring(k)] = tonumber(l)
|
else gangroles[tostring(k)] = tonumber(l)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
end
|
||||||
if Config.useATM then
|
if Config.useATM then
|
||||||
exports['qb-target']:AddTargetModel(Config.ATMModels, { options = { { event = "jim-payments:Client:ATM:use", icon = "fas fa-money-check-alt", label = "Use ATM", id = "atm" },}, distance = 1.5, })
|
exports['qb-target']:AddTargetModel(Config.ATMModels, { options = { { event = "jim-payments:Client:ATM:use", icon = "fas fa-money-check-alt", label = "Use ATM", id = "atm" },}, distance = 1.5, })
|
||||||
for k,v in pairs(Config.ATMLocations) do
|
for k,v in pairs(Config.ATMLocations) do
|
||||||
exports['qb-target']:AddCircleZone("jimatm"..k, vector3(tonumber(v.x), tonumber(v.y), tonumber(v.z)+0.2), 0.5, { name="jimatm"..k, debugPoly=false, useZ=true, },
|
exports['qb-target']:AddCircleZone("jimatm"..k, vector3(tonumber(v.x), tonumber(v.y), tonumber(v.z)+0.2), 0.5, { name="jimatm"..k, debugPoly=false, useZ=true, },
|
||||||
{ options = { { event = "jim-payments:Client:ATM:use", icon = "fas fa-money-check-alt", label = "Use ATM", id = "atm" },
|
{ options = { { event = "jim-payments:Client:ATM:use", icon = "fas fa-money-check-alt", label = "Use ATM", id = "atm" },
|
||||||
--[[{ event = "jim-payments:Client:ATM:use", icon = "fas fa-arrow-right-arrow-left", label = "Transfer Money", id = "transfer" },]] }, distance = 1.5 })
|
--[[{ event = "jim-payments:Client:ATM:use", icon = "fas fa-arrow-right-arrow-left", label = "Transfer Money", id = "transfer" },]]
|
||||||
|
}, distance = 1.5 })
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
if Config.useBanks then
|
if Config.useBanks then
|
||||||
@@ -202,26 +197,29 @@ local function PlayATMAnimation(animation)
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
local function GrabAccount(type, job)
|
||||||
|
local p = promise.new()
|
||||||
|
QBCore.Functions.TriggerCallback('jim-payments:ManageWrapper', function(cb) p:resolve(cb) end, type, job)
|
||||||
|
return Citizen.Await(p)
|
||||||
|
end
|
||||||
|
|
||||||
RegisterNetEvent('jim-payments:Client:ATM:use', function(data)
|
RegisterNetEvent('jim-payments:Client:ATM:use', function(data)
|
||||||
--this grabs all the info from names to savings account numbers in the databases
|
--this grabs all the info from names to savings account numbers in the databases
|
||||||
while name == nil do
|
while name == nil do
|
||||||
QBCore.Functions.TriggerCallback('jim-payments:ATM:Find', function(cb1, cb2, cb3, cb4, cb5, cb6, cb7) name = cb1 cash = cb2 bank = cb3 account = cb4 cid = cb5 savbal = cb6 aid = cb7 end)
|
QBCore.Functions.TriggerCallback('jim-payments:ATM:Find', function(cb1, cb2, cb3, cb4, cb5, cb6, cb7) name = cb1 cash = cb2 bank = cb3 account = cb4 cid = cb5 savbal = cb6 aid = cb7 end)
|
||||||
Citizen.Wait(100)
|
Citizen.Wait(100)
|
||||||
end
|
end
|
||||||
while society == nil do
|
|
||||||
QBCore.Functions.TriggerCallback('qb-bossmenu:server:GetAccount', function(cb) society = cb end, PlayerJob.name)
|
society = GrabAccount("GetAccount", PlayerJob.name)
|
||||||
Citizen.Wait(100)
|
Wait(200)
|
||||||
end
|
gsociety = GrabAccount("GetGangAccount", PlayerGang.name)
|
||||||
while gsociety == nil do
|
|
||||||
QBCore.Functions.TriggerCallback('qb-gangmenu:server:GetAccount', function(cb) gsociety = cb end, PlayerGang.name)
|
|
||||||
Citizen.Wait(100)
|
|
||||||
end
|
|
||||||
local atmbartime = 2500
|
local atmbartime = 2500
|
||||||
local setoptions = {}
|
local setoptions = {}
|
||||||
|
|
||||||
if data.id == "atm" then
|
if data.id == "atm" then
|
||||||
setoptions = { { value = "withdraw", text = "Withdrawl" }, }
|
setoptions = { { value = "withdraw", text = "Withdrawl" }, }
|
||||||
setview = "Welcome back, "..name.."<br><br>- Citizen ID -<br>"..cid.."<br><br>- Balances -<br>🏦Bank - $"..cv(bank).."<br>💵Cash - $"..cv(cash)..'<br><br>- Options -'
|
setview = "<center><img src=https://static.wikia.nocookie.net/gtawiki/images/b/bd/Fleeca-GTAV-Logo.png width=200px></center><br>Welcome back, "..name.."<br><br>- Citizen ID -<br>"..cid.."<br><br>- Balances -<br>🏦Bank - $"..cv(bank).."<br>💵Cash - $"..cv(cash)..'<br><br>- Options -'
|
||||||
setheader = "💵 ATM Banking 💵"
|
setheader = "💵 ATM Banking 💵"
|
||||||
setinputs = { { type = 'radio', name = 'billtype', text = setview, options = setoptions },
|
setinputs = { { type = 'radio', name = 'billtype', text = setview, options = setoptions },
|
||||||
{ type = 'number', isRequired = true, name = 'amount', text = '💵 Amount to transfer' }, }
|
{ type = 'number', isRequired = true, name = 'amount', text = '💵 Amount to transfer' }, }
|
||||||
|
|||||||
@@ -13,6 +13,13 @@ end
|
|||||||
|
|
||||||
|
|
||||||
---- BANK STUFF
|
---- BANK STUFF
|
||||||
|
QBCore.Functions.CreateCallback('jim-payments:ManageWrapper', function(source, cb, type, account)
|
||||||
|
local result = nil
|
||||||
|
if type == "GetAccount" then result = exports["qb-management"]:GetAccount(account) end
|
||||||
|
if type == "GetGangAccount" then result = exports["qb-management"]:GetGangAccount(account) end
|
||||||
|
cb(result)
|
||||||
|
end)
|
||||||
|
|
||||||
RegisterServerEvent('jim-payments:server:ATM:use', function(amount, billtype, baccount, account, society, gsociety)
|
RegisterServerEvent('jim-payments:server:ATM:use', function(amount, billtype, baccount, account, society, gsociety)
|
||||||
local src = source
|
local src = source
|
||||||
local Player = QBCore.Functions.GetPlayer(src)
|
local Player = QBCore.Functions.GetPlayer(src)
|
||||||
@@ -72,17 +79,19 @@ RegisterServerEvent('jim-payments:server:ATM:use', function(amount, billtype, ba
|
|||||||
elseif tonumber(society) >= amount then
|
elseif tonumber(society) >= amount then
|
||||||
TriggerClientEvent("QBCore:Notify", src, "Withdrew $"..cv(amount).." from the "..Player.PlayerData.job.label.." account", "success")
|
TriggerClientEvent("QBCore:Notify", src, "Withdrew $"..cv(amount).." from the "..Player.PlayerData.job.label.." account", "success")
|
||||||
Player.Functions.AddMoney('bank', amount)
|
Player.Functions.AddMoney('bank', amount)
|
||||||
TriggerEvent("qb-bossmenu:server:removeAccountMoney", tostring(Player.PlayerData.job.name), amount)
|
exports["qb-management"]:RemoveMoney(tostring(Player.PlayerData.job.name), amount)
|
||||||
|
--TriggerEvent("qb-bossmenu:server:removeAccountMoney", tostring(Player.PlayerData.job.name), amount)
|
||||||
end
|
end
|
||||||
elseif billtype == "deposit" then
|
elseif billtype == "deposit" then
|
||||||
if bankB < amount then TriggerClientEvent("QBCore:Notify", src, "Not enough money in your bank", "error")
|
if bankB < amount then TriggerClientEvent("QBCore:Notify", src, "Not enough money in your bank", "error")
|
||||||
elseif bankB >= amount then
|
elseif bankB >= amount then
|
||||||
TriggerEvent("qb-bossmenu:server:addAccountMoney", tostring(Player.PlayerData.job.name), amount)
|
exports["qb-management"]:AddMoney(tostring(Player.PlayerData.job.name), amount)
|
||||||
|
--TriggerEvent("qb-bossmenu:server:addAccountMoney", tostring(Player.PlayerData.job.name), amount)
|
||||||
Player.Functions.RemoveMoney('bank', amount) Wait(1500)
|
Player.Functions.RemoveMoney('bank', amount) Wait(1500)
|
||||||
TriggerClientEvent("QBCore:Notify", src, "Deposited $"..cv(amount).." into the "..Player.PlayerData.job.label.." account", "success")
|
TriggerClientEvent("QBCore:Notify", src, "Deposited $"..cv(amount).." into the "..Player.PlayerData.job.label.." account", "success")
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
-- Transfers between players --
|
-- Transfer from boss account to players --
|
||||||
elseif account == "societytransfer" then
|
elseif account == "societytransfer" then
|
||||||
local bannedCharacters = {'%','$',';'}
|
local bannedCharacters = {'%','$',';'}
|
||||||
local newAmount = tostring(amount)
|
local newAmount = tostring(amount)
|
||||||
@@ -97,10 +106,11 @@ RegisterServerEvent('jim-payments:server:ATM:use', function(amount, billtype, ba
|
|||||||
local Player = QBCore.Functions.GetPlayer(src)
|
local Player = QBCore.Functions.GetPlayer(src)
|
||||||
if (society - amount) >= 0 then
|
if (society - amount) >= 0 then
|
||||||
local query = '%"account":"' .. baccount .. '"%'
|
local query = '%"account":"' .. baccount .. '"%'
|
||||||
local result = exports.oxmysql:executeSync('SELECT * FROM players WHERE charinfo LIKE ?', {query})
|
local result = MySQL.Sync.fetchAll('SELECT * FROM players WHERE charinfo LIKE ?', {query})
|
||||||
if result[1] ~= nil then
|
if result[1] ~= nil then
|
||||||
local Reciever = QBCore.Functions.GetPlayerByCitizenId(result[1].citizenid)
|
local Reciever = QBCore.Functions.GetPlayerByCitizenId(result[1].citizenid)
|
||||||
TriggerEvent("qb-gangmenu:server:removeAccountMoney", tostring(Player.PlayerData.gang.name), amount)
|
exports["qb-management"]:RemoveMoney(tostring(Player.PlayerData.job.name), amount)
|
||||||
|
--TriggerEvent("qb-bossmenu:server:removeAccountMoney", tostring(Player.PlayerData.job.name), amount)
|
||||||
if Reciever ~= nil then
|
if Reciever ~= nil then
|
||||||
Reciever.Functions.AddMoney('bank', amount)
|
Reciever.Functions.AddMoney('bank', amount)
|
||||||
TriggerClientEvent("QBCore:Notify", src, "Sent $"..amount.." to "..Reciever.PlayerData.charinfo.firstname.." "..Reciever.PlayerData.charinfo.lastname, "success")
|
TriggerClientEvent("QBCore:Notify", src, "Sent $"..amount.." to "..Reciever.PlayerData.charinfo.firstname.." "..Reciever.PlayerData.charinfo.lastname, "success")
|
||||||
@@ -108,31 +118,32 @@ RegisterServerEvent('jim-payments:server:ATM:use', function(amount, billtype, ba
|
|||||||
else
|
else
|
||||||
local RecieverMoney = json.decode(result[1].money)
|
local RecieverMoney = json.decode(result[1].money)
|
||||||
RecieverMoney.bank = (RecieverMoney.bank + amount)
|
RecieverMoney.bank = (RecieverMoney.bank + amount)
|
||||||
exports.oxmysql:execute('UPDATE players SET money = ? WHERE citizenid = ?', {json.encode(RecieverMoney), result[1].citizenid})
|
MySQL.Async.execute('UPDATE players SET money = ? WHERE citizenid = ?', {json.encode(RecieverMoney), result[1].citizenid})
|
||||||
end
|
end
|
||||||
elseif result[1] == nil then TriggerClientEvent("QBCore:Notify", src, "Error: Account '"..baccount.."' not found", "error")
|
elseif result[1] == nil then TriggerClientEvent("QBCore:Notify", src, "Error: Account '"..baccount.."' not found", "error")
|
||||||
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
--Simple transfers from society account to bank --
|
--Simple transfers from gang society account to bank --
|
||||||
elseif account == "gang" then
|
elseif account == "gang" then
|
||||||
if billtype == "withdraw" then
|
if billtype == "withdraw" then
|
||||||
if tonumber(gsociety) < amount then TriggerClientEvent("QBCore:Notify", src, "Society balance too low", "error")
|
if tonumber(gsociety) < amount then TriggerClientEvent("QBCore:Notify", src, "Society balance too low", "error")
|
||||||
elseif tonumber(gsociety) >= amount then
|
elseif tonumber(gsociety) >= amount then
|
||||||
TriggerClientEvent("QBCore:Notify", src, "Withdrew $"..cv(amount).." from the "..Player.PlayerData.gang.label.." account", "success")
|
TriggerClientEvent("QBCore:Notify", src, "Withdrew $"..cv(amount).." from the "..Player.PlayerData.gang.label.." account", "success")
|
||||||
Player.Functions.AddMoney('bank', amount)
|
Player.Functions.AddMoney('bank', amount)
|
||||||
TriggerEvent("qb-gangmenu:server:removeAccountMoney", tostring(Player.PlayerData.gang.name), amount)
|
exports["qb-management"]:RemoveGangMoney(tostring(Player.PlayerData.gang.name), amount)
|
||||||
|
--TriggerEvent("qb-gangmenu:server:removeAccountMoney", tostring(Player.PlayerData.gang.name), amount)
|
||||||
end
|
end
|
||||||
elseif billtype == "deposit" then
|
elseif billtype == "deposit" then
|
||||||
if bankB < amount then TriggerClientEvent("QBCore:Notify", src, "Not enough money in your bank", "error")
|
if bankB < amount then TriggerClientEvent("QBCore:Notify", src, "Not enough money in your bank", "error")
|
||||||
elseif bankB >= amount then
|
elseif bankB >= amount then
|
||||||
TriggerEvent("qb-gangmenu:server:addAccountMoney", tostring(Player.PlayerData.gang.name), amount)
|
exports["qb-management"]:AddGangMoney(tostring(Player.PlayerData.gang.name), amount)
|
||||||
|
--TriggerEvent("qb-gangmenu:server:addAccountMoney", tostring(Player.PlayerData.gang.name), amount)
|
||||||
Player.Functions.RemoveMoney('bank', amount) Wait(1500)
|
Player.Functions.RemoveMoney('bank', amount) Wait(1500)
|
||||||
TriggerClientEvent("QBCore:Notify", src, "Deposited $"..cv(amount).." into the "..Player.PlayerData.gang.label.." account", "success")
|
TriggerClientEvent("QBCore:Notify", src, "Deposited $"..cv(amount).." into the "..Player.PlayerData.gang.label.." account", "success")
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
-- Transfers between players --
|
-- Transfer from gang account to players --
|
||||||
elseif account == "gangtransfer" then
|
elseif account == "gangtransfer" then
|
||||||
local bannedCharacters = {'%','$',';'}
|
local bannedCharacters = {'%','$',';'}
|
||||||
local newAmount = tostring(amount)
|
local newAmount = tostring(amount)
|
||||||
@@ -147,10 +158,11 @@ RegisterServerEvent('jim-payments:server:ATM:use', function(amount, billtype, ba
|
|||||||
local Player = QBCore.Functions.GetPlayer(src)
|
local Player = QBCore.Functions.GetPlayer(src)
|
||||||
if (gsociety - amount) >= 0 then
|
if (gsociety - amount) >= 0 then
|
||||||
local query = '%"account":"' .. baccount .. '"%'
|
local query = '%"account":"' .. baccount .. '"%'
|
||||||
local result = exports.oxmysql:executeSync('SELECT * FROM players WHERE charinfo LIKE ?', {query})
|
local result = MySQL.Sync.fetchAll('SELECT * FROM players WHERE charinfo LIKE ?', {query})
|
||||||
if result[1] ~= nil then
|
if result[1] ~= nil then
|
||||||
local Reciever = QBCore.Functions.GetPlayerByCitizenId(result[1].citizenid)
|
local Reciever = QBCore.Functions.GetPlayerByCitizenId(result[1].citizenid)
|
||||||
TriggerEvent("qb-bossmenu:server:removeAccountMoney", tostring(Player.PlayerData.gang.name), amount)
|
exports["qb-management"]:RemoveGangMoney(tostring(Player.PlayerData.gang.name), amount)
|
||||||
|
--TriggerEvent("qb-bossmenu:server:removeAccountMoney", tostring(Player.PlayerData.gang.name), amount)
|
||||||
if Reciever ~= nil then
|
if Reciever ~= nil then
|
||||||
Reciever.Functions.AddMoney('bank', amount)
|
Reciever.Functions.AddMoney('bank', amount)
|
||||||
TriggerClientEvent("QBCore:Notify", src, "Sent $"..amount.." to "..Reciever.PlayerData.charinfo.firstname.." "..Reciever.PlayerData.charinfo.lastname, "success")
|
TriggerClientEvent("QBCore:Notify", src, "Sent $"..amount.." to "..Reciever.PlayerData.charinfo.firstname.." "..Reciever.PlayerData.charinfo.lastname, "success")
|
||||||
@@ -158,7 +170,7 @@ RegisterServerEvent('jim-payments:server:ATM:use', function(amount, billtype, ba
|
|||||||
else
|
else
|
||||||
local RecieverMoney = json.decode(result[1].money)
|
local RecieverMoney = json.decode(result[1].money)
|
||||||
RecieverMoney.bank = (RecieverMoney.bank + amount)
|
RecieverMoney.bank = (RecieverMoney.bank + amount)
|
||||||
exports.oxmysql:execute('UPDATE players SET money = ? WHERE citizenid = ?', {json.encode(RecieverMoney), result[1].citizenid})
|
MySQL.Async.execute('UPDATE players SET money = ? WHERE citizenid = ?', {json.encode(RecieverMoney), result[1].citizenid})
|
||||||
end
|
end
|
||||||
elseif result[1] == nil then TriggerClientEvent("QBCore:Notify", src, "Error: Account '"..baccount.."' not found", "error")
|
elseif result[1] == nil then TriggerClientEvent("QBCore:Notify", src, "Error: Account '"..baccount.."' not found", "error")
|
||||||
|
|
||||||
@@ -180,7 +192,7 @@ RegisterServerEvent('jim-payments:server:ATM:use', function(amount, billtype, ba
|
|||||||
local Player = QBCore.Functions.GetPlayer(src)
|
local Player = QBCore.Functions.GetPlayer(src)
|
||||||
if (Player.PlayerData.money.bank - amount) >= 0 then
|
if (Player.PlayerData.money.bank - amount) >= 0 then
|
||||||
local query = '%"account":"' .. baccount .. '"%'
|
local query = '%"account":"' .. baccount .. '"%'
|
||||||
local result = exports.oxmysql:executeSync('SELECT * FROM players WHERE charinfo LIKE ?', {query})
|
local result = MySQL.Sync.fetchAll('SELECT * FROM players WHERE charinfo LIKE ?', {query})
|
||||||
if result[1] ~= nil then
|
if result[1] ~= nil then
|
||||||
local Reciever = QBCore.Functions.GetPlayerByCitizenId(result[1].citizenid)
|
local Reciever = QBCore.Functions.GetPlayerByCitizenId(result[1].citizenid)
|
||||||
Player.Functions.RemoveMoney('bank', amount)
|
Player.Functions.RemoveMoney('bank', amount)
|
||||||
@@ -191,7 +203,7 @@ RegisterServerEvent('jim-payments:server:ATM:use', function(amount, billtype, ba
|
|||||||
else
|
else
|
||||||
local RecieverMoney = json.decode(result[1].money)
|
local RecieverMoney = json.decode(result[1].money)
|
||||||
RecieverMoney.bank = (RecieverMoney.bank + amount)
|
RecieverMoney.bank = (RecieverMoney.bank + amount)
|
||||||
exports.oxmysql:execute('UPDATE players SET money = ? WHERE citizenid = ?', {json.encode(RecieverMoney), result[1].citizenid})
|
MySQL.Async.execute('UPDATE players SET money = ? WHERE citizenid = ?', {json.encode(RecieverMoney), result[1].citizenid})
|
||||||
end
|
end
|
||||||
elseif result[1] == nil then TriggerClientEvent("QBCore:Notify", src, "Error: Account '"..baccount.."' not found", "error")
|
elseif result[1] == nil then TriggerClientEvent("QBCore:Notify", src, "Error: Account '"..baccount.."' not found", "error")
|
||||||
|
|
||||||
@@ -234,7 +246,7 @@ RegisterServerEvent("jim-payments:server:ATM:give", function(citizen, price)
|
|||||||
Player.Functions.RemoveMoney('cash', amount)
|
Player.Functions.RemoveMoney('cash', amount)
|
||||||
TriggerClientEvent("QBCore:Notify", source, "You gave "..Reciever.PlayerData.charinfo.firstname.." $"..cv(amount), "success")
|
TriggerClientEvent("QBCore:Notify", source, "You gave "..Reciever.PlayerData.charinfo.firstname.." $"..cv(amount), "success")
|
||||||
Reciever.Functions.AddMoney('cash', amount)
|
Reciever.Functions.AddMoney('cash', amount)
|
||||||
TriggerClientEvent("QBCore:Notify", tonumber(citizen), "You got $"..cv(amount).." from "..Reciever.PlayerData.charinfo.firstname, "success")
|
TriggerClientEvent("QBCore:Notify", tonumber(citizen), "You got $"..cv(amount).." from "..Player.PlayerData.charinfo.firstname, "success")
|
||||||
elseif balance < amount then
|
elseif balance < amount then
|
||||||
TriggerClientEvent("QBCore:Notify", source, "You don't have enough cash to give", "error")
|
TriggerClientEvent("QBCore:Notify", source, "You don't have enough cash to give", "error")
|
||||||
end
|
end
|
||||||
|
|||||||
63
client.lua
63
client.lua
@@ -3,33 +3,13 @@ local QBCore = exports['qb-core']:GetCoreObject()
|
|||||||
PlayerJob = {}
|
PlayerJob = {}
|
||||||
local onDuty = false
|
local onDuty = false
|
||||||
|
|
||||||
RegisterNetEvent('QBCore:Client:OnPlayerLoaded')
|
RegisterNetEvent('QBCore:Client:OnPlayerLoaded') AddEventHandler('QBCore:Client:OnPlayerLoaded', function() QBCore.Functions.GetPlayerData(function(PlayerData) PlayerJob = PlayerData.job PlayerGang = PlayerData.gang end) end)
|
||||||
AddEventHandler('QBCore:Client:OnPlayerLoaded', function()
|
RegisterNetEvent('QBCore:Client:OnJobUpdate') AddEventHandler('QBCore:Client:OnJobUpdate', function(JobInfo) PlayerJob = JobInfo onDuty = PlayerJob.onduty end)
|
||||||
QBCore.Functions.GetPlayerData(function(PlayerData)
|
RegisterNetEvent('QBCore:Client:SetDuty') AddEventHandler('QBCore:Client:SetDuty', function(duty) onDuty = duty end)
|
||||||
PlayerJob = PlayerData.job
|
RegisterNetEvent('QBCore:Client:OnGangUpdate') AddEventHandler('QBCore:Client:OnGangUpdate', function(GangInfo) PlayerGang = GangInfo end)
|
||||||
PlayerGang = PlayerData.gang
|
|
||||||
end)
|
|
||||||
end)
|
|
||||||
|
|
||||||
RegisterNetEvent('QBCore:Client:OnJobUpdate')
|
|
||||||
AddEventHandler('QBCore:Client:OnJobUpdate', function(JobInfo)
|
|
||||||
PlayerJob = JobInfo
|
|
||||||
onDuty = PlayerJob.onduty
|
|
||||||
end)
|
|
||||||
|
|
||||||
RegisterNetEvent('QBCore:Client:SetDuty')
|
|
||||||
AddEventHandler('QBCore:Client:SetDuty', function(duty)
|
|
||||||
onDuty = duty
|
|
||||||
end)
|
|
||||||
|
|
||||||
RegisterNetEvent('QBCore:Client:OnGangUpdate')
|
|
||||||
AddEventHandler('QBCore:Client:OnGangUpdate', function(GangInfo)
|
|
||||||
PlayerGang = GangInfo
|
|
||||||
end)
|
|
||||||
|
|
||||||
--Keeps track of duty on script restarts
|
--Keeps track of duty on script restarts
|
||||||
AddEventHandler('onResourceStart', function(resource)
|
AddEventHandler('onResourceStart', function(resource) if GetCurrentResourceName() == resource then QBCore.Functions.GetPlayerData(function(PlayerData) PlayerJob = PlayerData.job PlayerGang = PlayerData.gang onDuty = PlayerJob.onduty end) end end)
|
||||||
if GetCurrentResourceName() == resource then QBCore.Functions.GetPlayerData(function(PlayerData) PlayerJob = PlayerData.job PlayerGang = PlayerData.gang onDuty = PlayerJob.onduty end) end end)
|
|
||||||
|
|
||||||
Citizen.CreateThread(function()
|
Citizen.CreateThread(function()
|
||||||
local jobroles = {}
|
local jobroles = {}
|
||||||
@@ -38,7 +18,7 @@ Citizen.CreateThread(function()
|
|||||||
{ options = { { event = "jim-payments:Tickets:Menu", icon = "fas fa-receipt", label = "Cash in Receipts", job = jobroles } }, distance = 2.0 })
|
{ options = { { event = "jim-payments:Tickets:Menu", icon = "fas fa-receipt", label = "Cash in Receipts", job = jobroles } }, distance = 2.0 })
|
||||||
end)
|
end)
|
||||||
|
|
||||||
RegisterNetEvent('jim-payments:client:Charge', function()
|
RegisterNetEvent('jim-payments:client:Charge', function(data)
|
||||||
if not onDuty then TriggerEvent("QBCore:Notify", "Not Clocked in!", "error") return end -- Require to be on duty when making a payment
|
if not onDuty then TriggerEvent("QBCore:Notify", "Not Clocked in!", "error") return end -- Require to be on duty when making a payment
|
||||||
local onlineList = {}
|
local onlineList = {}
|
||||||
local nearbyList = {}
|
local nearbyList = {}
|
||||||
@@ -48,41 +28,48 @@ RegisterNetEvent('jim-payments:client:Charge', function()
|
|||||||
for i = 1, #onlineList do
|
for i = 1, #onlineList do
|
||||||
if onlineList[i].value == GetPlayerServerId(v) then
|
if onlineList[i].value == GetPlayerServerId(v) then
|
||||||
if v ~= PlayerId() then
|
if v ~= PlayerId() then
|
||||||
nearbyList[#nearbyList+1] = onlineList[i]
|
nearbyList[#nearbyList+1] = { value = onlineList[i].value, text = onlineList[i].text..' ('..math.floor(dist+0.05)..'m)' }
|
||||||
nearbyList[#nearbyList].text = nearbyList[#nearbyList].text..' ('..math.floor(dist+0.05)..'m)'
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
dist = nil
|
dist = nil
|
||||||
end
|
end
|
||||||
|
if data.img == nil then img = "" else img = data.img end
|
||||||
|
|
||||||
if nearbyList[#nearbyList] == nil then TriggerEvent("QBCore:Notify", "No one near by to charge", "error") return end
|
if nearbyList[#nearbyList] == nil then TriggerEvent("QBCore:Notify", "No one near by to charge", "error") return end
|
||||||
local dialog = exports['qb-input']:ShowInput({ header = PlayerJob.label.." Cash Register", submitText = "Send",
|
local dialog = exports['qb-input']:ShowInput({ header = img..PlayerJob.label.." Cash Register", submitText = "Send",
|
||||||
inputs = {
|
inputs = {
|
||||||
{ text = " ", name = "citizen", type = "select", options = nearbyList },
|
{ text = " ", name = "citizen", type = "select", options = nearbyList },
|
||||||
{ type = 'radio', name = 'billtype', text = 'Payment Type', options = { { value = "cash", text = "Cash" }, { value = "card", text = "Card" } } },
|
{ type = 'radio', name = 'billtype', text = 'Payment Type', options = { { value = "cash", text = "Cash" }, { value = "bank", text = "Card" } } },
|
||||||
{ type = 'number', isRequired = true, name = 'price', text = '💵 Amount to Charge' },}
|
{ type = 'number', isRequired = true, name = 'price', text = '💵 Amount to Charge' },}
|
||||||
})
|
})
|
||||||
if dialog then
|
if dialog then
|
||||||
if not dialog.citizen or not dialog.price then return end
|
if not dialog.citizen or not dialog.price then return end
|
||||||
TriggerServerEvent('jim-payments:server:Charge', dialog.citizen, dialog.price, dialog.billtype)
|
TriggerServerEvent('jim-payments:server:Charge', dialog.citizen, dialog.price, dialog.billtype, data.img)
|
||||||
end
|
end
|
||||||
end)
|
end)
|
||||||
end)
|
end)
|
||||||
|
|
||||||
RegisterNetEvent('jim-payments:Tickets:Menu', function()
|
RegisterNetEvent('jim-payments:Tickets:Menu', function()
|
||||||
local amount = nil
|
local amount = nil
|
||||||
while amount == nil do QBCore.Functions.TriggerCallback('jim-payments:Ticket:Count', function(cb) amount = cb end) Citizen.Wait(1) end
|
local p = promise.new() QBCore.Functions.TriggerCallback('jim-payments:Ticket:Count', function(cb) p:resolve(cb) end) amount = Citizen.Await(p)
|
||||||
for k, v in pairs(Config.Jobs) do if k ~= PlayerJob.name then
|
for k, v in pairs(Config.Jobs) do if k ~= PlayerJob.name then
|
||||||
else exports['qb-menu']:openMenu({
|
else exports['qb-menu']:openMenu({
|
||||||
{ isMenuHeader = true, header = "🧾 "..PlayerJob.label.." Receipts 🧾", txt = "Do you want trade your receipts for payment?" },
|
{ isMenuHeader = true, header = "🧾 "..PlayerJob.label.." Receipts 🧾", txt = "Do you want trade your receipts for payment?" },
|
||||||
{ isMenuHeader = true, header = "", txt = "Amount of Tickets: "..amount.."<br>Total Payment: $"..(Config.Jobs[PlayerJob.name].PayPerTicket * amount) },
|
{ isMenuHeader = true, header = "", txt = "Amount of Tickets: "..amount.."<br>Total Payment: $"..(Config.Jobs[PlayerJob.name].PayPerTicket * amount) },
|
||||||
{ header = "Yes", txt = "", params = { event = "jim-payments:Tickets:Sell:yes" } },
|
{ header = "✅ Yes", txt = "", params = { event = "jim-payments:Tickets:Sell:yes" } },
|
||||||
{ header = "No", txt = "", params = { event = "jim-payments:Tickets:Sell:no" } }, })
|
{ header = "❌ No", txt = "", params = { event = "jim-payments:Tickets:Sell:no" } }, })
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end)
|
end)
|
||||||
|
|
||||||
|
RegisterNetEvent("jim-payments:client:PayPopup", function(amount, biller, billtype, img)
|
||||||
|
if img == nil then img = "" end
|
||||||
|
exports['qb-menu']:openMenu({
|
||||||
|
{ isMenuHeader = true, header = img.."🧾 "..PlayerJob.label.." Payment 🧾", txt = "Do you want accept the payment?" },
|
||||||
|
{ isMenuHeader = true, header = "", txt = billtype:gsub("^%l", string.upper).." Payment: $"..amount },
|
||||||
|
{ header = "✅ Yes", txt = "", params = { isServer = true, event = "jim-payments:server:PayPopup", args = { accept = true, amount = amount, biller = biller, billtype = billtype } } },
|
||||||
|
{ header = "❌ No", txt = "", params = { isServer = true, event = "jim-payments:server:PayPopup", args = { accept = false, amount = amount, biller = biller, billtype = billtype } } }, })
|
||||||
|
end)
|
||||||
|
|
||||||
RegisterNetEvent('jim-payments:Tickets:Sell:yes', function() TriggerServerEvent('jim-payments:Tickets:Sell') end)
|
RegisterNetEvent('jim-payments:Tickets:Sell:yes', function() TriggerServerEvent('jim-payments:Tickets:Sell') end)
|
||||||
RegisterNetEvent('jim-payments:Tickets:Sell:no', function() exports['qb-menu']:closeMenu() end)
|
RegisterNetEvent('jim-payments:Tickets:Sell:no', function() exports['qb-menu']:closeMenu() end)
|
||||||
41
config.lua
41
config.lua
@@ -1,4 +1,4 @@
|
|||||||
print("Jim-Payments v2 - Payments Script by Jimathy")
|
print("Jim-Payments v2.2 - Payments Script by Jimathy")
|
||||||
|
|
||||||
-- If you need support I now have a discord available, it helps me keep track of issues and give better support.
|
-- If you need support I now have a discord available, it helps me keep track of issues and give better support.
|
||||||
|
|
||||||
@@ -6,17 +6,36 @@ print("Jim-Payments v2 - Payments Script by Jimathy")
|
|||||||
|
|
||||||
Config = {}
|
Config = {}
|
||||||
|
|
||||||
Config.PaymentRadius = 30 -- This is how far the player list will check
|
Config.TicketSystem = true -- Enable this if you want to use the ticket system
|
||||||
|
|
||||||
|
Config.PaymentRadius = 30 -- This is how far the playerlist will check for nearby players (based on the person charging)
|
||||||
|
|
||||||
|
Config.useATM = true -- Enable this to use my ATM's
|
||||||
|
Config.useBanks = true -- Enable this to use my banking stuff
|
||||||
|
Config.BankBlips = true -- Enable this if you disabled qb-banking and need bank locations
|
||||||
|
Config.ATMBlips = false -- Enable this if you are a pyscho and need every ATM to be on the map too
|
||||||
|
|
||||||
|
Config.PhoneBank = true -- Set this to false to use the popup payment system FOR CARD/BANK PAYMENTS instead of using phone invoices
|
||||||
|
-- This doesn't affect Cash payments as they by default use confirmation now
|
||||||
|
-- This is helpful for phones that don't support invoices well
|
||||||
|
|
||||||
|
Config.Commission = false -- Set this to true to enable Commissions and give the person charging a percentage of the total
|
||||||
|
Config.CommissionAll = false -- Set this to true to give commission to workers clocked in
|
||||||
|
Config.CommissionDouble = false -- Set this to true if you want the person charging to get double Commission
|
||||||
|
Config.CommissionLimit = false -- If true, this limits the Commission to only be given if over the "MinAmountForTicket". If false, Commission will be given for any amount
|
||||||
|
|
||||||
-- MinAmountforTicket should be your cheapest item
|
-- MinAmountforTicket should be your cheapest item
|
||||||
-- PayPerTicket should never be higher than MinAmountforTicket
|
-- PayPerTicket should never be higher than MinAmountforTicket
|
||||||
|
-- Commission is a percentage eg "0.10" becomes 10%
|
||||||
|
|
||||||
Config.Jobs = {
|
Config.Jobs = {
|
||||||
['popsdiner'] = { MinAmountforTicket = 50, PayPerTicket = 50 },
|
['beanmachine'] = { MinAmountforTicket = 50, PayPerTicket = 50, Commission = 0.10, },
|
||||||
['henhouse'] = { MinAmountforTicket = 50, PayPerTicket = 50 },
|
['burgershot'] = { MinAmountforTicket = 50, PayPerTicket = 50 , Commission = 0.10,},
|
||||||
['pizzathis'] = { MinAmountforTicket = 50, PayPerTicket = 50 },
|
['catcafe'] = { MinAmountforTicket = 50, PayPerTicket = 50, Commission = 0.10, },
|
||||||
['burgershot'] = { MinAmountforTicket = 50, PayPerTicket = 50 },
|
['henhouse'] = { MinAmountforTicket = 50, PayPerTicket = 50, Commission = 0.10, },
|
||||||
['catcafe'] = { MinAmountforTicket = 50, PayPerTicket = 50 },
|
['pizzathis'] = { MinAmountforTicket = 50, PayPerTicket = 50, Commission = 0.10, },
|
||||||
['tequilala'] = { MinAmountforTicket = 50, PayPerTicket = 50 },
|
['popsdiner'] = { MinAmountforTicket = 50, PayPerTicket = 50, Commission = 0.10, },
|
||||||
['vanilla'] = { MinAmountforTicket = 50, PayPerTicket = 50 },
|
['tequilala'] = { MinAmountforTicket = 50, PayPerTicket = 50, Commission = 0.10, },
|
||||||
['mechanic'] = { MinAmountforTicket = 1000, PayPerTicket = 500 },
|
['vanilla'] = { MinAmountforTicket = 50, PayPerTicket = 50, Commission = 0.10, },
|
||||||
}
|
['mechanic'] = { MinAmountforTicket = 1000, PayPerTicket = 500, Commission = 0.10, },
|
||||||
|
}
|
||||||
@@ -1,13 +1,14 @@
|
|||||||
name "Jim-Payments"
|
name "Jim-Payments"
|
||||||
author "Jimathy"
|
author "Jimathy"
|
||||||
version "v2"
|
version "v2.2"
|
||||||
description "Payment Script By Jimathy"
|
description "Payment Script By Jimathy"
|
||||||
fx_version "cerulean"
|
fx_version "cerulean"
|
||||||
game "gta5"
|
game "gta5"
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
'qb-input',
|
'qb-input',
|
||||||
'qb-target'
|
'qb-target',
|
||||||
|
'qb-management'
|
||||||
}
|
}
|
||||||
|
|
||||||
client_scripts {
|
client_scripts {
|
||||||
|
|||||||
130
server.lua
130
server.lua
@@ -1,21 +1,62 @@
|
|||||||
local QBCore = exports['qb-core']:GetCoreObject()
|
local QBCore = exports['qb-core']:GetCoreObject()
|
||||||
|
|
||||||
RegisterServerEvent('jim-payments:Tickets:Give')
|
local function cv(amount)
|
||||||
AddEventHandler('jim-payments:Tickets:Give', function(amount, job)
|
local formatted = amount
|
||||||
for k, v in pairs(QBCore.Functions.GetPlayers()) do
|
while true do
|
||||||
local Player = QBCore.Functions.GetPlayer(v)
|
formatted, k = string.gsub(formatted, "^(-?%d+)(%d%d%d)", '%1,%2')
|
||||||
if Player ~= nil then
|
if (k==0) then
|
||||||
if Player.PlayerData.job.name == job and Player.PlayerData.job.onduty then
|
break
|
||||||
if amount >= Config.Jobs[job].MinAmountforTicket then
|
|
||||||
Player.Functions.AddItem('payticket', 1, false, {["quality"] = nil})
|
|
||||||
TriggerClientEvent('QBCore:Notify', Player.PlayerData.source, 'Receipt received', 'success')
|
|
||||||
TriggerClientEvent('inventory:client:ItemBox', Player.PlayerData.source, QBCore.Shared.Items['payticket'], "add", 1)
|
|
||||||
elseif amount < Config.Jobs[job].MinAmountforTicket then
|
|
||||||
TriggerClientEvent("QBCore:Notify", Player.PlayerData.source, "Amount too low, didn't receive a receipt", "error")
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
return formatted
|
||||||
|
end
|
||||||
|
|
||||||
|
--QBCore.Commands.Add("cashregister", "Use mobile cash register", {}, false, function(source) TriggerClientEvent("jim-payments:client:Charge", source, true) end)
|
||||||
|
|
||||||
|
RegisterServerEvent('jim-payments:Tickets:Give', function(data, biller)
|
||||||
|
--Find the biller from their citizenid
|
||||||
|
if biller == nil then
|
||||||
|
for k, v in pairs(QBCore.Functions.GetPlayers()) do
|
||||||
|
local Player = QBCore.Functions.GetPlayer(v)
|
||||||
|
if Player.PlayerData.citizenid == data.senderCitizenId then biller = Player end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
if Config.TicketSystem then
|
||||||
|
if data.amount >= Config.Jobs[data.society].MinAmountforTicket then
|
||||||
|
for k, v in pairs(QBCore.Functions.GetPlayers()) do
|
||||||
|
local Player = QBCore.Functions.GetPlayer(v)
|
||||||
|
if Player ~= nil then
|
||||||
|
if Player.PlayerData.job.name == data.society and Player.PlayerData.job.onduty then
|
||||||
|
Player.Functions.AddItem('payticket', 1, false, {["quality"] = nil})
|
||||||
|
TriggerClientEvent('QBCore:Notify', Player.PlayerData.source, 'Receipt received', 'success')
|
||||||
|
TriggerClientEvent('inventory:client:ItemBox', Player.PlayerData.source, QBCore.Shared.Items['payticket'], "add", 1)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
-- Commission section, does each config option separately
|
||||||
|
local comm = tonumber(Config.Jobs[data.society].Commission)
|
||||||
|
if Config.Commission and comm ~= 0 then
|
||||||
|
if Config.CommissionLimit and data.amount < Config.Jobs[data.society].MinAmountforTicket then return end
|
||||||
|
if Config.CommissionDouble then
|
||||||
|
biller.Functions.AddMoney("bank", math.floor(tonumber(data.amount) * (comm *2)))
|
||||||
|
TriggerClientEvent("QBCore:Notify", biller.PlayerData.source, "Recieved $"..math.floor(tonumber(data.amount) * (comm *2)).." in Commission", "success")
|
||||||
|
else biller.Functions.AddMoney("bank", math.floor(tonumber(data.amount) *comm))
|
||||||
|
TriggerClientEvent("QBCore:Notify", biller.PlayerData.source, "Recieved $"..math.floor(tonumber(data.amount) * comm).." in Commission", "success")
|
||||||
|
end
|
||||||
|
if Config.CommissionAll then
|
||||||
|
for k, v in pairs(QBCore.Functions.GetPlayers()) do
|
||||||
|
local Player = QBCore.Functions.GetPlayer(v)
|
||||||
|
if Player ~= nil and Player ~= biller then
|
||||||
|
if Player.PlayerData.job.name == data.society and Player.PlayerData.job.onduty then
|
||||||
|
Player.Functions.AddMoney("bank", math.floor(tonumber(data.amount) * comm))
|
||||||
|
TriggerClientEvent("QBCore:Notify", Player.PlayerData.source, "Recieved $"..math.floor(tonumber(data.amount) * comm).." in Commission", "success")
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
end)
|
end)
|
||||||
|
|
||||||
RegisterServerEvent('jim-payments:Tickets:Sell', function()
|
RegisterServerEvent('jim-payments:Tickets:Sell', function()
|
||||||
@@ -27,7 +68,7 @@ RegisterServerEvent('jim-payments:Tickets:Sell', function()
|
|||||||
pay = (tickets * Config.Jobs[Player.PlayerData.job.name].PayPerTicket)
|
pay = (tickets * Config.Jobs[Player.PlayerData.job.name].PayPerTicket)
|
||||||
Player.Functions.AddMoney('bank', pay, 'ticket-payment')
|
Player.Functions.AddMoney('bank', pay, 'ticket-payment')
|
||||||
TriggerClientEvent('inventory:client:ItemBox', source, QBCore.Shared.Items['payticket'], "remove", tickets)
|
TriggerClientEvent('inventory:client:ItemBox', source, QBCore.Shared.Items['payticket'], "remove", tickets)
|
||||||
TriggerClientEvent('QBCore:Notify', source, "Tickets traded: "..tickets.." Total: $"..pay, 'success')
|
TriggerClientEvent('QBCore:Notify', source, "Tickets traded: "..tickets.." Total: $"..cv(pay), 'success')
|
||||||
end
|
end
|
||||||
end)
|
end)
|
||||||
|
|
||||||
@@ -37,33 +78,52 @@ QBCore.Functions.CreateCallback('jim-payments:Ticket:Count', function(source, cb
|
|||||||
cb(amount)
|
cb(amount)
|
||||||
end)
|
end)
|
||||||
|
|
||||||
RegisterServerEvent("jim-payments:server:Charge", function(citizen, price, billtype)
|
RegisterServerEvent("jim-payments:server:Charge", function(citizen, price, billtype, img)
|
||||||
local biller = QBCore.Functions.GetPlayer(source)
|
local src = source
|
||||||
|
local biller = QBCore.Functions.GetPlayer(src)
|
||||||
local billed = QBCore.Functions.GetPlayer(tonumber(citizen))
|
local billed = QBCore.Functions.GetPlayer(tonumber(citizen))
|
||||||
local amount = tonumber(price)
|
local amount = tonumber(price)
|
||||||
local billtype = string.lower(tostring(billtype))
|
local balance = billed.Functions.GetMoney(billtype)
|
||||||
|
|
||||||
if amount and amount > 0 then
|
if amount and amount > 0 then
|
||||||
if billtype == "cash" then balance = billed.Functions.GetMoney(billtype)
|
if balance < amount then
|
||||||
if balance >= amount then
|
TriggerClientEvent("QBCore:Notify", src, "Customer doesn't have enough cash to pay", "error")
|
||||||
billed.Functions.RemoveMoney('cash', amount) TriggerEvent("qb-bossmenu:server:addAccountMoney", tostring(biller.PlayerData.job.name), amount)
|
TriggerClientEvent("QBCore:Notify", tonumber(citizen), "You don't have enough cash to pay", "error")
|
||||||
TriggerEvent('jim-payments:Tickets:Give', amount, tostring(biller.PlayerData.job.name))
|
return
|
||||||
elseif balance < amount then
|
end
|
||||||
TriggerClientEvent("QBCore:Notify", source, "Customer doesn't have enough cash to pay", "error")
|
if billtype == "cash" then
|
||||||
TriggerClientEvent("QBCore:Notify", tonumber(citizen), "You don't have enough cash to pay", "error")
|
TriggerClientEvent("jim-payments:client:PayPopup", billed.PlayerData.source, amount, src, billtype, img)
|
||||||
|
elseif billtype == "bank" then
|
||||||
|
if Config.PhoneBank == false then
|
||||||
|
TriggerClientEvent("jim-payments:client:PayPopup", billed.PlayerData.source, amount, src, billtype, img)
|
||||||
|
else
|
||||||
|
MySQL.Async.insert(
|
||||||
|
'INSERT INTO phone_invoices (citizenid, amount, society, sender, sendercitizenid) VALUES (?, ?, ?, ?, ?)',
|
||||||
|
{billed.PlayerData.citizenid, amount, biller.PlayerData.job.name, biller.PlayerData.charinfo.firstname, biller.PlayerData.citizenid})
|
||||||
|
TriggerClientEvent('qb-phone:RefreshPhone', billed.PlayerData.source)
|
||||||
|
TriggerClientEvent('QBCore:Notify', src, 'Invoice Successfully Sent', 'success')
|
||||||
|
TriggerClientEvent('QBCore:Notify', billed.PlayerData.source, 'New Invoice Received')
|
||||||
end
|
end
|
||||||
elseif billtype == "card" then
|
|
||||||
MySQL.Async.insert(
|
|
||||||
'INSERT INTO phone_invoices (citizenid, amount, society, sender, sendercitizenid) VALUES (?, ?, ?, ?, ?)',
|
|
||||||
{billed.PlayerData.citizenid, amount, biller.PlayerData.job.name,
|
|
||||||
biller.PlayerData.charinfo.firstname, biller.PlayerData.citizenid})
|
|
||||||
TriggerClientEvent('qb-phone:RefreshPhone', billed.PlayerData.source)
|
|
||||||
TriggerClientEvent('QBCore:Notify', source, 'Invoice Successfully Sent', 'success')
|
|
||||||
TriggerClientEvent('QBCore:Notify', billed.PlayerData.source, 'New Invoice Received')
|
|
||||||
end
|
end
|
||||||
else TriggerClientEvent('QBCore:Notify', source, "You can't charge $0", 'error') return end
|
else TriggerClientEvent('QBCore:Notify', source, "You can't charge $0", 'error') return end
|
||||||
end)
|
end)
|
||||||
|
|
||||||
|
RegisterServerEvent("jim-payments:server:PayPopup", function(data)
|
||||||
|
local src = source
|
||||||
|
local billed = QBCore.Functions.GetPlayer(src)
|
||||||
|
local biller = QBCore.Functions.GetPlayer(tonumber(data.biller))
|
||||||
|
local newdata = { senderCitizenId = biller.PlayerData.citizenid, society = biller.PlayerData.job.name, amount = data.amount }
|
||||||
|
if data.accept == true then
|
||||||
|
billed.Functions.RemoveMoney(tostring(data.billtype), data.amount)
|
||||||
|
exports["qb-management"]:AddMoney(tostring(biller.PlayerData.job.name), data.amount)
|
||||||
|
--TriggerEvent("qb-bossmenu:server:addAccountMoney", tostring(biller.PlayerData.job.name), data.amount)
|
||||||
|
TriggerEvent('jim-payments:Tickets:Give', newdata, biller)
|
||||||
|
TriggerClientEvent("QBCore:Notify", data.biller, billed.PlayerData.charinfo.firstname.." accepted the payment", "success")
|
||||||
|
elseif data.accept == false then
|
||||||
|
TriggerClientEvent("QBCore:Notify", src, "You declined the payment")
|
||||||
|
TriggerClientEvent("QBCore:Notify", data.biller, billed.PlayerData.charinfo.firstname.." declined the payment", "error")
|
||||||
|
end
|
||||||
|
end)
|
||||||
|
|
||||||
QBCore.Functions.CreateCallback('jim-payments:MakePlayerList', function(source, cb)
|
QBCore.Functions.CreateCallback('jim-payments:MakePlayerList', function(source, cb)
|
||||||
local onlineList = {}
|
local onlineList = {}
|
||||||
for k, v in pairs(QBCore.Functions.GetPlayers()) do
|
for k, v in pairs(QBCore.Functions.GetPlayers()) do
|
||||||
@@ -71,4 +131,4 @@ QBCore.Functions.CreateCallback('jim-payments:MakePlayerList', function(source,
|
|||||||
onlineList[#onlineList+1] = { value = tonumber(v), text = "["..v.."] - "..P.PlayerData.charinfo.firstname..' '..P.PlayerData.charinfo.lastname }
|
onlineList[#onlineList+1] = { value = tonumber(v), text = "["..v.."] - "..P.PlayerData.charinfo.firstname..' '..P.PlayerData.charinfo.lastname }
|
||||||
end
|
end
|
||||||
cb(onlineList)
|
cb(onlineList)
|
||||||
end)
|
end)
|
||||||
Reference in New Issue
Block a user