mirror of
https://github.com/jimathy/jim-payments.git
synced 2026-08-17 06:16:02 +01:00
Compare commits
31 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
9601e4b2ac | ||
|
|
ef5775fd6d | ||
|
|
a5e09e4c49 | ||
|
|
3e9570607a | ||
|
|
5de2f99693 | ||
|
|
24ea006d60 | ||
|
|
8fcea104da | ||
|
|
00367122bf | ||
|
|
683f017029 | ||
|
|
ce90bd4f26 | ||
|
|
afdbb72ce7 | ||
|
|
cb54fb18fa | ||
|
|
44833e6c71 | ||
|
|
9aee05be46 | ||
|
|
79bfe1c7f9 | ||
|
|
2bdaf89b28 | ||
|
|
487459eda8 | ||
|
|
be931570bb | ||
|
|
e958ae1582 | ||
|
|
d1ea279f4a | ||
|
|
256394bfe3 | ||
|
|
227fbd322c | ||
|
|
4ed398fd9f | ||
|
|
2837a808f1 | ||
|
|
b78c6dc3a9 | ||
|
|
412267a5c8 | ||
|
|
e0321c51c6 | ||
|
|
0ea3f36d42 | ||
|
|
ded2fbb219 | ||
|
|
3722d4b2ba | ||
|
|
63cf7f972d |
10
README.md
10
README.md
@@ -1,8 +1,14 @@
|
||||
# jim-payments
|
||||
QBCore based payment system
|
||||
|
||||
|
||||
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
|
||||
|
||||
 
|
||||
|
||||
# Installation
|
||||
|
||||
To make use of this payment system you need trigger the event
|
||||
@@ -39,3 +45,7 @@ Go to [qb] > qb-phone > client > main.lua
|
||||
- Add this line:
|
||||
|
||||
```TriggerServerEvent('jim-payments:Tickets:Give', amount, society)```
|
||||
|
||||
--------------
|
||||
|
||||
NOTE: If you are converting from my older job scripts, I recommend removing the previous triggers from qb-phone
|
||||
|
||||
379
atms.lua
Normal file
379
atms.lua
Normal file
@@ -0,0 +1,379 @@
|
||||
local QBCore = exports['qb-core']:GetCoreObject()
|
||||
|
||||
-- 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
|
||||
-- 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.ATMLocations = {
|
||||
--PACIFIC BANK 10 ATMS
|
||||
vector3(265.9, 213.86, 106.28),
|
||||
vector3(265.56, 212.98, 106.28),
|
||||
vector3(265.19, 211.91, 106.28),
|
||||
vector3(264.86, 211.03, 106.28),
|
||||
vector3(264.52, 210.06, 106.28),
|
||||
vector3(236.64, 219.72, 106.29),
|
||||
vector3(237.04, 218.72, 106.29),
|
||||
vector3(237.5, 217.87, 106.29),
|
||||
vector3(237.93, 216.94, 106.29),
|
||||
vector3(238.36, 216.03, 106.29),
|
||||
|
||||
--WALL ATMS
|
||||
vector3(-386.54, 6046.29, 31.5),
|
||||
vector3(-282.82, 6226.24, 31.49),
|
||||
vector3(-132.74, 6366.79, 31.48),
|
||||
vector3(-95.76, 6457.41, 31.46),
|
||||
vector3(-97.52, 6455.65, 31.47),
|
||||
vector3(155.95, 6642.99, 31.6),
|
||||
vector3(173.92, 6638.16, 31.57),
|
||||
vector3(2558.65, 350.92, 108.62),
|
||||
vector3(1077.78, -776.64, 58.35),
|
||||
vector3(1138.14, -468.88, 66.73),
|
||||
vector3(1166.93, -455.96, 66.81),
|
||||
vector3(285.37, 143.07, 104.17),
|
||||
vector3(-165.43, 234.81, 94.92),
|
||||
vector3(-165.4, 232.73, 94.92),
|
||||
vector3(-1410.41, -98.76, 52.43),
|
||||
vector3(-1409.85, -100.51, 52.38),
|
||||
vector3(-1206.0, -324.94, 37.86),
|
||||
vector3(-1205.23, -326.55, 37.86),
|
||||
vector3(-2072.28, -317.27, 13.32),
|
||||
vector3(-2974.7, 380.15, 15.0),
|
||||
vector3(-2959.01, 487.45, 15.46),
|
||||
vector3(-2956.87, 487.36, 15.46),
|
||||
vector3(-3043.98, 594.32, 7.74),
|
||||
vector3(-3241.35, 997.74, 12.55),
|
||||
vector3(-1305.59, -706.64, 25.32),
|
||||
vector3(-537.85, -854.69, 29.28),
|
||||
vector3(-709.98, -818.71, 23.73),
|
||||
vector3(-712.87, -818.71, 23.73),
|
||||
vector3(-526.71, -1223.18, 18.45),
|
||||
vector3(-256.47, -715.94, 33.55),
|
||||
vector3(-259.13, -723.29, 33.54),
|
||||
vector3(-203.82, -861.3, 30.27),
|
||||
vector3(111.38, -774.96, 31.44),
|
||||
vector3(114.56, -776.13, 31.42),
|
||||
vector3(112.46, -819.65, 31.34),
|
||||
vector3(118.93, -883.68, 31.12),
|
||||
vector3(-846.97, -340.29, 38.68),
|
||||
vector3(-846.41, -341.41, 38.68),
|
||||
vector3(-262.21, -2012.17, 30.15),
|
||||
vector3(-273.23, -2024.32, 30.15),
|
||||
vector3(24.46, -945.94, 29.36),
|
||||
vector3(-254.48, -692.74, 33.61),
|
||||
vector3(-1569.95, -546.94, 34.96),
|
||||
vector3(-1570.91, -547.63, 34.96),
|
||||
vector3(289.14, -1282.29, 29.6),
|
||||
vector3(289.18, -1256.84, 29.44),
|
||||
vector3(296.04, -896.22, 29.24),
|
||||
vector3(296.74, -894.26, 29.24),
|
||||
vector3(-301.63, -829.73, 32.43),
|
||||
vector3(-303.23, -829.44, 32.43),
|
||||
vector3(5.27, -919.87, 29.56),
|
||||
vector3(-1200.61, -885.62, 13.26),
|
||||
}
|
||||
|
||||
Config.BankLocations = {
|
||||
vector3(149.9, -1040.46, 29.37),
|
||||
vector3(314.23, -278.83, 54.17),
|
||||
vector3(-350.8, -49.57, 49.04),
|
||||
vector3(-1213.0, -330.39, 37.79),
|
||||
vector3(-2962.71, 483.0, 15.7),
|
||||
vector3(1175.07, 2706.41, 38.09),
|
||||
vector3(247.44, 223.22, 106.29),
|
||||
vector3(-113.22, 6470.03, 31.63),
|
||||
vector3(242.25, 225.15, 106.29)
|
||||
--vector3(252.41, 221.41, 106.29)
|
||||
}
|
||||
|
||||
|
||||
local function cv(amount)
|
||||
local formatted = amount
|
||||
while true do
|
||||
formatted, k = string.gsub(formatted, "^(-?%d+)(%d%d%d)", '%1,%2')
|
||||
if (k==0) then
|
||||
break
|
||||
end
|
||||
end
|
||||
return formatted
|
||||
end
|
||||
local function createBlips()
|
||||
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
|
||||
for k, v in pairs(Config.ATMLocations) do
|
||||
blip = AddBlipForCoord(v)
|
||||
SetBlipSprite(blip, 108)
|
||||
SetBlipDisplay(blip, 4)
|
||||
SetBlipScale(blip, 0.55)
|
||||
SetBlipColour(blip, 3)
|
||||
SetBlipAsShortRange(blip, true)
|
||||
BeginTextCommandSetBlipName("STRING")
|
||||
AddTextComponentString("ATM")
|
||||
EndTextCommandSetBlipName(blip)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
AddEventHandler('onResourceStart', function(resource) if GetCurrentResourceName() == resource then createBlips() end end)
|
||||
|
||||
RegisterNetEvent('QBCore:Client:OnPlayerLoaded', function() createBlips() end)
|
||||
|
||||
Citizen.CreateThread(function()
|
||||
local bossroles = {}
|
||||
for k, v in pairs(Config.Jobs) do
|
||||
for l, b in pairs(QBCore.Shared.Jobs[tostring(k)].grades) do
|
||||
if QBCore.Shared.Jobs[tostring(k)].grades[l].isboss == true then
|
||||
if bossroles[tostring(k)] ~= nil then
|
||||
if bossroles[tostring(k)] > tonumber(l) then bossroles[tostring(k)] = tonumber(l) end
|
||||
else bossroles[tostring(k)] = tonumber(l)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
local gangroles = {}
|
||||
for k, v in pairs(QBCore.Shared.Gangs) do
|
||||
for l, b in pairs(QBCore.Shared.Gangs[tostring(k)].grades) do
|
||||
if tostring(k) ~= "none" then
|
||||
if QBCore.Shared.Gangs[tostring(k)].grades[l].isboss == true then
|
||||
if gangroles[tostring(k)] ~= nil then
|
||||
if gangroles[tostring(k)] > tonumber(l) then gangroles[tostring(k)] = tonumber(l) end
|
||||
else gangroles[tostring(k)] = tonumber(l)
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
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, })
|
||||
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, },
|
||||
{ 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 })
|
||||
end
|
||||
end
|
||||
if Config.useBanks then
|
||||
for k,v in pairs(Config.BankLocations) do
|
||||
exports['qb-target']:AddCircleZone("jimbank"..k, vector3(tonumber(v.x), tonumber(v.y), tonumber(v.z)), 2.0, { name="jimbank"..k, debugPoly=false, useZ=true, },
|
||||
{ options = { { event = "jim-payments:Client:ATM:use", icon = "fas fa-piggy-bank", label = "Use Bank", id = "bank" },
|
||||
{ event = "jim-payments:Client:ATM:use", icon = "fas fa-arrow-right-arrow-left", label = "Transfer Money", id = "transfer" },
|
||||
{ event = "jim-payments:Client:ATM:use", icon = "fas fa-money-check-dollar", label = "Access Savings", id = "savings" },
|
||||
|
||||
{ event = "jim-payments:Client:ATM:use", icon = "fas fa-building", label = "Access Society Account", id = "society", job = bossroles },
|
||||
{ event = "jim-payments:Client:ATM:use", icon = "fas fa-arrow-right-arrow-left", label = "Society Money Transfer", id = "societytransfer", job = bossroles },
|
||||
|
||||
{ event = "jim-payments:Client:ATM:use", icon = "fas fa-building", label = "Gang Society Account", id = "gang", gang = gangroles },
|
||||
{ event = "jim-payments:Client:ATM:use", icon = "fas fa-arrow-right-arrow-left", label = "Gang Money Transfer", id = "gangtransfer", gang = gangroles }, }, distance = 2.5 })
|
||||
end
|
||||
end
|
||||
end)
|
||||
|
||||
local function PlayATMAnimation(animation)
|
||||
if animation == 'enter' then RequestAnimDict('amb@prop_human_atm@male@enter')
|
||||
while not HasAnimDictLoaded('amb@prop_human_atm@male@enter') do Wait(1) end
|
||||
if HasAnimDictLoaded('amb@prop_human_atm@male@enter') then TaskPlayAnim(PlayerPedId(), 'amb@prop_human_atm@male@enter', "enter", 1.0,-1.0, 1500, 1, 1, true, true, true) end
|
||||
end
|
||||
if animation == 'exit' then RequestAnimDict('amb@prop_human_atm@male@exit')
|
||||
while not HasAnimDictLoaded('amb@prop_human_atm@male@exit') do Wait(1) end
|
||||
if HasAnimDictLoaded('amb@prop_human_atm@male@exit') then TaskPlayAnim(PlayerPedId(), 'amb@prop_human_atm@male@exit', "exit", 1.0,-1.0, 3000, 1, 1, true, true, true) end
|
||||
end
|
||||
end
|
||||
|
||||
RegisterNetEvent('jim-payments:Client:ATM:use', function(data)
|
||||
--this grabs all the info from names to savings account numbers in the databases
|
||||
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)
|
||||
Citizen.Wait(100)
|
||||
end
|
||||
while society == nil do
|
||||
QBCore.Functions.TriggerCallback('qb-bossmenu:server:GetAccount', function(cb) society = cb end, PlayerJob.name)
|
||||
Citizen.Wait(100)
|
||||
end
|
||||
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 setoptions = {}
|
||||
|
||||
if data.id == "atm" then
|
||||
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 -'
|
||||
setheader = "💵 ATM Banking 💵"
|
||||
setinputs = { { type = 'radio', name = 'billtype', text = setview, options = setoptions },
|
||||
{ type = 'number', isRequired = true, name = 'amount', text = '💵 Amount to transfer' }, }
|
||||
for k, v in pairs(Config.ATMModels) do
|
||||
local playerPed = PlayerPedId()
|
||||
local playerCoords = GetEntityCoords(playerPed, true)
|
||||
local hash = GetHashKey(v)
|
||||
local atm = IsObjectNearPoint(hash, playerCoords.x, playerCoords.y, playerCoords.z, 1.5)
|
||||
if atm then
|
||||
local obj = GetClosestObjectOfType(playerCoords.x, playerCoords.y, playerCoords.z, 1.5, v, false, false, false)
|
||||
local atmCoords = GetEntityCoords(obj, false)
|
||||
TaskTurnPedToFaceEntity(playerPed, obj, 1000)
|
||||
Wait(1000)
|
||||
PlayATMAnimation('enter')
|
||||
QBCore.Functions.Progressbar("accessing_atm", "Accessing ATM", atmbartime, false, true, { disableMovement = false, disableCarMovement = false, disableMouse = false, disableCombat = false, }, {}, {}, {}, function() -- Done
|
||||
end, function()
|
||||
TriggerEvent("QBCore:Notify", "Cancelled!", "error")
|
||||
return
|
||||
end)
|
||||
end
|
||||
end
|
||||
|
||||
elseif data.id == "bank" then
|
||||
setoptions = { { value = "withdraw", text = "Withdrawl" }, { value = "deposit", text = "Deposit" } }
|
||||
setview = "Welcome back, "..name.."<br><br>- Account -<br>"..account.."<br>"..cid.."<br><br>- Balances -<br>🏦Bank - $"..cv(bank).."<br>💵Cash - $"..cv(cash).."<br><br>- Options -"
|
||||
setheader = "🏦 Banking 🏦"
|
||||
setinputs = { { type = 'radio', name = 'billtype', text = setview, options = setoptions },
|
||||
{ type = 'number', isRequired = true, name = 'amount', text = '💵 Amount to transfer' }, }
|
||||
PlayATMAnimation('enter')
|
||||
QBCore.Functions.Progressbar("accessing_atm", "Accessing Bank", atmbartime, false, true, { disableMovement = false, disableCarMovement = false, disableMouse = false, disableCombat = false, }, {}, {}, {}, function() -- Done
|
||||
end, function()
|
||||
TriggerEvent("QBCore:Notify", "Cancelled!", "error")
|
||||
return
|
||||
end)
|
||||
|
||||
elseif data.id == "transfer" then
|
||||
setoptions = { { value = "transfer", text = "Transfer" } }
|
||||
setview = "Welcome back, "..name.."<br><br>- Account -<br>"..account.."<br>"..cid.."<br><br>- Balances -<br>🏦Bank - $"..cv(bank).."<br><br>- Options -"
|
||||
setheader = "🔀 Transfer Services 🔀"
|
||||
setinputs = { { type = 'radio', name = 'billtype', text = setview, options = setoptions },
|
||||
{ type = 'text', isRequired = true, name = 'account', text = '🏦 Account no.' },
|
||||
{ type = 'number', isRequired = true, name = 'amount', text = '💸 Amount to transfer' }, }
|
||||
PlayATMAnimation('enter')
|
||||
QBCore.Functions.Progressbar("accessing_atm", "Accessing Transfers", atmbartime, false, true, { disableMovement = false, disableCarMovement = false, disableMouse = false, disableCombat = false, }, {}, {}, {}, function() -- Done
|
||||
end, function()
|
||||
TriggerEvent("QBCore:Notify", "Cancelled!", "error")
|
||||
return
|
||||
end)
|
||||
|
||||
elseif data.id == "savings" then
|
||||
setoptions = { { value = "withdraw", text = "Withdrawl" }, { value = "deposit", text = "Deposit" } }
|
||||
setview = "Welcome back, "..name.."<br><br>- Account Info -<br>Savings ID: "..aid.."<br>"..cid.."<br><br>- Balances -<br>💰Savings - $"..cv(savbal).."<br>🏦Bank - $"..cv(bank).."<br><br>- Options -"
|
||||
setheader = "💰 Savings 💰"
|
||||
setinputs = { { type = 'radio', name = 'billtype', text = setview, options = setoptions },
|
||||
{ type = 'number', isRequired = true, name = 'amount', text = '💵 Amount to transfer' }, }
|
||||
PlayATMAnimation('enter')
|
||||
QBCore.Functions.Progressbar("accessing_atm", "Accessing Savings", atmbartime, false, true, { disableMovement = false, disableCarMovement = false, disableMouse = false, disableCombat = false, }, {}, {}, {}, function() -- Done
|
||||
end, function()
|
||||
TriggerEvent("QBCore:Notify", "Cancelled!", "error")
|
||||
return
|
||||
end)
|
||||
|
||||
elseif data.id == "society" then
|
||||
setoptions = { { value = "withdraw", text = "Withdrawl" }, { value = "deposit", text = "Deposit" } }
|
||||
setview = "Welcome back, "..name.."<br><br>- Society Account -<br>"..PlayerJob.label.."<br><br>- Balances -<br>🏢"..PlayerJob.label.." - $"..cv(society).."<br>🏦Bank - $"..cv(bank).."<br><br>- Options -"
|
||||
setheader = "🏢 Society Banking 🏢"
|
||||
setinputs = { { type = 'radio', name = 'billtype', text = setview, options = setoptions },
|
||||
{ type = 'number', isRequired = true, name = 'amount', text = '💵 Amount to transfer' }, }
|
||||
PlayATMAnimation('enter')
|
||||
QBCore.Functions.Progressbar("accessing_atm", "Accessing Society Account", atmbartime, false, true, { disableMovement = false, disableCarMovement = false, disableMouse = false, disableCombat = false, }, {}, {}, {}, function() -- Done
|
||||
end, function()
|
||||
TriggerEvent("QBCore:Notify", "Cancelled!", "error")
|
||||
return
|
||||
end)
|
||||
|
||||
elseif data.id == "societytransfer" then
|
||||
setoptions = { { value = "transfer", text = "Transfer" } }
|
||||
setview = "Welcome back, "..name.."<br><br>- Society Account -<br>"..PlayerJob.label.."<br><br>- Balances -<br>🏢"..PlayerJob.label.." - $"..cv(society).."<br><br>- Options -"
|
||||
setheader = "🔀 Transfer Services 🔀"
|
||||
setinputs = { { type = 'radio', name = 'billtype', text = setview, options = setoptions },
|
||||
{ type = 'text', isRequired = true, name = 'account', text = '🏦 Account no.' },
|
||||
{ type = 'number', isRequired = true, name = 'amount', text = '💸 Amount to transfer' }, }
|
||||
PlayATMAnimation('enter')
|
||||
QBCore.Functions.Progressbar("accessing_atm", "Accessing Transfers", atmbartime, false, true, { disableMovement = false, disableCarMovement = false, disableMouse = false, disableCombat = false, }, {}, {}, {}, function() -- Done
|
||||
end, function()
|
||||
TriggerEvent("QBCore:Notify", "Cancelled!", "error")
|
||||
return
|
||||
end)
|
||||
|
||||
elseif data.id == "gang" then
|
||||
setheader = "🏢 Society Banking 🏢"
|
||||
setview = "Welcome back, "..name.."<br><br>- Society Account -<br>"..PlayerGang.label.."<br><br>- Balances -<br>🏢"..PlayerGang.label.." - $"..cv(gsociety).."<br>🏦Bank - $"..cv(bank).."<br><br>- Options -"
|
||||
setoptions = { { value = "withdraw", text = "Withdrawl" }, { value = "deposit", text = "Deposit" } }
|
||||
setinputs = { { type = 'radio', name = 'billtype', text = setview, options = setoptions },
|
||||
{ type = 'number', isRequired = true, name = 'amount', text = '💵 Amount to transfer' }, }
|
||||
PlayATMAnimation('enter')
|
||||
QBCore.Functions.Progressbar("accessing_atm", "Accessing Society Account", atmbartime, false, true, { disableMovement = false, disableCarMovement = false, disableMouse = false, disableCombat = false, }, {}, {}, {}, function() -- Done
|
||||
end, function()
|
||||
TriggerEvent("QBCore:Notify", "Cancelled!", "error")
|
||||
return
|
||||
end)
|
||||
|
||||
elseif data.id == "gangtransfer" then
|
||||
setoptions = { { value = "transfer", text = "Transfer" } }
|
||||
setview = "Welcome back, "..name.."<br><br>- Society Account -<br>"..PlayerGang.label.."<br><br>- Balances -<br>🏢"..PlayerGang.label.." - $"..cv(gsociety).."<br><br>- Options -"
|
||||
setheader = "🔀 Transfer Services 🔀"
|
||||
setinputs = { { type = 'radio', name = 'billtype', text = setview, options = setoptions },
|
||||
{ type = 'text', isRequired = true, name = 'account', text = '🏦 Account no.' },
|
||||
{ type = 'number', isRequired = true, name = 'amount', text = '💸 Amount to transfer' }, }
|
||||
PlayATMAnimation('enter')
|
||||
QBCore.Functions.Progressbar("accessing_atm", "Accessing Transfers", atmbartime, false, true, { disableMovement = false, disableCarMovement = false, disableMouse = false, disableCombat = false, }, {}, {}, {}, function() -- Done
|
||||
end, function()
|
||||
TriggerEvent("QBCore:Notify", "Cancelled!", "error")
|
||||
return
|
||||
end)
|
||||
end
|
||||
|
||||
Wait(atmbartime+500)
|
||||
local dialog = exports['qb-input']:ShowInput({ header = setheader, txt = "test", submitText = "Transfer", inputs = setinputs })
|
||||
if dialog then
|
||||
if not dialog.amount then return end
|
||||
PlayATMAnimation('exit') Citizen.Wait(1000)
|
||||
TriggerServerEvent('jim-payments:server:ATM:use', dialog.amount, dialog.billtype, dialog.account, data.id, society, gsociety)
|
||||
end
|
||||
gsociety, society, name = nil
|
||||
end)
|
||||
|
||||
|
||||
RegisterNetEvent('jim-payments:client:ATM:give', function()
|
||||
local onlineList = {}
|
||||
local nearbyList = {}
|
||||
QBCore.Functions.TriggerCallback('jim-payments:MakePlayerList', function(cb) onlineList = cb if onlineList[1] == nil then Wait(200) end
|
||||
for k, v in pairs(QBCore.Functions.GetPlayersFromCoords(GetEntityCoords(PlayerPedId()), Config.PaymentRadius)) do
|
||||
local dist = #(GetEntityCoords(GetPlayerPed(v)) - GetEntityCoords(PlayerPedId()))
|
||||
for i = 1, #onlineList do
|
||||
if onlineList[i].value == GetPlayerServerId(v) then
|
||||
if v ~= PlayerId() then
|
||||
nearbyList[#nearbyList+1] = { value = onlineList[i].value, text = onlineList[i].text..' ('..math.floor(dist+0.05)..'m)' }
|
||||
end
|
||||
end
|
||||
end
|
||||
dist = nil
|
||||
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 = "Give someone cash", submitText = "Give",
|
||||
inputs = {
|
||||
{ text = " ", name = "citizen", type = "select", options = nearbyList },
|
||||
{ type = 'number', isRequired = true, name = 'price', text = '💵 Amount to Pay' }, }
|
||||
})
|
||||
if dialog then
|
||||
if not dialog.citizen or not dialog.price then return end
|
||||
TriggerServerEvent('jim-payments:server:ATM:give', dialog.citizen, dialog.price)
|
||||
end
|
||||
end)
|
||||
end)
|
||||
242
atmserver.lua
Normal file
242
atmserver.lua
Normal file
@@ -0,0 +1,242 @@
|
||||
local QBCore = exports['qb-core']:GetCoreObject()
|
||||
|
||||
local function cv(amount)
|
||||
local formatted = amount
|
||||
while true do
|
||||
formatted, k = string.gsub(formatted, "^(-?%d+)(%d%d%d)", '%1,%2')
|
||||
if (k==0) then
|
||||
break
|
||||
end
|
||||
end
|
||||
return formatted
|
||||
end
|
||||
|
||||
|
||||
---- BANK STUFF
|
||||
RegisterServerEvent('jim-payments:server:ATM:use', function(amount, billtype, baccount, account, society, gsociety)
|
||||
local src = source
|
||||
local Player = QBCore.Functions.GetPlayer(src)
|
||||
local cashB = Player.Functions.GetMoney("cash")
|
||||
local bankB = Player.Functions.GetMoney("bank")
|
||||
local amount = tonumber(amount)
|
||||
--TriggerClientEvent("QBCore:Notify", src, tostring(account), "error")
|
||||
|
||||
--Simple transfers from bank to wallet --
|
||||
if account == "bank" or account == "atm" then
|
||||
if billtype == "withdraw" then
|
||||
if bankB < amount then TriggerClientEvent("QBCore:Notify", src, "Bank Balance too low", "error")
|
||||
elseif bankB >= tonumber(amount) then
|
||||
TriggerClientEvent("QBCore:Notify", src, "Withdrew $"..cv(amount).." from the bank", "success") -- Don't really need this as phone gets notified when money is withdrawn
|
||||
Player.Functions.RemoveMoney('bank', amount) Wait(1500)
|
||||
Player.Functions.AddMoney('cash', amount)
|
||||
end
|
||||
elseif billtype == "deposit" then
|
||||
if cashB < amount then TriggerClientEvent("QBCore:Notify", src, "Not enough cash", "error")
|
||||
elseif cashB >= amount then
|
||||
Player.Functions.RemoveMoney('cash', amount) Wait(1500)
|
||||
Player.Functions.AddMoney('bank', amount)
|
||||
TriggerClientEvent("QBCore:Notify", src, "Deposited $"..cv(amount).." into the Bank", "success")
|
||||
end
|
||||
end
|
||||
-- Transfers from bank to savings account --
|
||||
elseif account == "savings" then
|
||||
local getSavingsAccount = MySQL.Sync.fetchAll('SELECT * FROM bank_accounts WHERE citizenid = ? AND account_type = ?', { Player.PlayerData.citizenid, 'Savings' })
|
||||
if getSavingsAccount[1] ~= nil then savbal = tonumber(getSavingsAccount[1].amount) aid = getSavingsAccount[1].record_id end
|
||||
|
||||
if billtype == "withdraw" then
|
||||
if savbal >= amount then
|
||||
savbal = savbal - amount
|
||||
Player.Functions.AddMoney('bank', amount)
|
||||
TriggerClientEvent("QBCore:Notify", src, "$"..cv(amount).." Withdrawn from savings into bank account", "success")
|
||||
MySQL.Async.execute('UPDATE bank_accounts SET amount = ? WHERE citizenid = ? AND record_id = ?', { savbal, Player.PlayerData.citizenid, getSavingsAccount[1].record_id }, function(success)
|
||||
if success then return true else return false end
|
||||
end)
|
||||
elseif savbal < amount then
|
||||
TriggerClientEvent("QBCore:Notify", src, "Savings Balance too low", "error")
|
||||
end
|
||||
elseif billtype == "deposit" then
|
||||
if amount < bankB then
|
||||
savbal = savbal + amount
|
||||
Player.Functions.RemoveMoney('bank', amount)
|
||||
TriggerClientEvent("QBCore:Notify", src, "$"..cv(amount).." Deposited from bank account into savings", "success")
|
||||
MySQL.Async.execute('UPDATE bank_accounts SET amount = ? WHERE citizenid = ? AND record_id = ?', { savbal, Player.PlayerData.citizenid, getSavingsAccount[1].record_id }, function(success)
|
||||
if success then return true else return false end
|
||||
end)
|
||||
else TriggerClientEvent("QBCore:Notify", src, "Bank Balance too low", "error")
|
||||
end
|
||||
end
|
||||
--Simple transfers from society account to bank --
|
||||
elseif account == "society" then
|
||||
if billtype == "withdraw" then
|
||||
if tonumber(society) < amount then TriggerClientEvent("QBCore:Notify", src, "Society balance too low", "error")
|
||||
elseif tonumber(society) >= amount then
|
||||
TriggerClientEvent("QBCore:Notify", src, "Withdrew $"..cv(amount).." from the "..Player.PlayerData.job.label.." account", "success")
|
||||
Player.Functions.AddMoney('bank', amount)
|
||||
TriggerEvent("qb-bossmenu:server:removeAccountMoney", tostring(Player.PlayerData.job.name), amount)
|
||||
end
|
||||
elseif billtype == "deposit" then
|
||||
if bankB < amount then TriggerClientEvent("QBCore:Notify", src, "Not enough money in your bank", "error")
|
||||
elseif bankB >= amount then
|
||||
TriggerEvent("qb-bossmenu:server:addAccountMoney", tostring(Player.PlayerData.job.name), amount)
|
||||
Player.Functions.RemoveMoney('bank', amount) Wait(1500)
|
||||
TriggerClientEvent("QBCore:Notify", src, "Deposited $"..cv(amount).." into the "..Player.PlayerData.job.label.." account", "success")
|
||||
end
|
||||
end
|
||||
-- Transfers between players --
|
||||
elseif account == "societytransfer" then
|
||||
local bannedCharacters = {'%','$',';'}
|
||||
local newAmount = tostring(amount)
|
||||
local newiban = tostring(baccount)
|
||||
for k, v in pairs(bannedCharacters) do
|
||||
newAmount = string.gsub(newAmount, '%' .. v, '')
|
||||
newiban = string.gsub(newiban, '%' .. v, '')
|
||||
end
|
||||
baccount = newiban
|
||||
amount = tonumber(newAmount)
|
||||
|
||||
local Player = QBCore.Functions.GetPlayer(src)
|
||||
if (society - amount) >= 0 then
|
||||
local query = '%"account":"' .. baccount .. '"%'
|
||||
local result = exports.oxmysql:executeSync('SELECT * FROM players WHERE charinfo LIKE ?', {query})
|
||||
if result[1] ~= nil then
|
||||
local Reciever = QBCore.Functions.GetPlayerByCitizenId(result[1].citizenid)
|
||||
TriggerEvent("qb-gangmenu:server:removeAccountMoney", tostring(Player.PlayerData.gang.name), amount)
|
||||
if Reciever ~= nil then
|
||||
Reciever.Functions.AddMoney('bank', amount)
|
||||
TriggerClientEvent("QBCore:Notify", src, "Sent $"..amount.." to "..Reciever.PlayerData.charinfo.firstname.." "..Reciever.PlayerData.charinfo.lastname, "success")
|
||||
TriggerClientEvent("QBCore:Notify", Reciever.PlayerData.source, "Recieved $"..cv(amount).." from "..tostring(Player.PlayerData.job.label).." account", "success")
|
||||
else
|
||||
local RecieverMoney = json.decode(result[1].money)
|
||||
RecieverMoney.bank = (RecieverMoney.bank + amount)
|
||||
exports.oxmysql:execute('UPDATE players SET money = ? WHERE citizenid = ?', {json.encode(RecieverMoney), result[1].citizenid})
|
||||
end
|
||||
elseif result[1] == nil then TriggerClientEvent("QBCore:Notify", src, "Error: Account '"..baccount.."' not found", "error")
|
||||
|
||||
end
|
||||
end
|
||||
|
||||
--Simple transfers from society account to bank --
|
||||
elseif account == "gang" then
|
||||
if billtype == "withdraw" then
|
||||
if tonumber(gsociety) < amount then TriggerClientEvent("QBCore:Notify", src, "Society balance too low", "error")
|
||||
elseif tonumber(gsociety) >= amount then
|
||||
TriggerClientEvent("QBCore:Notify", src, "Withdrew $"..cv(amount).." from the "..Player.PlayerData.gang.label.." account", "success")
|
||||
Player.Functions.AddMoney('bank', amount)
|
||||
TriggerEvent("qb-gangmenu:server:removeAccountMoney", tostring(Player.PlayerData.gang.name), amount)
|
||||
end
|
||||
elseif billtype == "deposit" then
|
||||
if bankB < amount then TriggerClientEvent("QBCore:Notify", src, "Not enough money in your bank", "error")
|
||||
elseif bankB >= amount then
|
||||
TriggerEvent("qb-gangmenu:server:addAccountMoney", tostring(Player.PlayerData.gang.name), amount)
|
||||
Player.Functions.RemoveMoney('bank', amount) Wait(1500)
|
||||
TriggerClientEvent("QBCore:Notify", src, "Deposited $"..cv(amount).." into the "..Player.PlayerData.gang.label.." account", "success")
|
||||
end
|
||||
end
|
||||
-- Transfers between players --
|
||||
elseif account == "gangtransfer" then
|
||||
local bannedCharacters = {'%','$',';'}
|
||||
local newAmount = tostring(amount)
|
||||
local newiban = tostring(baccount)
|
||||
for k, v in pairs(bannedCharacters) do
|
||||
newAmount = string.gsub(newAmount, '%' .. v, '')
|
||||
newiban = string.gsub(newiban, '%' .. v, '')
|
||||
end
|
||||
baccount = newiban
|
||||
amount = tonumber(newAmount)
|
||||
|
||||
local Player = QBCore.Functions.GetPlayer(src)
|
||||
if (gsociety - amount) >= 0 then
|
||||
local query = '%"account":"' .. baccount .. '"%'
|
||||
local result = exports.oxmysql:executeSync('SELECT * FROM players WHERE charinfo LIKE ?', {query})
|
||||
if result[1] ~= nil then
|
||||
local Reciever = QBCore.Functions.GetPlayerByCitizenId(result[1].citizenid)
|
||||
TriggerEvent("qb-bossmenu:server:removeAccountMoney", tostring(Player.PlayerData.gang.name), amount)
|
||||
if Reciever ~= nil then
|
||||
Reciever.Functions.AddMoney('bank', amount)
|
||||
TriggerClientEvent("QBCore:Notify", src, "Sent $"..amount.." to "..Reciever.PlayerData.charinfo.firstname.." "..Reciever.PlayerData.charinfo.lastname, "success")
|
||||
TriggerClientEvent("QBCore:Notify", Reciever.PlayerData.source, "Recieved $"..cv(amount).." from "..tostring(Player.PlayerData.gang.label).." account", "success")
|
||||
else
|
||||
local RecieverMoney = json.decode(result[1].money)
|
||||
RecieverMoney.bank = (RecieverMoney.bank + amount)
|
||||
exports.oxmysql:execute('UPDATE players SET money = ? WHERE citizenid = ?', {json.encode(RecieverMoney), result[1].citizenid})
|
||||
end
|
||||
elseif result[1] == nil then TriggerClientEvent("QBCore:Notify", src, "Error: Account '"..baccount.."' not found", "error")
|
||||
|
||||
end
|
||||
end
|
||||
|
||||
elseif account == "transfer" then
|
||||
|
||||
local bannedCharacters = {'%','$',';'}
|
||||
local newAmount = tostring(amount)
|
||||
local newiban = tostring(baccount)
|
||||
for k, v in pairs(bannedCharacters) do
|
||||
newAmount = string.gsub(newAmount, '%' .. v, '')
|
||||
newiban = string.gsub(newiban, '%' .. v, '')
|
||||
end
|
||||
baccount = newiban
|
||||
amount = tonumber(newAmount)
|
||||
|
||||
local Player = QBCore.Functions.GetPlayer(src)
|
||||
if (Player.PlayerData.money.bank - amount) >= 0 then
|
||||
local query = '%"account":"' .. baccount .. '"%'
|
||||
local result = exports.oxmysql:executeSync('SELECT * FROM players WHERE charinfo LIKE ?', {query})
|
||||
if result[1] ~= nil then
|
||||
local Reciever = QBCore.Functions.GetPlayerByCitizenId(result[1].citizenid)
|
||||
Player.Functions.RemoveMoney('bank', amount)
|
||||
if Reciever ~= nil then
|
||||
Reciever.Functions.AddMoney('bank', amount)
|
||||
TriggerClientEvent("QBCore:Notify", src, "Sent $"..cv(amount).." to "..Reciever.PlayerData.charinfo.firstname.." "..Reciever.PlayerData.charinfo.lastname, "success")
|
||||
TriggerClientEvent("QBCore:Notify", Reciever.PlayerData.source, "Recieved $"..cv(amount).." from "..Player.PlayerData.charinfo.firstname.." "..Player.PlayerData.charinfo.lastname, "success")
|
||||
else
|
||||
local RecieverMoney = json.decode(result[1].money)
|
||||
RecieverMoney.bank = (RecieverMoney.bank + amount)
|
||||
exports.oxmysql:execute('UPDATE players SET money = ? WHERE citizenid = ?', {json.encode(RecieverMoney), result[1].citizenid})
|
||||
end
|
||||
elseif result[1] == nil then TriggerClientEvent("QBCore:Notify", src, "Error: Account '"..baccount.."' not found", "error")
|
||||
|
||||
end
|
||||
end
|
||||
end
|
||||
end)
|
||||
|
||||
QBCore.Functions.CreateCallback('jim-payments:ATM:Find', function(source, cb)
|
||||
local Player = QBCore.Functions.GetPlayer(source)
|
||||
local name = Player.PlayerData.charinfo.firstname..' '..Player.PlayerData.charinfo.lastname
|
||||
local cid = Player.PlayerData.citizenid.." ["..source.."]"
|
||||
local cash = Player.Functions.GetMoney("cash")
|
||||
local bank = Player.Functions.GetMoney("bank")
|
||||
local account = Player.PlayerData.charinfo.account
|
||||
|
||||
local getSavingsAccount = MySQL.Sync.fetchAll('SELECT * FROM bank_accounts WHERE citizenid = ? AND account_type = ?', { Player.PlayerData.citizenid, 'Savings' })
|
||||
if getSavingsAccount[1] ~= nil then
|
||||
aid = getSavingsAccount[1].record_id
|
||||
savbal = getSavingsAccount[1].amount
|
||||
else
|
||||
MySQL.Async.insert('INSERT INTO bank_accounts (citizenid, amount, account_type) VALUES (?, ?, ?)', { Player.PlayerData.citizenid, 0, 'Savings' }, function() completed = true end) repeat Wait(0) until completed == true
|
||||
aid = getSavingsAccount[1].record_id
|
||||
savbal = getSavingsAccount[1].amount
|
||||
end
|
||||
|
||||
cb(name, cash, bank, account, cid, savbal, aid)
|
||||
end)
|
||||
|
||||
QBCore.Commands.Add("cashgive", "Pay a user nearby", {}, false, function(source) TriggerClientEvent("jim-payments:client:ATM:give", source) end)
|
||||
|
||||
RegisterServerEvent("jim-payments:server:ATM:give", function(citizen, price)
|
||||
local Player = QBCore.Functions.GetPlayer(source)
|
||||
local Reciever = QBCore.Functions.GetPlayer(tonumber(citizen))
|
||||
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)
|
||||
TriggerClientEvent("QBCore:Notify", source, "You gave "..Reciever.PlayerData.charinfo.firstname.." $"..cv(amount), "success")
|
||||
Reciever.Functions.AddMoney('cash', amount)
|
||||
TriggerClientEvent("QBCore:Notify", tonumber(citizen), "You got $"..cv(amount).." from "..Reciever.PlayerData.charinfo.firstname, "success")
|
||||
elseif balance < amount then
|
||||
TriggerClientEvent("QBCore:Notify", source, "You don't have enough cash to give", "error")
|
||||
end
|
||||
else TriggerClientEvent('QBCore:Notify', source, "You can't give $0", 'error') end
|
||||
end)
|
||||
62
client.lua
62
client.lua
@@ -1,13 +1,13 @@
|
||||
local QBCore = exports['qb-core']:GetCoreObject()
|
||||
|
||||
PlayerJob = {}
|
||||
|
||||
local onDuty = false
|
||||
|
||||
RegisterNetEvent('QBCore:Client:OnPlayerLoaded')
|
||||
AddEventHandler('QBCore:Client:OnPlayerLoaded', function()
|
||||
QBCore.Functions.GetPlayerData(function(PlayerData)
|
||||
PlayerJob = PlayerData.job
|
||||
PlayerGang = PlayerData.gang
|
||||
end)
|
||||
end)
|
||||
|
||||
@@ -22,31 +22,67 @@ 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
|
||||
AddEventHandler('onResourceStart', function(resource) if GetCurrentResourceName() == resource then QBCore.Functions.GetPlayerData(function(PlayerData) PlayerJob = PlayerData.job end) end end)
|
||||
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)
|
||||
|
||||
Citizen.CreateThread(function()
|
||||
local jobroles = {}
|
||||
for k, v in pairs(Config.Jobs) do jobroles[tostring(k)] = 0 end
|
||||
for k, v in pairs(Config.Jobs) do jobroles[tostring(k)] = 0 end
|
||||
exports['qb-target']:AddBoxZone("JimBank", vector3(251.75, 222.17, 106.2), 0.6, 2.0, { name="JimBank", heading = 340.0, debugPoly=false, minZ = 105.75, maxZ = 107.29, },
|
||||
{ options = { { type = 'server', event = "jim-payments:Tickets:Sell", 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)
|
||||
|
||||
RegisterNetEvent('jim-payments:client:Charge', function()
|
||||
if not onDuty then TriggerEvent("QBCore:Notify", "Not Clocked in!", "error") return end -- Require to be on duty when making a payment
|
||||
QBCore.Functions.TriggerCallback('jim-payments:server:GetCurrentPlayers', function(playerList)
|
||||
if playerList[1] == nil then TriggerEvent("QBCore:Notify", "No one near by to charge", "error") return end
|
||||
local dialog = exports['qb-input']:ShowInput({ header = "Charge Customer", submitText = "Send",
|
||||
local onlineList = {}
|
||||
local nearbyList = {}
|
||||
QBCore.Functions.TriggerCallback('jim-payments:MakePlayerList', function(cb) onlineList = cb if onlineList[1] == nil then Wait(200) end
|
||||
for k, v in pairs(QBCore.Functions.GetPlayersFromCoords(GetEntityCoords(PlayerPedId()), Config.PaymentRadius)) do
|
||||
local dist = #(GetEntityCoords(GetPlayerPed(v)) - GetEntityCoords(PlayerPedId()))
|
||||
for i = 1, #onlineList do
|
||||
if onlineList[i].value == GetPlayerServerId(v) then
|
||||
if v ~= PlayerId() then
|
||||
nearbyList[#nearbyList+1] = onlineList[i]
|
||||
nearbyList[#nearbyList].text = nearbyList[#nearbyList].text..' ('..math.floor(dist+0.05)..'m)'
|
||||
end
|
||||
end
|
||||
end
|
||||
dist = nil
|
||||
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",
|
||||
inputs = {
|
||||
{ text = "Citizen", name = "citizen", type = "select", options = playerList },
|
||||
{ type = 'number', isRequired = true, name = 'price', text = 'Amount to Charge' },
|
||||
{ type = 'radio', name = 'billtype', text = 'Payment Type', options = { { value = "cash", text = "Cash" }, { value = "card", text = "Card" } } }, }
|
||||
{ text = " ", name = "citizen", type = "select", options = nearbyList },
|
||||
{ type = 'radio', name = 'billtype', text = 'Payment Type', options = { { value = "cash", text = "Cash" }, { value = "card", text = "Card" } } },
|
||||
{ type = 'number', isRequired = true, name = 'price', text = '💵 Amount to Charge' },}
|
||||
})
|
||||
if dialog then
|
||||
if not dialog.citizen or not dialog.price then return end
|
||||
TriggerServerEvent('jim-payments:server:Charge', dialog.citizen, dialog.price, dialog.billtype)
|
||||
end
|
||||
end)
|
||||
end)
|
||||
end)
|
||||
|
||||
RegisterNetEvent('jim-payments:Tickets:Menu', function()
|
||||
local amount = nil
|
||||
while amount == nil do QBCore.Functions.TriggerCallback('jim-payments:Ticket:Count', function(cb) amount = cb end) Citizen.Wait(1) end
|
||||
for k, v in pairs(Config.Jobs) do if k ~= PlayerJob.name then
|
||||
else exports['qb-menu']:openMenu({
|
||||
{ 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) },
|
||||
{ header = "Yes", txt = "", params = { event = "jim-payments:Tickets:Sell:yes" } },
|
||||
{ header = "No", txt = "", params = { event = "jim-payments:Tickets:Sell:no" } }, })
|
||||
end
|
||||
end
|
||||
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)
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
print("Jim-Payments v1.0 - Payments Script by Jimathy")
|
||||
print("Jim-Payments v2 - 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.
|
||||
|
||||
@@ -8,6 +8,8 @@ Config = {}
|
||||
|
||||
Config.PaymentRadius = 30 -- This is how far the player list will check
|
||||
|
||||
-- MinAmountforTicket should be your cheapest item
|
||||
-- PayPerTicket should never be higher than MinAmountforTicket
|
||||
Config.Jobs = {
|
||||
['popsdiner'] = { MinAmountforTicket = 50, PayPerTicket = 50 },
|
||||
['henhouse'] = { MinAmountforTicket = 50, PayPerTicket = 50 },
|
||||
@@ -17,4 +19,4 @@ Config.Jobs = {
|
||||
['tequilala'] = { MinAmountforTicket = 50, PayPerTicket = 50 },
|
||||
['vanilla'] = { MinAmountforTicket = 50, PayPerTicket = 50 },
|
||||
['mechanic'] = { MinAmountforTicket = 1000, PayPerTicket = 500 },
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,21 +1,24 @@
|
||||
name "Jim-Payments"
|
||||
author "Jimathy"
|
||||
version "v1.0"
|
||||
version "v2"
|
||||
description "Payment Script By Jimathy"
|
||||
fx_version "cerulean"
|
||||
game "gta5"
|
||||
|
||||
dependencies {
|
||||
'qb-input',
|
||||
'qb-target'
|
||||
}
|
||||
|
||||
client_scripts {
|
||||
'client.lua'
|
||||
'client.lua',
|
||||
'atms.lua'
|
||||
}
|
||||
|
||||
server_scripts {
|
||||
'@oxmysql/lib/MySQL.lua',
|
||||
'server.lua'
|
||||
'server.lua',
|
||||
'atmserver.lua'
|
||||
}
|
||||
|
||||
shared_scripts {
|
||||
|
||||
Binary file not shown.
|
Before Width: | Height: | Size: 18 KiB After Width: | Height: | Size: 24 KiB |
52
server.lua
52
server.lua
@@ -18,28 +18,33 @@ AddEventHandler('jim-payments:Tickets:Give', function(amount, job)
|
||||
end
|
||||
end)
|
||||
|
||||
RegisterServerEvent('jim-payments:Tickets:Sell')
|
||||
AddEventHandler('jim-payments:Tickets:Sell', function(data)
|
||||
RegisterServerEvent('jim-payments:Tickets:Sell', function()
|
||||
local Player = QBCore.Functions.GetPlayer(source)
|
||||
if Player.Functions.GetItemByName("payticket") == nil then TriggerClientEvent('QBCore:Notify', source, "No tickets to trade", 'error') return
|
||||
else
|
||||
tickets = Player.Functions.GetItemByName("payticket").amount
|
||||
Player.Functions.RemoveItem('payticket', tickets)
|
||||
Player.Functions.AddMoney('bank', (tickets * Confing.Jobs[Player.PlayerData.job.name].PayPerTicket), 'ticket-payment')
|
||||
pay = (tickets * Config.Jobs[Player.PlayerData.job.name].PayPerTicket)
|
||||
Player.Functions.AddMoney('bank', pay, 'ticket-payment')
|
||||
TriggerClientEvent('inventory:client:ItemBox', source, QBCore.Shared.Items['payticket'], "remove", tickets)
|
||||
TriggerClientEvent('QBCore:Notify', source, "Tickets: "..tickets.." Total: $"..pay, 'success')
|
||||
TriggerClientEvent('QBCore:Notify', source, "Tickets traded: "..tickets.." Total: $"..pay, 'success')
|
||||
end
|
||||
end)
|
||||
|
||||
QBCore.Functions.CreateCallback('jim-payments:Ticket:Count', function(source, cb)
|
||||
if QBCore.Functions.GetPlayer(source).Functions.GetItemByName('payticket') == nil then amount = 0
|
||||
else amount = QBCore.Functions.GetPlayer(source).Functions.GetItemByName('payticket').amount end
|
||||
cb(amount)
|
||||
end)
|
||||
|
||||
RegisterServerEvent("jim-payments:server:Charge", function(citizen, price, billtype)
|
||||
local biller = QBCore.Functions.GetPlayer(source)
|
||||
local billed = QBCore.Functions.GetPlayer(tonumber(citizen))
|
||||
local amount = tonumber(price)
|
||||
local billtype = string.lower(tostring(billtype))
|
||||
|
||||
if billed ~= nil then
|
||||
if amount and amount > 0 then
|
||||
if billtype == "cash" then balance = billed.Functions.GetMoney(billtype)
|
||||
if source == tonumber(citizen) then TriggerClientEvent('QBCore:Notify', source, 'You Cannot Bill Yourself', 'error') return end
|
||||
if balance >= amount then
|
||||
billed.Functions.RemoveMoney('cash', amount) TriggerEvent("qb-bossmenu:server:addAccountMoney", tostring(biller.PlayerData.job.name), amount)
|
||||
TriggerEvent('jim-payments:Tickets:Give', amount, tostring(biller.PlayerData.job.name))
|
||||
@@ -47,30 +52,23 @@ RegisterServerEvent("jim-payments:server:Charge", function(citizen, price, billt
|
||||
TriggerClientEvent("QBCore:Notify", source, "Customer doesn't have enough cash to pay", "error")
|
||||
TriggerClientEvent("QBCore:Notify", tonumber(citizen), "You don't have enough cash to pay", "error")
|
||||
end
|
||||
elseif billtype == "card" then
|
||||
if biller.PlayerData.citizenid == billed.PlayerData.citizenid then TriggerClientEvent('QBCore:Notify', source, 'You Cannot Bill Yourself', 'error') return end
|
||||
if amount and amount > 0 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')
|
||||
else TriggerClientEvent('QBCore:Notify', source, 'Must Be A Valid Amount Above 0', 'error') 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
|
||||
else TriggerClientEvent('QBCore:Notify', source, 'Player Not Online', 'error') end
|
||||
else TriggerClientEvent('QBCore:Notify', source, "You can't charge $0", 'error') return end
|
||||
end)
|
||||
|
||||
QBCore.Functions.CreateCallback('jim-payments:server:GetCurrentPlayers', function(source, cb)
|
||||
QBCore.Functions.CreateCallback('jim-payments:MakePlayerList', function(source, cb)
|
||||
local onlineList = {}
|
||||
local SPlayer = QBCore.Functions.GetPlayer(source)
|
||||
for k, v in pairs(QBCore.Functions.GetPlayers()) do
|
||||
local Player = QBCore.Functions.GetPlayer(v)
|
||||
if Player ~= nil and v ~= source then
|
||||
local dist = #(vector3(Player.PlayerData.position.x, Player.PlayerData.position.y, Player.PlayerData.position.z) - vector3(SPlayer.PlayerData.position.x, SPlayer.PlayerData.position.y, SPlayer.PlayerData.position.z))
|
||||
if dist < Config.PaymentRadius then onlineList[#onlineList+1] = { value = tonumber(v), text = "["..v.."] - "..Player.PlayerData.charinfo.firstname..' '..Player.PlayerData.charinfo.lastname } end
|
||||
end
|
||||
local P = QBCore.Functions.GetPlayer(v)
|
||||
onlineList[#onlineList+1] = { value = tonumber(v), text = "["..v.."] - "..P.PlayerData.charinfo.firstname..' '..P.PlayerData.charinfo.lastname }
|
||||
end
|
||||
cb(onlineList)
|
||||
end)
|
||||
cb(onlineList)
|
||||
end)
|
||||
|
||||
Reference in New Issue
Block a user