19 Commits

Author SHA1 Message Date
Jim Shield
3e9aa9676d Optimize, refactor and tidy 2022-08-22 21:32:15 +01:00
Jim Shield
3117ef68af Fix gks install info 2022-08-03 10:01:38 +01:00
Jim Shield
2c1f1e8573 Small banking changes 2022-07-28 19:35:35 +01:00
Jim Shield
d71f3d29ed Add files via upload 2022-07-28 18:34:17 +01:00
Jim Shield
df640a1a08 I hate github announces 1 letter changes 2022-07-28 18:06:20 +01:00
Jim Shield
8c1a6a11cc ran out of indents 2022-07-28 18:05:13 +01:00
Jim Shield
e2712da4b0 Update README.md 2022-07-28 18:00:45 +01:00
Jim Shield
95eda3b471 Quick rearrange of preview images 2022-07-28 16:00:21 +01:00
Jim Shield
120dae8066 Update README.md 2022-07-28 15:56:57 +01:00
Jim Shield
0990422823 Re-order the config to make more sense 2022-07-28 11:10:00 +01:00
Jim Shield
475ae9f827 typo fix 2022-07-19 14:53:34 +01:00
Jim Shield
9c1953ab92 Custom cash register spawning support built in 2022-07-19 14:52:02 +01:00
Jim Shield
d77d23e635 polcharge fixes 2022-07-16 09:21:12 +01:00
Jim Shield
2a67217155 Hotfix for confirmation polcharge's 2022-07-13 18:28:36 +01:00
Jim Shield
df43549e08 fucking stay false 2022-07-13 18:12:52 +01:00
Jim Shield
91a0cadad7 Polcharge Commission now taken from society charge 2022-07-13 18:09:08 +01:00
Jim Shield
8cf1de1cf9 server print new society balance in debug mode 2022-07-13 17:36:45 +01:00
Jim Shield
b543803194 PolCharge fixes + debug 2022-07-11 19:59:57 +01:00
Jim Shield
da1a19eb2c Config options to recommended defaults 2022-07-05 19:55:40 +01:00
12 changed files with 1464 additions and 243 deletions

208
README.md
View File

@@ -1,89 +1,177 @@
# jim-payments # jim-payments
QBCore based payment system - QBCore based payment system
- Enchanced QB-Input payment system from my other scripts now free on its own
If you think I did a good job here, consider donating as it keeps by lights on and my cat fat: ### If you need support I have a discord server available, it helps me keep track of issues and give better support.
https://ko-fi.com/jixelpatterns ## https://discord.gg/xKgQZ6wZvS
--------------
If you use a different phone/invoice system let me know and I will add support for it as best I can! ### If you think I did a good job here, consider donating as it keeps by lights on and my cat fat/floofy:
## https://ko-fi.com/jixelpatterns
Enchanced QB-Input payment system from my other scripts now free on its own ---
![General](https://i.imgur.com/37d2mE3.jpeg) ![General](https://i.imgur.com/AIdXzxX.jpeg) - If you use a different phone/invoice system let me know and I will add support for it as best I can!
![General](https://i.imgur.com/RYADcI2.jpeg) ![General](https://i.imgur.com/ICbQyeQ.jpeg) - Currently supported are:
- qb-phone
- gks-phone
- qs-smartphone - Leave the setting as "qb"
---
# Installation # Installation
---
To make use of this payment system you need trigger the event - I always recommend starting my scripts AFTER `[qb]` not inside it as it can mess with any dependancies on server load
- I have a separate folder called `[jim]` (that is also in the resources folder) that starts WAY after everything else.
```jim-payments:client:Charge``` - This ensure's it has everything it requires before trying to load
- Example of my load order:
for example with qb-target ```CSS
```lua # QBCore & Extra stuff
exports['qb-target']:AddBoxZone("Receipt", vector3(1589.14, 6458.26, 26.01), 0.6, 0.6, { name="Receipt", heading = 335.0, debugPoly=debugPoly, minZ = 26.01, maxZ = 26.81, }, ensure qb-core
{ options = { { event = "jim-payments:client:Charge", icon = "fas fa-credit-card", label = "Charge Customer", job = "popsdiner" } }, distance = 2.0 }) ensure [qb]
``` ensure [standalone]
It currently requires you to be on duty to charge someone ensure [voice]
ensure [defaultmaps]
This does not need to be added to **MY** job scripts, they already have built in support ensure [vehicles]
#Extra Jim Stuff
-------------- ensure [jim]
To make use of the ticket reward system for workers you need to add the ticket item to your shared items lua:
```lua
["payticket"] = {["name"] = "payticket", ["label"] = "Receipt", ["weight"] = 150, ["type"] = "item", ["image"] = "ticket.png", ["unique"] = false, ["useable"] = false, ["shouldClose"] = false, ["combinable"] = nil, ["description"] = "Cash these in at the bank!"},
``` ```
Add the ticket image to your inventory script ---
## Item installation
- To make use of the ticket reward system for workers you need to add the ticket item to your shared items lua
- Naviage to `[qb] > qb-core / shared / items.lua` and add this line
```lua
["payticket"] = {["name"] = "payticket", ["label"] = "Receipt", ["weight"] = 150, ["type"] = "item", ["image"] = "ticket.png", ["unique"] = false, ["useable"] = false, ["shouldClose"] = false, ["combinable"] = nil, ["description"] = "Cash these in at the bank!"},
```
[qb] > qb-inventory > html > images - Add the ticket image to your inventory script:
- Naviage to `[qb] > qb-inventory > html > images` and add this line
-------------- ![](https://github.com/jimathy/jim-payments/blob/main/images/ticket.png?raw=true)
To get tickets from phone invoices you NEED to add it to the event when a payment is accepted:
For QB-Phone: ---
Go to [qb] > qb-phone > client > main.lua ## Phone Setup
- Around line 645 there should be the PayInvoice NUICallBack - There are two modes in the script, one that uses the phone for invoices/bank charges
- Directly *above* this line: - The script supports many features like pay tickets, commission payments etc.
- If you want to use phone systems for these then you need to add the event for when a payment is accepted:
- REMINDER: IF using phone invoices, the money being added to the society accounts is handled `BY THE PHONE`, not by my script. If money isn't going to the account its the phone system or bossmenu script.
#### QB-Phone:
- Go to `[qb] > qb-phone > client > main.lua`
- Search for the event `RegisterNUICallback('PayInvoice', function(data, cb)` and look for the line:
```lua ```lua
TriggerServerEvent('qb-phone:server:BillingEmail', data, true) TriggerServerEvent('qb-phone:server:BillingEmail', data, true)
``` ```
- Add this line: - Directly *above* this line add:
```lua ```lua
TriggerServerEvent('jim-payments:Tickets:Give', data) TriggerServerEvent('jim-payments:Tickets:Give', data)
``` ```
- The phone should now be integrated with jim-payments
For GKSPhone: #### GKS-Phone:
Go to gks-phone > server > serverapi.lua - Go to `gks-phone > server > serverapi.lua`
- Search for the event: `gksphone:faturapayBill` and search for this line:
- Search for the event: ```gksphone:faturapayBill```
- Under this line:
```lua ```lua
Ply.Functions.RemoveMoney('bank', amount, "paid-invoice") Ply.Functions.RemoveMoney('bank', amount, "paid-invoice")
``` ```
- Add these lines: - Directly under this line add this event:
```lua ```lua
TriggerEvent('jim-payments:Tickets:Give', { sender = Ply.PlayerData.charinfo.firstname, senderCitizenId = data[1].sendercitizenid, society = data[1].society, amount = data[1].amount }) TriggerEvent('jim-payments:Tickets:Give', { sender = Ply.PlayerData.charinfo.firstname, senderCitizenId = data[1].sendercitizenid, society = data[1].society, amount = data[1].amount })
``` ```
- The phone should now be integrated with jim-payments
-------------- ---
# Setup/Config
---
## Custom Locations
The latest banking systems are very simple to use and add, - You can make of this payment system for a job script that wasn't created by me
simply look in the atms.lua and change the config options at the top - All you need to do is add the job, grab a `vector4` (vector3 + heading) and set if you need a to spawn prop or not
- For example:
```lua
CustomCashRegisters = { -- Located in the config.lua
["burgershot"] = { -- Player job role restriction
{ coords = vector4(-1185.5, -878.54, 13.91, 305.53), prop = true, }, -- vector4 to place the till and the way it faces
{ coords = vector4(-1184.34, -880.51, 13.93, 302.04), prop = true, }, -- "prop = true" spawns a prop at the coords
},
},
```
### This does not need to be done for MY job scripts, they already have built in support
---
## PayTickets
![](https://i.imgur.com/ICbQyeQ.jpeg)
- This script has a built in ticket reward system
- On successful sale, the employees will be handed a ticket if they are clocked in
- This can then be handed in to the bank to receive payment
- Works as a reward and incentive for turning up to do work
- The values are set per job in `Config.Jobs`
- `TicketSystem` Enable this if you want to use the ticket system false
- `TicketSystemAll` Enable this to give tickets to all workers clocked in
---
## Commission System
- Support for commission to be paid as a reward for each successful payment
- Very customisable with the config.lua
- `Commission` Choose wether people get commission from every sale
- `CommissionAll` Choose if **EVERY** worker gets Commission that is on duty
- `CommissionDouble` Choose if Commission is limited by `MinAmountForTicket`
- `CommissionLimit` Choose if the worker charging the customer gets double commission
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) ## Multiple Job and Gang Role support
Choose wether to add ATM blips (if you like $ signs) - The script supports adding job roles to the config so they can get rewards for successful payments
- This includes Gang roles for stores/bars owned by a gang allowing them to get ticket rewards and commission
- Examples of adding jobs / gangs to config.lua:
-------------- ```lua
Jobs = {
New Commission system added ['mechanic'] = { MinAmountforTicket = 1000, PayPerTicket = 500, Commission = 0.10, },
['lostmc'] = { MinAmountforTicket = 50, PayPerTicket = 50, Commission = 0.10, gang = true, },
This brings more config options to find tune the script },
```
Choose wether people get commission from every sale - `MinAmountforTicket` is the amount required in a charge before they can get a ticket
Choose if EVERY worker gets Commission that is on duty - `PayPerTicket` is the amount paid per ticket at the bank for the job role
Choose if Commission is limited by MinAmountForTicket - I personally recommend this being lower than `MinAmountforTicket`, being too high makes it exploitable
Choose if the worker charging the customer gets double commission - `Commission` is the amount of commission given to players on successful payments (0.10 = 10%)
- `gang = true` add this if the added role is a gang role
---
## /cashgive
![](https://i.imgur.com/AIdXzxX.jpeg)
- Alternative to /givecash
- A simple command built in to send cash to a `nearby player`
- Shows a list of names and id's of people nearby to select from rather
- Better experience than trying to figure out their ID and entering it manually
---
## /cashregister
![](https://i.imgur.com/37d2mE3.jpeg)
- This command is mean't as a portable cash register alternative
- For example:
- When a person is devliering food they can do `/cashregister` and the payment will still be sent to the society account
- Doesn't utilize the ticket reward system unfortunately
---
## /polcharge
- This script supports a customisable "police billing"
- This is the ability for selected jobroles to charge a nearby player
- Depending on how you've set it up, this can take money directly from the players bank to the job's society account
- This is by default enabled for `police` and `ambulance`
- This also supports giving the player a cut of the payment as `commission`
- Default Config:
```lua
FineJobs = {
['police'] = { Commission = 0.25, },
['ambulance'] = { Commission = 0.25, },
},
FineJobConfirmation = false, -- "true" makes it so fines need confirmation, "false" skips this ands just removes the money
FineJobList = true, -- "true" to use nearby player list feature in the cash registers, "false" for manual id entry
```
---
## Banking
![](https://i.imgur.com/RYADcI2.jpeg)
- This script has simple banking systems built in
- Works as a basic replacement for qb-banking and qb-atms
- Adjust the options in config.lua:
- `useATM` Choose wether to make atm's usable
- `useBanks` Choose wether to make bank desks/teller's usable
- `BankBlips` Enable this if you disabled qb-banking and need bank locations
- `ATMBlips` Enable this if you are a pyscho and need every ATM to be on the map too
- `Gabz` Enable to change to Gabz Bank locations, this corrects the ATM/Bank Cashier + Ticket Cash in
---

141
atms.lua
View File

@@ -21,15 +21,17 @@ local function cv(amount)
return formatted return formatted
end end
local function loadModel(model) if Config.Debug then print("Debug: Loading Model: '"..model.."'") end RequestModel(model) while not HasModelLoaded(model) do Wait(0) end end local function loadModel(model) if not HasModelLoaded(model) then if Config.Debug then print("^5Debug^7: ^2Loading Model^7: '^6"..model.."^7'") end RequestModel(model) while not HasModelLoaded(model) do Wait(0) end end end
local function unloadModel(model) if Config.Debug then print("Debug: Removing Model: '"..model.."'") end SetModelAsNoLongerNeeded(model) end local function unloadModel(model) if Config.Debug then print("^5Debug^7: ^2Removing Model^7: '^6"..model.."^7'") end SetModelAsNoLongerNeeded(model) end
local function loadAnimDict(dict) if Config.Debug then print("^5Debug^7: ^2Loading Anim Dictionary^7: '^6"..dict.."^7'") end while not HasAnimDictLoaded(dict) do RequestAnimDict(dict) Wait(5) end end
local function unloadAnimDict(dict) if Config.Debug then print("^5Debug^7: ^2Removing Anim Dictionary^7: '^6"..dict.."^7'") end RemoveAnimDict(dict) end
local bossroles = {} local bossroles = {}
local gangroles = {} local gangroles = {}
CreateThread(function() CreateThread(function()
if Config.useATM then if Config.useATM then
if Config.ATMBlips then if Config.ATMBlips then
for k, v in pairs(Config.WallATMLocations) do for _, v in pairs(Config.WallATMLocations) do
blip = AddBlipForCoord(v) blip = AddBlipForCoord(v)
SetBlipSprite(blip, 108) SetBlipSprite(blip, 108)
SetBlipDisplay(blip, 4) SetBlipDisplay(blip, 4)
@@ -40,7 +42,7 @@ CreateThread(function()
AddTextComponentString("ATM") AddTextComponentString("ATM")
EndTextCommandSetBlipName(blip) EndTextCommandSetBlipName(blip)
end end
for k, v in pairs(Config.ATMLocations) do for _, v in pairs(Config.ATMLocations) do
blip = AddBlipForCoord(v) blip = AddBlipForCoord(v)
SetBlipSprite(blip, 108) SetBlipSprite(blip, 108)
SetBlipDisplay(blip, 4) SetBlipDisplay(blip, 4)
@@ -55,8 +57,8 @@ CreateThread(function()
end end
if Config.useBanks then if Config.useBanks then
if Config.BankBlips then if Config.BankBlips then
for k,v in pairs(Config.BankLocations) do for _, v in pairs(Config.BankLocations) do
for l, b in pairs(v) do for _, b in pairs(v) do
blip = AddBlipForCoord(b) blip = AddBlipForCoord(b)
SetBlipSprite(blip, 108) SetBlipSprite(blip, 108)
SetBlipDisplay(blip, 4) SetBlipDisplay(blip, 4)
@@ -72,9 +74,9 @@ CreateThread(function()
end end
end end
if Config.useATM or Config.useBanks then if Config.useATM or Config.useBanks then
for k, v in pairs(QBCore.Shared.Jobs) do ---Grabs the list of jobs for k in pairs(QBCore.Shared.Jobs) do ---Grabs the list of jobs
if QBCore.Shared.Jobs[tostring(k)] then if QBCore.Shared.Jobs[tostring(k)] then
for l, b in pairs(QBCore.Shared.Jobs[tostring(k)].grades) do -- Grabs the list of grades for l 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 -- Checks the grade if is boss if QBCore.Shared.Jobs[tostring(k)].grades[l].isboss == true then -- Checks the grade if is boss
if bossroles[tostring(k)] ~= nil then -- checks if the line exists if bossroles[tostring(k)] ~= nil then -- checks if the line exists
if bossroles[tostring(k)] > tonumber(l) then bossroles[tostring(k)] = tonumber(l) end -- the if bossroles[tostring(k)] > tonumber(l) then bossroles[tostring(k)] = tonumber(l) end -- the
@@ -84,9 +86,9 @@ CreateThread(function()
end end
end end
end end
for k, v in pairs(QBCore.Shared.Gangs) do for k in pairs(QBCore.Shared.Gangs) do
if QBCore.Shared.Gangs[tostring(k)] then if QBCore.Shared.Gangs[tostring(k)] then
for l, b in pairs(QBCore.Shared.Gangs[tostring(k)].grades) do for l in pairs(QBCore.Shared.Gangs[tostring(k)].grades) do
if tostring(k) ~= "none" then if tostring(k) ~= "none" then
if QBCore.Shared.Gangs[tostring(k)].grades[l].isboss == true then if QBCore.Shared.Gangs[tostring(k)].grades[l].isboss == true then
if gangroles[tostring(k)] ~= nil then if gangroles[tostring(k)] ~= nil then
@@ -105,14 +107,14 @@ CreateThread(function()
Targets["jimwallatm"..k] = Targets["jimwallatm"..k] =
exports['qb-target']:AddCircleZone("jimwallatm"..k, vector3(tonumber(v.x), tonumber(v.y), tonumber(v.z)+0.2), 0.5, { name="jimwallatm"..k, debugPoly=Config.Debug, useZ=true, }, exports['qb-target']:AddCircleZone("jimwallatm"..k, vector3(tonumber(v.x), tonumber(v.y), tonumber(v.z)+0.2), 0.5, { name="jimwallatm"..k, debugPoly=Config.Debug, 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" }, --{ event = "jim-payments:Client:ATM:use", icon = "fas fa-arrow-right-arrow-left", label = "Transfer Money", id = "transfer" },
}, distance = 1.5 }) }, distance = 1.5 })
end end
for k,v in pairs(Config.ATMLocations) do for k,v in pairs(Config.ATMLocations) do
Targets["jimatm"..k] = Targets["jimatm"..k] =
exports['qb-target']:AddCircleZone("jimatm"..k, vector3(tonumber(v.x), tonumber(v.y), tonumber(v.z)+0.2), 0.5, { name="jimatm"..k, debugPoly=Config.Debug, 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=Config.Debug, 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" }, --{ event = "jim-payments:Client:ATM:use", icon = "fas fa-arrow-right-arrow-left", label = "Transfer Money", id = "transfer" },
}, distance = 1.5 }) }, distance = 1.5 })
end end
end end
@@ -122,20 +124,21 @@ CreateThread(function()
Targets["jimbank"..k..l] = Targets["jimbank"..k..l] =
exports['qb-target']:AddCircleZone("jimbank"..k..l, vector3(tonumber(b.x), tonumber(b.y), tonumber(b.z)+0.2), 2.0, { name="jimbank"..k..l, debugPoly=Config.Debug, useZ=true, }, exports['qb-target']:AddCircleZone("jimbank"..k..l, vector3(tonumber(b.x), tonumber(b.y), tonumber(b.z)+0.2), 2.0, { name="jimbank"..k..l, debugPoly=Config.Debug, useZ=true, },
{ options = { { event = "jim-payments:Client:ATM:use", icon = "fas fa-piggy-bank", label = "Use Bank", id = "bank" }, { 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-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-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-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-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-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 }, }, { event = "jim-payments:Client:ATM:use", icon = "fas fa-arrow-right-arrow-left", label = "Gang Money Transfer", id = "gangtransfer", gang = gangroles }, },
distance = 2.5 }) distance = 2.5 })
if Config.Peds then if Config.Peds then
local i = math.random(1, #Config.PedPool) local i = math.random(1, #Config.PedPool)
loadModel(Config.PedPool[i]) loadModel(Config.PedPool[i])
if not Config.Gabz then CreateModelHide(vector3(tonumber(b.x), tonumber(b.y), tonumber(b.z)), 1.0, `v_corp_bk_chair3`, true) end
if Peds["jimbank"..k..l] == nil then Peds["jimbank"..k..l] = CreatePed(0, Config.PedPool[i], vector3(tonumber(b.x), tonumber(b.y), tonumber(b.z)-1.03), b[4], false, false) end if Peds["jimbank"..k..l] == nil then Peds["jimbank"..k..l] = CreatePed(0, Config.PedPool[i], vector3(tonumber(b.x), tonumber(b.y), tonumber(b.z)-1.03), b[4], false, false) end
if Config.Debug then print("Ped Created - 'jimbank"..k..l.."'") end if Config.Debug then print("^5Debug^7: ^6Ped ^2Created for location^7: '^6"..k..l.."^7'") end
end end
end end
end end
@@ -143,36 +146,28 @@ CreateThread(function()
end) end)
local function PlayATMAnimation(animation) local function PlayATMAnimation(animation)
if animation == 'enter' then RequestAnimDict('amb@prop_human_atm@male@enter') if animation == 'enter' then
while not HasAnimDictLoaded('amb@prop_human_atm@male@enter') do Wait(1) end loadAnimDict('amb@prop_human_atm@male@enter')
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 TaskPlayAnim(PlayerPedId(), 'amb@prop_human_atm@male@enter', "enter", 1.0,-1.0, 1500, 1, 1, true, true, true)
unloadAnimDict('amb@prop_human_atm@male@enter')
end end
if animation == 'exit' then RequestAnimDict('amb@prop_human_atm@male@exit') if animation == 'exit' then
while not HasAnimDictLoaded('amb@prop_human_atm@male@exit') do Wait(1) end loadAnimDict('amb@prop_human_atm@male@exit')
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 TaskPlayAnim(PlayerPedId(), 'amb@prop_human_atm@male@exit', "exit", 1.0,-1.0, 3000, 1, 1, true, true, true)
unloadAnimDict('amb@prop_human_atm@male@enter')
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
local p = promise.new() local p = promise.new()
QBCore.Functions.TriggerCallback('jim-payments:ATM:Find', function(cb) p:resolve(cb) end) local info = Citizen.Await(p) QBCore.Functions.TriggerCallback('jim-payments:ATM:Find', function(cb) p:resolve(cb) end) local info = Citizen.Await(p)
local society local gsociety local cancelled = false local cancelled = false
if Config.Manage then if not Config.Manage then
society = GrabAccount("GetAccount", PlayerJob.name)
Wait(200)
gsociety = GrabAccount("GetGangAccount", PlayerGang.name)
else
local p = promise.new() local p = promise.new()
QBCore.Functions.TriggerCallback('qb-bossmenu:server:GetAccount', function(cb) p:resolve(cb) end, PlayerJob.name) society = Citizen.Await(p) QBCore.Functions.TriggerCallback('qb-bossmenu:server:GetAccount', function(cb) p:resolve(cb) end, PlayerJob.name) info.society = Citizen.Await(p)
local p2 = promise.new() local p2 = promise.new()
QBCore.Functions.TriggerCallback('qb-gangmenu:server:GetAccount', function(cb) p2:resolve(cb) end, PlayerGang.name) gsociety = Citizen.Await(p2) QBCore.Functions.TriggerCallback('qb-gangmenu:server:GetAccount', function(cb) p2:resolve(cb) end, PlayerGang.name) info.gsociety = Citizen.Await(p2)
end end
local atmbartime = 2500 local atmbartime = 2500
local setoptions = {} local setoptions = {}
@@ -181,8 +176,8 @@ RegisterNetEvent('jim-payments:Client:ATM:use', function(data)
setoptions = { { value = "withdraw", text = "Withdrawl" }, } setoptions = { { value = "withdraw", text = "Withdrawl" }, }
setview = "<center><img src=https://static.wikia.nocookie.net/gtawiki/images/b/bd/Fleeca-GTAV-Logo.png width=200px></center><br>Welcome back, "..info.name.."<br><br>- Citizen ID -<br>"..info.cid.."<br><br>- Balances -<br>🏦Bank - $"..cv(info.bank).."<br>💵Cash - $"..cv(info.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, "..info.name.."<br><br>- Citizen ID -<br>"..info.cid.."<br><br>- Balances -<br>🏦Bank - $"..cv(info.bank).."<br>💵Cash - $"..cv(info.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' }, }
for k, v in pairs(Config.ATMModels) do for k, v in pairs(Config.ATMModels) do
local playerPed = PlayerPedId() local playerPed = PlayerPedId()
local playerCoords = GetEntityCoords(playerPed, true) local playerCoords = GetEntityCoords(playerPed, true)
@@ -206,8 +201,8 @@ RegisterNetEvent('jim-payments:Client:ATM:use', function(data)
setoptions = { { value = "withdraw", text = "Withdrawl" }, { value = "deposit", text = "Deposit" } } setoptions = { { value = "withdraw", text = "Withdrawl" }, { value = "deposit", text = "Deposit" } }
setview = "Welcome back, "..info.name.."<br><br>- Account -<br>"..info.account.."<br>"..info.cid.."<br><br>- Balances -<br>🏦Bank - $"..cv(info.bank).."<br>💵Cash - $"..cv(info.cash).."<br><br>- Options -" setview = "Welcome back, "..info.name.."<br><br>- Account -<br>"..info.account.."<br>"..info.cid.."<br><br>- Balances -<br>🏦Bank - $"..cv(info.bank).."<br>💵Cash - $"..cv(info.cash).."<br><br>- Options -"
setheader = "🏦 Banking 🏦" setheader = "🏦 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' }, }
PlayATMAnimation('enter') PlayATMAnimation('enter')
QBCore.Functions.Progressbar("accessing_atm", "Accessing Bank", atmbartime, false, true, { disableMovement = false, disableCarMovement = false, disableMouse = false, disableCombat = false, }, {}, {}, {}, function() -- Done QBCore.Functions.Progressbar("accessing_atm", "Accessing Bank", atmbartime, false, true, { disableMovement = false, disableCarMovement = false, disableMouse = false, disableCombat = false, }, {}, {}, {}, function() -- Done
end, function() end, function()
@@ -219,10 +214,11 @@ RegisterNetEvent('jim-payments:Client:ATM:use', function(data)
setoptions = { { value = "transfer", text = "Transfer" } } setoptions = { { value = "transfer", text = "Transfer" } }
setview = "Welcome back, "..info.name.."<br><br>- Account -<br>"..info.account.."<br>"..info.cid.."<br><br>- Balances -<br>🏦Bank - $"..cv(info.bank).."<br><br>- Options -" setview = "Welcome back, "..info.name.."<br><br>- Account -<br>"..info.account.."<br>"..info.cid.."<br><br>- Balances -<br>🏦Bank - $"..cv(info.bank).."<br><br>- Options -"
setheader = "🔀 Transfer Services 🔀" setheader = "🔀 Transfer Services 🔀"
setinputs = { { type = 'radio', name = 'billtype', text = setview, options = setoptions }, setinputs = { { type = 'radio', name = 'billtype', text = setview, options = setoptions },
{ type = 'text', isRequired = true, name = 'account', text = '🏦 Account no.' }, { type = 'text', isRequired = true, name = 'account', text = '🏦 Account no.' },
{ type = 'number', isRequired = true, name = 'amount', text = '💸 Amount to transfer' }, } { type = 'number', isRequired = true, name = 'amount', text = '💸 Amount to transfer' }, }
PlayATMAnimation('enter') PlayATMAnimation('enter')
QBCore.Functions.Progressbar("accessing_atm", "Accessing Transfers", atmbartime, false, true, { disableMovement = false, disableCarMovement = false, disableMouse = false, disableCombat = false, }, {}, {}, {}, function() -- Done QBCore.Functions.Progressbar("accessing_atm", "Accessing Transfers", atmbartime, false, true, { disableMovement = false, disableCarMovement = false, disableMouse = false, disableCombat = false, }, {}, {}, {}, function() -- Done
end, function() end, function()
TriggerEvent("QBCore:Notify", "Cancelled!", "error") TriggerEvent("QBCore:Notify", "Cancelled!", "error")
@@ -233,9 +229,10 @@ RegisterNetEvent('jim-payments:Client:ATM:use', function(data)
setoptions = { { value = "withdraw", text = "Withdrawl" }, { value = "deposit", text = "Deposit" } } setoptions = { { value = "withdraw", text = "Withdrawl" }, { value = "deposit", text = "Deposit" } }
setview = "Welcome back, "..info.name.."<br><br>- Account Info -<br>Savings ID: "..info.aid.."<br>"..info.cid.."<br><br>- Balances -<br>💰Savings - $"..cv(info.savbal).."<br>🏦Bank - $"..cv(info.bank).."<br><br>- Options -" setview = "Welcome back, "..info.name.."<br><br>- Account Info -<br>Savings ID: "..info.aid.."<br>"..info.cid.."<br><br>- Balances -<br>💰Savings - $"..cv(info.savbal).."<br>🏦Bank - $"..cv(info.bank).."<br><br>- Options -"
setheader = "💰 Savings 💰" setheader = "💰 Savings 💰"
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' }, }
PlayATMAnimation('enter') PlayATMAnimation('enter')
QBCore.Functions.Progressbar("accessing_atm", "Accessing Savings", atmbartime, false, true, { disableMovement = false, disableCarMovement = false, disableMouse = false, disableCombat = false, }, {}, {}, {}, function() -- Done QBCore.Functions.Progressbar("accessing_atm", "Accessing Savings", atmbartime, false, true, { disableMovement = false, disableCarMovement = false, disableMouse = false, disableCombat = false, }, {}, {}, {}, function() -- Done
end, function() end, function()
TriggerEvent("QBCore:Notify", "Cancelled!", "error") TriggerEvent("QBCore:Notify", "Cancelled!", "error")
@@ -244,11 +241,17 @@ RegisterNetEvent('jim-payments:Client:ATM:use', function(data)
elseif data.id == "society" then elseif data.id == "society" then
setoptions = { { value = "withdraw", text = "Withdrawl" }, { value = "deposit", text = "Deposit" } } setoptions = { { value = "withdraw", text = "Withdrawl" }, { value = "deposit", text = "Deposit" } }
setview = "Welcome back, "..info.name.."<br><br>- Society Account -<br>"..PlayerJob.label.."<br><br>- Balances -<br>🏢"..PlayerJob.label.." - $"..cv(society).."<br>🏦Bank - $"..cv(info.bank).."<br><br>- Options -" setview = "Welcome back, "..info.name..
"<br><br>- Society Account -<br>"..
PlayerJob.label..
"<br><br>- Balances -<br>🏢"..
PlayerJob.label.." - $"..cv(info.society)..
"<br>🏦Bank - $"..cv(info.bank)
setheader = "🏢 Society Banking 🏢" setheader = "🏢 Society 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' }, }
PlayATMAnimation('enter') PlayATMAnimation('enter')
QBCore.Functions.Progressbar("accessing_atm", "Accessing Society Account", atmbartime, false, true, { disableMovement = false, disableCarMovement = false, disableMouse = false, disableCombat = false, }, {}, {}, {}, function() -- Done QBCore.Functions.Progressbar("accessing_atm", "Accessing Society Account", atmbartime, false, true, { disableMovement = false, disableCarMovement = false, disableMouse = false, disableCombat = false, }, {}, {}, {}, function() -- Done
end, function() end, function()
TriggerEvent("QBCore:Notify", "Cancelled!", "error") TriggerEvent("QBCore:Notify", "Cancelled!", "error")
@@ -257,11 +260,11 @@ RegisterNetEvent('jim-payments:Client:ATM:use', function(data)
elseif data.id == "societytransfer" then elseif data.id == "societytransfer" then
setoptions = { { value = "transfer", text = "Transfer" } } setoptions = { { value = "transfer", text = "Transfer" } }
setview = "Welcome back, "..info.name.."<br><br>- Society Account -<br>"..PlayerJob.label.."<br><br>- Balances -<br>🏢"..PlayerJob.label.." - $"..cv(society).."<br><br>- Options -" setview = "Welcome back, "..info.name.."<br><br>- Society Account -<br>"..PlayerJob.label.."<br><br>- Balances -<br>🏢"..PlayerJob.label.." - $"..cv(info.society).."<br><br>- Options -"
setheader = "🔀 Transfer Services 🔀" setheader = "🔀 Transfer Services 🔀"
setinputs = { { type = 'radio', name = 'billtype', text = setview, options = setoptions }, setinputs = { { type = 'radio', name = 'billtype', text = setview, options = setoptions },
{ type = 'text', isRequired = true, name = 'account', text = '🏦 Account no.' }, { type = 'text', isRequired = true, name = 'account', text = '🏦 Account no.' },
{ type = 'number', isRequired = true, name = 'amount', text = '💸 Amount to transfer' }, } { type = 'number', isRequired = true, name = 'amount', text = '💸 Amount to transfer' }, }
PlayATMAnimation('enter') PlayATMAnimation('enter')
QBCore.Functions.Progressbar("accessing_atm", "Accessing Transfers", atmbartime, false, true, { disableMovement = false, disableCarMovement = false, disableMouse = false, disableCombat = false, }, {}, {}, {}, function() -- Done QBCore.Functions.Progressbar("accessing_atm", "Accessing Transfers", atmbartime, false, true, { disableMovement = false, disableCarMovement = false, disableMouse = false, disableCombat = false, }, {}, {}, {}, function() -- Done
end, function() end, function()
@@ -271,11 +274,12 @@ RegisterNetEvent('jim-payments:Client:ATM:use', function(data)
elseif data.id == "gang" then elseif data.id == "gang" then
setheader = "🏢 Society Banking 🏢" setheader = "🏢 Society Banking 🏢"
setview = "Welcome back, "..info.name.."<br><br>- Society Account -<br>"..PlayerGang.label.."<br><br>- Balances -<br>🏢"..PlayerGang.label.." - $"..cv(gsociety).."<br>🏦Bank - $"..cv(info.bank).."<br><br>- Options -" setview = "Welcome back, "..info.name.."<br><br>- Society Account -<br>"..PlayerGang.label.."<br><br>- Balances -<br>🏢"..PlayerGang.label.." - $"..cv(info.gsociety).."<br>🏦Bank - $"..cv(info.bank).."<br><br>- Options -"
setoptions = { { value = "withdraw", text = "Withdrawl" }, { value = "deposit", text = "Deposit" } } setoptions = { { value = "withdraw", text = "Withdrawl" }, { value = "deposit", text = "Deposit" } }
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' }, }
PlayATMAnimation('enter') PlayATMAnimation('enter')
QBCore.Functions.Progressbar("accessing_atm", "Accessing Society Account", atmbartime, false, true, { disableMovement = false, disableCarMovement = false, disableMouse = false, disableCombat = false, }, {}, {}, {}, function() -- Done QBCore.Functions.Progressbar("accessing_atm", "Accessing Society Account", atmbartime, false, true, { disableMovement = false, disableCarMovement = false, disableMouse = false, disableCombat = false, }, {}, {}, {}, function() -- Done
end, function() end, function()
TriggerEvent("QBCore:Notify", "Cancelled!", "error") TriggerEvent("QBCore:Notify", "Cancelled!", "error")
@@ -284,12 +288,13 @@ RegisterNetEvent('jim-payments:Client:ATM:use', function(data)
elseif data.id == "gangtransfer" then elseif data.id == "gangtransfer" then
setoptions = { { value = "transfer", text = "Transfer" } } setoptions = { { value = "transfer", text = "Transfer" } }
setview = "Welcome back, "..info.name.."<br><br>- Society Account -<br>"..PlayerGang.label.."<br><br>- Balances -<br>🏢"..PlayerGang.label.." - $"..cv(gsociety).."<br><br>- Options -" setview = "Welcome back, "..info.name.."<br><br>- Society Account -<br>"..PlayerGang.label.."<br><br>- Balances -<br>🏢"..PlayerGang.label.." - $"..cv(info.gsociety).."<br><br>- Options -"
setheader = "🔀 Transfer Services 🔀" setheader = "🔀 Transfer Services 🔀"
setinputs = { { type = 'radio', name = 'billtype', text = setview, options = setoptions }, setinputs = { { type = 'radio', name = 'billtype', text = setview, options = setoptions },
{ type = 'text', isRequired = true, name = 'account', text = '🏦 Account no.' }, { type = 'text', isRequired = true, name = 'account', text = '🏦 Account no.' },
{ type = 'number', isRequired = true, name = 'amount', text = '💸 Amount to transfer' }, } { type = 'number', isRequired = true, name = 'amount', text = '💸 Amount to transfer' }, }
PlayATMAnimation('enter') PlayATMAnimation('enter')
QBCore.Functions.Progressbar("accessing_atm", "Accessing Transfers", atmbartime, false, true, { disableMovement = false, disableCarMovement = false, disableMouse = false, disableCombat = false, }, {}, {}, {}, function() -- Done QBCore.Functions.Progressbar("accessing_atm", "Accessing Transfers", atmbartime, false, true, { disableMovement = false, disableCarMovement = false, disableMouse = false, disableCombat = false, }, {}, {}, {}, function() -- Done
end, function() end, function()
@@ -305,7 +310,7 @@ RegisterNetEvent('jim-payments:Client:ATM:use', function(data)
if dialog then if dialog then
if not dialog.amount then return end if not dialog.amount then return end
PlayATMAnimation('exit') Citizen.Wait(1000) PlayATMAnimation('exit') Citizen.Wait(1000)
TriggerServerEvent('jim-payments:server:ATM:use', dialog.amount, dialog.billtype, dialog.account, data.id, society, gsociety) TriggerServerEvent('jim-payments:server:ATM:use', dialog.amount, dialog.billtype, dialog.account, data.id, info.society, info.gsociety)
end end
end end
end) end)
@@ -315,18 +320,18 @@ RegisterNetEvent('jim-payments:client:ATM:give', function()
local onlineList = {} local onlineList = {}
local nearbyList = {} local nearbyList = {}
QBCore.Functions.TriggerCallback('jim-payments:MakePlayerList', function(cb) onlineList = cb if onlineList[1] == nil then Wait(200) end 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 for _, id in pairs(QBCore.Functions.GetPlayersFromCoords(GetEntityCoords(PlayerPedId()), Config.PaymentRadius)) do
local dist = #(GetEntityCoords(GetPlayerPed(v)) - GetEntityCoords(PlayerPedId())) local dist = #(GetEntityCoords(GetPlayerPed(id)) - GetEntityCoords(PlayerPedId()))
for i = 1, #onlineList do for i = 1, #onlineList do
if onlineList[i].value == GetPlayerServerId(v) then if onlineList[i].value == GetPlayerServerId(id) then
if v ~= PlayerId() then if id ~= PlayerId() or Config.Debug then
nearbyList[#nearbyList+1] = { value = onlineList[i].value, text = onlineList[i].text..' ('..math.floor(dist+0.05)..'m)' } nearbyList[#nearbyList+1] = { value = onlineList[i].value, text = onlineList[i].text..' ('..math.floor(dist+0.05)..'m)' }
end end
end end
end end
dist = nil dist = nil
end end
if nearbyList[#nearbyList] == nil then TriggerEvent("QBCore:Notify", "No one near by to charge", "error") return end if not nearbyList[1] 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", local dialog = exports['qb-input']:ShowInput({ header = "Give someone cash", submitText = "Give",
inputs = { inputs = {
{ text = " ", name = "citizen", type = "select", options = nearbyList }, { text = " ", name = "citizen", type = "select", options = nearbyList },

View File

@@ -11,14 +11,6 @@ local function cv(amount)
return formatted return formatted
end end
---- 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)
@@ -47,7 +39,7 @@ RegisterServerEvent('jim-payments:server:ATM:use', function(amount, billtype, ba
elseif account == "savings" then elseif account == "savings" then
local getSavingsAccount = MySQL.Sync.fetchAll('SELECT * FROM bank_accounts WHERE citizenid = ? AND account_type = ?', { Player.PlayerData.citizenid, 'Savings' }) 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 getSavingsAccount[1] ~= nil then savbal = tonumber(getSavingsAccount[1].amount) aid = getSavingsAccount[1].record_id end
if billtype == "withdraw" then if billtype == "withdraw" then
if savbal >= amount then if savbal >= amount then
savbal = savbal - amount savbal = savbal - amount
@@ -62,7 +54,7 @@ RegisterServerEvent('jim-payments:server:ATM:use', function(amount, billtype, ba
elseif billtype == "deposit" then elseif billtype == "deposit" then
if amount < bankB then if amount < bankB then
savbal = savbal + amount savbal = savbal + amount
Player.Functions.RemoveMoney('bank', amount) Player.Functions.RemoveMoney('bank', amount)
TriggerClientEvent("QBCore:Notify", src, "$"..cv(amount).." Deposited from bank account into savings", "success") 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) 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 if success then return true else return false end
@@ -100,16 +92,16 @@ RegisterServerEvent('jim-payments:server:ATM:use', function(amount, billtype, ba
end end
baccount = newiban baccount = newiban
amount = tonumber(newAmount) amount = tonumber(newAmount)
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 = MySQL.Sync.fetchAll('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] then
local Reciever = QBCore.Functions.GetPlayerByCitizenId(result[1].citizenid) local Reciever = QBCore.Functions.GetPlayerByCitizenId(result[1].citizenid)
if Config.Manage then exports["qb-management"]:RemoveMoney(tostring(Player.PlayerData.job.name), amount) if Config.Manage then exports["qb-management"]:RemoveMoney(tostring(Player.PlayerData.job.name), amount)
else TriggerEvent("qb-bossmenu:server:removeAccountMoney", tostring(Player.PlayerData.job.name), amount) end else TriggerEvent("qb-bossmenu:server:removeAccountMoney", tostring(Player.PlayerData.job.name), amount) end
if Reciever ~= nil then if Reciever 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")
TriggerClientEvent("QBCore:Notify", Reciever.PlayerData.source, "Recieved $"..cv(amount).." from "..tostring(Player.PlayerData.job.label).." account", "success") TriggerClientEvent("QBCore:Notify", Reciever.PlayerData.source, "Recieved $"..cv(amount).." from "..tostring(Player.PlayerData.job.label).." account", "success")
@@ -118,10 +110,10 @@ RegisterServerEvent('jim-payments:server:ATM:use', function(amount, billtype, ba
RecieverMoney.bank = (RecieverMoney.bank + amount) RecieverMoney.bank = (RecieverMoney.bank + amount)
MySQL.Async.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 not result[1] then TriggerClientEvent("QBCore:Notify", src, "Error: Account '"..baccount.."' not found", "error")
end end
end end
--Simple transfers from gang 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
@@ -152,16 +144,16 @@ RegisterServerEvent('jim-payments:server:ATM:use', function(amount, billtype, ba
end end
baccount = newiban baccount = newiban
amount = tonumber(newAmount) amount = tonumber(newAmount)
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 = MySQL.Sync.fetchAll('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] then
local Reciever = QBCore.Functions.GetPlayerByCitizenId(result[1].citizenid) local Reciever = QBCore.Functions.GetPlayerByCitizenId(result[1].citizenid)
if Config.Manage then exports["qb-management"]:RemoveGangMoney(tostring(Player.PlayerData.gang.name), amount) if Config.Manage then exports["qb-management"]:RemoveGangMoney(tostring(Player.PlayerData.gang.name), amount)
else TriggerEvent("qb-bossmenu:server:removeAccountMoney", tostring(Player.PlayerData.gang.name), amount) end else TriggerEvent("qb-bossmenu:server:removeAccountMoney", tostring(Player.PlayerData.gang.name), amount) end
if Reciever ~= nil then if not Reciever 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")
TriggerClientEvent("QBCore:Notify", Reciever.PlayerData.source, "Recieved $"..cv(amount).." from "..tostring(Player.PlayerData.gang.label).." account", "success") TriggerClientEvent("QBCore:Notify", Reciever.PlayerData.source, "Recieved $"..cv(amount).." from "..tostring(Player.PlayerData.gang.label).." account", "success")
@@ -170,13 +162,13 @@ RegisterServerEvent('jim-payments:server:ATM:use', function(amount, billtype, ba
RecieverMoney.bank = (RecieverMoney.bank + amount) RecieverMoney.bank = (RecieverMoney.bank + amount)
MySQL.Async.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 not result[1] then TriggerClientEvent("QBCore:Notify", src, "Error: Account '"..baccount.."' not found", "error")
end end
end end
elseif account == "transfer" then elseif account == "transfer" then
local bannedCharacters = {'%','$',';'} local bannedCharacters = {'%','$',';'}
local newAmount = tostring(amount) local newAmount = tostring(amount)
local newiban = tostring(baccount) local newiban = tostring(baccount)
@@ -186,15 +178,15 @@ RegisterServerEvent('jim-payments:server:ATM:use', function(amount, billtype, ba
end end
baccount = newiban baccount = newiban
amount = tonumber(newAmount) amount = tonumber(newAmount)
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 = MySQL.Sync.fetchAll('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] 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)
if Reciever ~= nil then if Reciever then
Reciever.Functions.AddMoney('bank', amount) 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", 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") TriggerClientEvent("QBCore:Notify", Reciever.PlayerData.source, "Recieved $"..cv(amount).." from "..Player.PlayerData.charinfo.firstname.." "..Player.PlayerData.charinfo.lastname, "success")
@@ -203,11 +195,11 @@ RegisterServerEvent('jim-payments:server:ATM:use', function(amount, billtype, ba
RecieverMoney.bank = (RecieverMoney.bank + amount) RecieverMoney.bank = (RecieverMoney.bank + amount)
MySQL.Async.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 not result[1] then TriggerClientEvent("QBCore:Notify", src, "Error: Account '"..baccount.."' not found", "error")
end end
end end
end end
end) end)
QBCore.Functions.CreateCallback('jim-payments:ATM:Find', function(source, cb) QBCore.Functions.CreateCallback('jim-payments:ATM:Find', function(source, cb)
@@ -217,26 +209,43 @@ QBCore.Functions.CreateCallback('jim-payments:ATM:Find', function(source, cb)
local cash = Player.Functions.GetMoney("cash") local cash = Player.Functions.GetMoney("cash")
local bank = Player.Functions.GetMoney("bank") local bank = Player.Functions.GetMoney("bank")
local account = Player.PlayerData.charinfo.account local account = Player.PlayerData.charinfo.account
local society = 0
local getSavingsAccount = MySQL.Sync.fetchAll('SELECT * FROM bank_accounts WHERE citizenid = ? AND account_type = ?', { Player.PlayerData.citizenid, 'Savings' }) local gsociety = 0
if getSavingsAccount[1] ~= nil then
aid = getSavingsAccount[1].record_id -- If qb-management, grab info directly from database
savbal = getSavingsAccount[1].amount if Config.Manage then
else local result = MySQL.Sync.fetchAll('SELECT * FROM management_funds')
for k, v in pairs(result) do
if Player.PlayerData.job.name == v.job_name then society = v.amount end
end
if Player.PlayerData.gang.name ~= "none" then
for k, v in pairs(result) do
if Player.PlayerData.gang.name == v.job_name then gsociety = v.amount end
end
end
else
end
-- Grab Savings account info
local result = MySQL.Sync.fetchAll('SELECT * FROM bank_accounts WHERE citizenid = ? AND account_type = ?', { Player.PlayerData.citizenid, 'Savings' })
if result[1] then
accountID = result[1].record_id
savingBalance = result[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 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
local getSavingsAccount = MySQL.Sync.fetchAll('SELECT * FROM bank_accounts WHERE citizenid = ? AND account_type = ?', { Player.PlayerData.citizenid, 'Savings' }) local result = MySQL.Sync.fetchAll('SELECT * FROM bank_accounts WHERE citizenid = ? AND account_type = ?', { Player.PlayerData.citizenid, 'Savings' })
aid = getSavingsAccount[1].record_id aid = result[1].record_id
savbal = getSavingsAccount[1].amount savingBalance = result[1].amount
end end
local data = { cb({name = name,
name = name,
cash = cash, cash = cash,
bank = bank, bank = bank,
account = account, account = account,
cid = cid, cid = cid,
savbal = savbal, savbal = savingBalance,
aid = aid } aid = accountID,
cb(data) society = society,
gsociety = gsociety})
end) end)
QBCore.Commands.Add("cashgive", "Pay a user nearby", {}, false, function(source) TriggerClientEvent("jim-payments:client:ATM:give", source) end) QBCore.Commands.Add("cashgive", "Pay a user nearby", {}, false, function(source) TriggerClientEvent("jim-payments:client:ATM:give", source) end)
@@ -246,7 +255,7 @@ RegisterServerEvent("jim-payments:server:ATM:give", function(citizen, price)
local Reciever = QBCore.Functions.GetPlayer(tonumber(citizen)) local Reciever = QBCore.Functions.GetPlayer(tonumber(citizen))
local amount = tonumber(price) local amount = tonumber(price)
local balance = Player.Functions.GetMoney("cash") local balance = Player.Functions.GetMoney("cash")
if amount and amount > 0 then if amount and amount > 0 then
if balance >= amount then if balance >= amount then
Player.Functions.RemoveMoney('cash', amount) Player.Functions.RemoveMoney('cash', amount)

View File

@@ -5,6 +5,8 @@ PlayerGang = {}
local onDuty = false local onDuty = false
local BankPed = nil local BankPed = nil
local Targets = {}
local till = {}
RegisterNetEvent('QBCore:Client:OnPlayerLoaded', function() QBCore.Functions.GetPlayerData(function(PlayerData) PlayerJob = PlayerData.job PlayerGang = PlayerData.gang end) end) RegisterNetEvent('QBCore:Client:OnPlayerLoaded', function() QBCore.Functions.GetPlayerData(function(PlayerData) PlayerJob = PlayerData.job PlayerGang = PlayerData.gang end) end)
RegisterNetEvent('QBCore:Client:OnJobUpdate', function(JobInfo) PlayerJob = JobInfo onDuty = PlayerJob.onduty end) RegisterNetEvent('QBCore:Client:OnJobUpdate', function(JobInfo) PlayerJob = JobInfo onDuty = PlayerJob.onduty end)
@@ -20,14 +22,15 @@ AddEventHandler('onResourceStart', function(resource) if GetCurrentResourceName(
end) end)
end) end)
local function loadModel(model) if Config.Debug then print("Debug: Loading Model: '"..model.."'") end RequestModel(model) while not HasModelLoaded(model) do Wait(0) end end local function loadModel(model) if not HasModelLoaded(model) then if Config.Debug then print("^5Debug^7: ^2Loading Model^7: '^6"..model.."^7'") end RequestModel(model) while not HasModelLoaded(model) do Wait(0) end end end
local function unloadModel(model) if Config.Debug then print("Debug: Removing Model: '"..model.."'") end SetModelAsNoLongerNeeded(model) end local function unloadModel(model) if Config.Debug then print("^5Debug^7: ^2Removing Model^7: '^6"..model.."^7'") end SetModelAsNoLongerNeeded(model) end
CreateThread(function() CreateThread(function()
local jobroles = {} local gangroles = {} local jobroles = {} local gangroles = {}
--Build Job/Gang Checks for cashin location --Build Job/Gang Checks for cashin location
for k, v in pairs(Config.Jobs) do if v.gang then gangroles[tostring(k)] = 0 else jobroles[tostring(k)] = 0 end end for k, v in pairs(Config.Jobs) do if v.gang then gangroles[tostring(k)] = 0 else jobroles[tostring(k)] = 0 end end
--Create Target at location --Create Target at location
Targets["JimBank"] =
exports['qb-target']:AddCircleZone("JimBank", vector3(Config.CashInLocation.x, Config.CashInLocation.y, Config.CashInLocation.z), 2.0, { name="JimBank", debugPoly=Config.Debug, useZ=true, }, exports['qb-target']:AddCircleZone("JimBank", vector3(Config.CashInLocation.x, Config.CashInLocation.y, Config.CashInLocation.z), 2.0, { name="JimBank", debugPoly=Config.Debug, useZ=true, },
{ options = { { options = {
{ event = "jim-payments:Tickets:Menu", icon = "fas fa-receipt", label = "Cash in Job Receipts", job = jobroles, }, { event = "jim-payments:Tickets:Menu", icon = "fas fa-receipt", label = "Cash in Job Receipts", job = jobroles, },
@@ -37,8 +40,26 @@ CreateThread(function()
if Config.Peds then if Config.Peds then
local i = math.random(1, #Config.PedPool) local i = math.random(1, #Config.PedPool)
loadModel(Config.PedPool[i]) loadModel(Config.PedPool[i])
if not Config.Gabz then CreateModelHide(vector3(Config.CashInLocation.x, Config.CashInLocation.y, Config.CashInLocation.z), 1.0, `v_corp_bk_chair3`, true) end
if not BankPed then BankPed = CreatePed(0, Config.PedPool[i], vector3(Config.CashInLocation.x, Config.CashInLocation.y, Config.CashInLocation.z-1), Config.CashInLocation[4], false, false) end if not BankPed then BankPed = CreatePed(0, Config.PedPool[i], vector3(Config.CashInLocation.x, Config.CashInLocation.y, Config.CashInLocation.z-1), Config.CashInLocation[4], false, false) end
if Config.Debug then print("Ped Created for Ticket Trade") end if Config.Debug then print("^5Debug^7: ^6Ped ^2Created for location^7: '^6Ticket Trade^7'") end
end
--Spawn Custom Cash Register Targets
for k, v in pairs(Config.CustomCashRegisters) do
for i = 1, #v do
Targets["CustomRegister: "..k..i] =
exports['qb-target']:AddBoxZone("CustomRegister: "..k..i, v[i].coords, 0.47, 0.34, { name="CustomRegister: "..k..i, heading = v[i].coords[4], debugPoly=Config.Debug, minZ=v[i].coords.z-0.1, maxZ=v[i].coords.z+0.4 },
{ options = { { event = "jim-payments:client:Charge", icon = "fas fa-credit-card", label = "Charge Customer", job = k, img = "" }, },
distance = 2.0
})
if v[i].prop then
loadModel(`prop_till_03`)
till[#till+1] = CreateObject(`prop_till_03`, v[i].coords.x, v[i].coords.y, v[i].coords.z, 0, 0, 0)
SetEntityHeading(till[#till],v[i].coords[4]+180.0)
FreezeEntityPosition(till[#till], true)
end
end
end end
end) end)
@@ -63,7 +84,7 @@ RegisterNetEvent('jim-payments:client:Charge', function(data, outside)
end end
end end
--If list is empty(no one nearby) show error and stop --If list is empty(no one nearby) show error and stop
if not nearbyList[#nearbyList] then TriggerEvent("QBCore:Notify", "No one near by to charge", "error") return end if not nearbyList[1] then TriggerEvent("QBCore:Notify", "No one near by to charge", "error") return end
newinputs[#newinputs+1] = { text = " ", name = "citizen", type = "select", options = nearbyList } newinputs[#newinputs+1] = { text = " ", name = "citizen", type = "select", options = nearbyList }
else -- If Config.List is false, create input text box for ID's else -- If Config.List is false, create input text box for ID's
newinputs[#newinputs+1] = { type = 'text', isRequired = true, name = 'citizen', text = '# Customer ID #' } newinputs[#newinputs+1] = { type = 'text', isRequired = true, name = 'citizen', text = '# Customer ID #' }
@@ -108,7 +129,7 @@ RegisterNetEvent('jim-payments:client:PolCharge', function()
end end
end end
--If list is empty(no one nearby) show error and stop --If list is empty(no one nearby) show error and stop
if not nearbyList[#nearbyList] then TriggerEvent("QBCore:Notify", "No one near by to charge", "error") return end if not nearbyList[1] then TriggerEvent("QBCore:Notify", "No one near by to charge", "error") return end
newinputs[#newinputs+1] = { text = " ", name = "citizen", type = "select", options = nearbyList } newinputs[#newinputs+1] = { text = " ", name = "citizen", type = "select", options = nearbyList }
else -- If Config.List is false, create input text box for ID's else -- If Config.List is false, create input text box for ID's
newinputs[#newinputs+1] = { type = 'text', isRequired = true, name = 'citizen', text = "# Person's ID #" } newinputs[#newinputs+1] = { type = 'text', isRequired = true, name = 'citizen', text = "# Person's ID #" }
@@ -170,5 +191,7 @@ RegisterNetEvent('jim-payments:Tickets:Sell:yes', function() TriggerServerEvent(
RegisterNetEvent('jim-payments:Tickets:Sell:no', function() exports['qb-menu']:closeMenu() end) RegisterNetEvent('jim-payments:Tickets:Sell:no', function() exports['qb-menu']:closeMenu() end)
AddEventHandler('onResourceStop', function(resource) if resource ~= GetCurrentResourceName() then return end AddEventHandler('onResourceStop', function(resource) if resource ~= GetCurrentResourceName() then return end
exports['qb-target']:RemoveZone("JimBank") unloadModel(GetEntityModel(BankPed)) DeletePed(BankPed) for k in pairs(Targets) do exports['qb-target']:RemoveZone(k) end
for i = 1, #till do DeleteEntity(till[i]) end
unloadModel(GetEntityModel(BankPed)) DeletePed(BankPed)
end) end)

264
client/atms.lua Normal file
View File

@@ -0,0 +1,264 @@
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
local Targets = {}
local Peds = {}
local BankLoc = Config.VanBankLocations
local ATMLoc = Config.VanATMLocations
local bossroles = {}
local gangroles = {}
CreateThread(function()
if Config.useATM then
if Config.ATMBlips then
for _, v in pairs(Config.WallATMLocations) do
makeBlip({coords = v, sprite = 108, col = 3, scale = 0.55, disp = 6, name = "ATM" })
end
for _, v in pairs(Config.ATMLocations) do
makeBlip({coords = v, sprite = 108, col = 3, scale = 0.55, disp = 6, name = "ATM" })
end
end
end
if Config.useBanks then
if Config.BankBlips then
for _, v in pairs(Config.BankLocations) do
for _, b in pairs(v) do
makeBlip({coords = b, sprite = 108, col = 2, scale = 0.55, disp = 6, name = "Bank" })
break
end
end
end
end
if Config.useATM or Config.useBanks then
for k in pairs(QBCore.Shared.Jobs) do ---Grabs the list of jobs
if QBCore.Shared.Jobs[tostring(k)] then
for l 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 -- Checks the grade if is boss
if bossroles[tostring(k)] then -- checks if the line exists
if bossroles[tostring(k)] > tonumber(l) then bossroles[tostring(k)] = tonumber(l) end -- the
else bossroles[tostring(k)] = tonumber(l)
end
end
end
end
end
for k in pairs(QBCore.Shared.Gangs) do
if QBCore.Shared.Gangs[tostring(k)] then
for l 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)] 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
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.WallATMLocations) do
Targets["jimwallatm"..k] =
exports['qb-target']:AddCircleZone("jimwallatm"..k, vector3(v.x, v.y, v.z+0.2), 0.5, { name="jimwallatm"..k, debugPoly=Config.Debug, 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
for k,v in pairs(Config.ATMLocations) do
Targets["jimatm"..k] =
exports['qb-target']:AddCircleZone("jimatm"..k, vector3(v.x, v.y, v.z+0.2), 0.5, { name="jimatm"..k, debugPoly=Config.Debug, 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
for l, b in pairs(v) do
Targets["jimbank"..k..l] =
exports['qb-target']:AddCircleZone("jimbank"..k..l, vector3(b.x, b.y, b.z+0.2), 2.0, { name="jimbank"..k..l, debugPoly=Config.Debug, 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 })
if Config.Peds then
local i = math.random(1, #Config.PedPool)
if not Config.Gabz then CreateModelHide(b.xyz, 1.0, `v_corp_bk_chair3`, true) end
if not Peds["jimbank"..k..l] then Peds["jimbank"..k..l] = makePed(Config.PedPool[i], b, false, false) end
end
end
end
end
end)
local function PlayATMAnimation(animation)
if animation == 'enter' then
end
if animation == 'exit' then
loadAnimDict('amb@prop_human_atm@male@exit')
TaskPlayAnim(PlayerPedId(), 'amb@prop_human_atm@male@exit', "exit", 1.0,-1.0, 3000, 1, 1, true, true, true)
unloadAnimDict('amb@prop_human_atm@male@enter')
end
end
RegisterNetEvent('jim-payments:Client:ATM:use', function(data)
--this grabs all the info from names to savings account numbers in the databases
local p = promise.new()
QBCore.Functions.TriggerCallback('jim-payments:ATM:Find', function(cb) p:resolve(cb) end) local info = Citizen.Await(p)
if not Config.Manage then
local p = promise.new()
QBCore.Functions.TriggerCallback('qb-bossmenu:server:GetAccount', function(cb) p:resolve(cb) end, PlayerJob.name) info.society = Citizen.Await(p)
local p2 = promise.new()
QBCore.Functions.TriggerCallback('qb-gangmenu:server:GetAccount', function(cb) p2:resolve(cb) end, PlayerGang.name) info.gsociety = Citizen.Await(p2)
end
local atmbartime = 2500
local bartext = ""
local setoptions = {}
if data.id == "atm" then
setoptions = { { value = "withdraw", text = "Withdrawl" }, }
setview = "<center><img src=https://static.wikia.nocookie.net/gtawiki/images/b/bd/Fleeca-GTAV-Logo.png width=200px></center><br>Welcome back, "..info.name.."<br><br>- Citizen ID -<br>"..info.cid.."<br><br>- Balances -<br>🏦Bank - $"..cv(info.bank).."<br>💵Cash - $"..cv(info.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
if IsObjectNearPoint(v, GetEntityCoords(PlayerPedId()), 1.6) then
local obj = GetClosestObjectOfType(GetEntityCoords(PlayerPedId()), 1.6, v, false, false, false)
local atmCoords = GetEntityCoords(obj)
lookEnt(obj)
bartext = "Accessing ATM"
end
end
elseif data.id == "bank" then
setoptions = { { value = "withdraw", text = "Withdrawl" }, { value = "deposit", text = "Deposit" } }
setview = "Welcome back, "..info.name.."<br><br>- Account -<br>"..info.account.."<br>"..info.cid.."<br><br>- Balances -<br>🏦Bank - $"..cv(info.bank).."<br>💵Cash - $"..cv(info.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' }, }
bartext = "Accessing Bank"
elseif data.id == "transfer" then
setoptions = { { value = "transfer", text = "Transfer" } }
setview = "Welcome back, "..info.name.."<br><br>- Account -<br>"..info.account.."<br>"..info.cid.."<br><br>- Balances -<br>🏦Bank - $"..cv(info.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' }, }
bartext = "Accessing Transfers"
elseif data.id == "savings" then
setoptions = { { value = "withdraw", text = "Withdrawl" }, { value = "deposit", text = "Deposit" } }
setview = "Welcome back, "..info.name.."<br><br>- Account Info -<br>Savings ID: "..info.aid.."<br>"..info.cid.."<br><br>- Balances -<br>💰Savings - $"..cv(info.savbal).."<br>🏦Bank - $"..cv(info.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' }, }
bartext = "Accessing Savings"
elseif data.id == "society" then
setoptions = { { value = "withdraw", text = "Withdrawl" }, { value = "deposit", text = "Deposit" } }
setview = "Welcome back, "..info.name..
"<br><br>- Society Account -<br>"..
PlayerJob.label..
"<br><br>- Balances -<br>🏢"..
PlayerJob.label.." - $"..cv(info.society)..
"<br>🏦Bank - $"..cv(info.bank)
setheader = "🏢 Society Banking 🏢"
setinputs = { { type = 'radio', name = 'billtype', text = setview, options = setoptions },
{ type = 'number', isRequired = true, name = 'amount', text = '💵 Amount to transfer' }, }
bartext = "Accessing Society Account"
elseif data.id == "societytransfer" then
setoptions = { { value = "transfer", text = "Transfer" } }
setview = "Welcome back, "..info.name.."<br><br>- Society Account -<br>"..PlayerJob.label.."<br><br>- Balances -<br>🏢"..PlayerJob.label.." - $"..cv(info.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' }, }
bartext = "Accessing Society Transfers"
elseif data.id == "gang" then
setheader = "🏢 Society Banking 🏢"
setview = "Welcome back, "..info.name.."<br><br>- Society Account -<br>"..PlayerGang.label.."<br><br>- Balances -<br>🏢"..PlayerGang.label.." - $"..cv(info.gsociety).."<br>🏦Bank - $"..cv(info.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' }, }
bartext = "Accessing Gang Society Account"
elseif data.id == "gangtransfer" then
setoptions = { { value = "transfer", text = "Transfer" } }
setview = "Welcome back, "..info.name.."<br><br>- Society Account -<br>"..PlayerGang.label.."<br><br>- Balances -<br>🏢"..PlayerGang.label.." - $"..cv(info.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' }, }
bartext = "Accessing Gang Transfers"
end
loadAnimDict('amb@prop_human_atm@male@enter')
TaskPlayAnim(PlayerPedId(), 'amb@prop_human_atm@male@enter', "enter", 1.0,-1.0, 1500, 1, 1, true, true, true)
unloadAnimDict('amb@prop_human_atm@male@enter')
QBCore.Functions.Progressbar("accessing_atm", bartext, atmbartime, false, true, { disableMovement = false, disableCarMovement = false, disableMouse = false, disableCombat = false, }, {}, {}, {}, function()
local dialog = exports['qb-input']:ShowInput({ header = setheader, txt = "test", submitText = "Transfer", inputs = setinputs })
if dialog then
if not dialog.amount then return end
loadAnimDict('amb@prop_human_atm@male@exit')
TaskPlayAnim(PlayerPedId(), 'amb@prop_human_atm@male@exit', "exit", 1.0,-1.0, 3000, 1, 1, true, true, true)
unloadAnimDict('amb@prop_human_atm@male@enter')
Wait(1000)
TriggerServerEvent('jim-payments:server:ATM:use', dialog.amount, dialog.billtype, dialog.account, data.id, info.society, info.gsociety)
end
end, function() TriggerEvent("QBCore:Notify", "Cancelled!", "error")
end, data.icon)
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 _, id in pairs(QBCore.Functions.GetPlayersFromCoords(GetEntityCoords(PlayerPedId()), Config.PaymentRadius)) do
local dist = #(GetEntityCoords(GetPlayerPed(id)) - GetEntityCoords(PlayerPedId()))
for i = 1, #onlineList do
if onlineList[i].value == GetPlayerServerId(id) then
if id ~= PlayerId() or Config.Debug 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 not nearbyList[1] 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)
AddEventHandler('onResourceStop', function(r) if r ~= GetCurrentResourceName() then return end
for k in pairs(Targets) do exports['qb-target']:RemoveZone(k) end
for k in pairs(Peds) do unloadModel(GetEntityModel(Peds[k])) DeletePed(Peds[k]) end
end)

192
client/client.lua Normal file
View File

@@ -0,0 +1,192 @@
local QBCore = exports['qb-core']:GetCoreObject()
PlayerJob = {}
PlayerGang = {}
local onDuty = false
local BankPed = nil
local Targets = {}
local Till = {}
RegisterNetEvent('QBCore:Client:OnPlayerLoaded', function() QBCore.Functions.GetPlayerData(function(PlayerData) PlayerJob = PlayerData.job PlayerGang = PlayerData.gang end) end)
RegisterNetEvent('QBCore:Client:OnJobUpdate', function(JobInfo) PlayerJob = JobInfo onDuty = PlayerJob.onduty end)
RegisterNetEvent('QBCore:Client:SetDuty', function(duty) onDuty = duty end)
RegisterNetEvent('QBCore:Client:OnGangUpdate', function(GangInfo) PlayerGang = GangInfo end)
--Keeps track of duty on script restarts
AddEventHandler('onResourceStart', function(resource) if GetCurrentResourceName() ~= resource then return end
QBCore.Functions.GetPlayerData(function(PlayerData)
PlayerJob = PlayerData.job
PlayerGang = PlayerData.gang
onDuty = PlayerJob.onduty
end)
end)
CreateThread(function()
local jobroles = {} local gangroles = {}
--Build Job/Gang Checks for cashin location
for k, v in pairs(Config.Jobs) do if v.gang then gangroles[tostring(k)] = 0 else jobroles[tostring(k)] = 0 end end
--Create Target at location
Targets["JimBank"] =
exports['qb-target']:AddCircleZone("JimBank", vector3(Config.CashInLocation.x, Config.CashInLocation.y, Config.CashInLocation.z), 2.0, { name="JimBank", debugPoly=Config.Debug, useZ=true, },
{ options = {
{ event = "jim-payments:Tickets:Menu", icon = "fas fa-receipt", label = "Cash in Job Receipts", job = jobroles, },
{ event = "jim-payments:Tickets:Menu", icon = "fas fa-receipt", label = "Cash in Gang Receipts", gang = gangroles, } },
distance = 2.0 })
--Crete Ped at the location
if Config.Peds then
local i = math.random(1, #Config.PedPool)
if not Config.Gabz then CreateModelHide(vector3(Config.CashInLocation.x, Config.CashInLocation.y, Config.CashInLocation.z), 1.0, `v_corp_bk_chair3`, true) end
if not BankPed then
BankPed = CreatePed(0, Config.PedPool[i], vector3(Config.CashInLocation.x, Config.CashInLocation.y, Config.CashInLocation.z-1), Config.CashInLocation[4], false, false)
end
end
--Spawn Custom Cash Register Targets
for k, v in pairs(Config.CustomCashRegisters) do
for i = 1, #v do
local job = k
local gang = nil
if v[i].gang then job = nil gang = k end
Targets["CustomRegister: "..k..i] =
exports['qb-target']:AddBoxZone("CustomRegister: "..k..i, v[i].coords, 0.47, 0.34, { name="CustomRegister: "..k..i, heading = v[i].coords[4], debugPoly=Config.Debug, minZ=v[i].coords.z-0.1, maxZ=v[i].coords.z+0.4 },
{ options = { { event = "jim-payments:client:Charge", icon = "fas fa-credit-card", label = "Charge Customer", job = job, gang = gang, img = "" }, },
distance = 2.0 })
if v[i].prop then
Till[#Till+1] = makeProp({prop = `prop_till_03`, coords = v[i].coords}, 1, false)
end
end
end
end)
RegisterNetEvent('jim-payments:client:Charge', function(data, outside)
--Check if player is using /cashregister command
if not outside and not onDuty and data.gang == nil then TriggerEvent("QBCore:Notify", "Not Clocked in!", "error") return end
local newinputs = {} -- Begin qb-input creation here.
if Config.List then -- If nearby player list is wanted:
--Retrieve a list of nearby players from server
local p = promise.new() QBCore.Functions.TriggerCallback('jim-payments:MakePlayerList', function(cb) p:resolve(cb) end)
local onlineList = Citizen.Await(p)
local nearbyList = {}
--Convert list of players nearby into one qb-input understands + add distance info
for _, 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() or Config.Debug then
nearbyList[#nearbyList+1] = { value = onlineList[i].value, text = onlineList[i].text..' ('..math.floor(dist+0.05)..'m)' }
end
end
end
end
--If list is empty(no one nearby) show error and stop
if not nearbyList[1] then TriggerEvent("QBCore:Notify", "No one near by to charge", "error") return end
newinputs[#newinputs+1] = { text = " ", name = "citizen", type = "select", options = nearbyList }
else -- If Config.List is false, create input text box for ID's
newinputs[#newinputs+1] = { type = 'text', isRequired = true, name = 'citizen', text = '# Customer ID #' }
end
--Check if image was given when opening the regsiter
local img = data.img or ""
--Continue adding payment options to qb-input
newinputs[#newinputs+1] = { type = 'radio', name = 'billtype', text = 'Payment Type', options = { { value = "cash", text = "Cash" }, { value = "bank", text = "Card" } } }
newinputs[#newinputs+1] = { type = 'number', isRequired = true, name = 'price', text = '💵 Amount to Charge' }
--Grab Player Job name or Gang Name if needed
local label = PlayerJob.label
local gang = false
if data.gang then label = PlayerGang.label gang = true end
local dialog = exports['qb-input']:ShowInput({ header = img..label.." Cash Register", submitText = "Send", inputs = newinputs})
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, data.img, outside, gang)
end
end)
RegisterNetEvent('jim-payments:client:PolCharge', function()
--Check if player is allowed to use /cashregister command
local allowed = false
for k in pairs(Config.FineJobs) do if k == PlayerJob.name then allowed = true end end
if not allowed then TriggerEvent("QBCore:Notify", "You don't have the required job", "error") return end
local newinputs = {} -- Begin qb-input creation here.
if Config.FineJobList then -- If nearby player list is wanted:
--Retrieve a list of nearby players from server
local p = promise.new() QBCore.Functions.TriggerCallback('jim-payments:MakePlayerList', function(cb) p:resolve(cb) end)
local onlineList = Citizen.Await(p)
local nearbyList = {}
--Convert list of players nearby into one qb-input understands + add distance info
for _, 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() or Config.Debug then
nearbyList[#nearbyList+1] = { value = onlineList[i].value, text = onlineList[i].text..' ('..math.floor(dist+0.05)..'m)' }
end
end
end
end
--If list is empty(no one nearby) show error and stop
if not nearbyList[1] then TriggerEvent("QBCore:Notify", "No one near by to charge", "error") return end
newinputs[#newinputs+1] = { text = " ", name = "citizen", type = "select", options = nearbyList }
else -- If Config.List is false, create input text box for ID's
newinputs[#newinputs+1] = { type = 'text', isRequired = true, name = 'citizen', text = "# Person's ID #" }
end
--Continue adding payment options to qb-input
newinputs[#newinputs+1] = { type = 'number', isRequired = true, name = 'price', text = '💵 Amount to Charge' }
--Grab Player Job name or Gang Name if needed
local label = PlayerJob.label
local gang = false
local dialog = exports['qb-input']:ShowInput({ header = label.." Charge", submitText = "Send", inputs = newinputs})
if dialog then
if not dialog.citizen or not dialog.price then return end
TriggerServerEvent('jim-payments:server:PolCharge', dialog.citizen, dialog.price)
end
end)
RegisterNetEvent('jim-payments:Tickets:Menu', function(data)
--Get ticket info
local p = promise.new() QBCore.Functions.TriggerCallback('jim-payments:Ticket:Count', function(cb) p:resolve(cb) end)
local amount = Citizen.Await(p)
if not amount then TriggerEvent("QBCore:Notify", "You don't have any tickets to trade", "error") amount = 0 return end
local sellable = false
local name = "" local label = ""
--Check/adjust for job/gang names
for k, v in pairs(Config.Jobs) do
if data.gang then if v.gang and k == PlayerGang.name then name = k label = PlayerGang.label sellable = true end
else if not v.gang and k == PlayerJob.name then name = k label = PlayerJob.label sellable = true end
end
if sellable then -- if info is found then:
exports['qb-menu']:openMenu({
{ isMenuHeader = true, header = "🧾 "..label.." Receipts 🧾", txt = "Do you want trade your receipts for payment?" },
{ isMenuHeader = true, header = "", txt = "Amount of Tickets: "..amount.."<br>Total Payment: $"..(Config.Jobs[name].PayPerTicket * amount) },
{ icon = "fas fa-circle-check", header = "Yes", txt = "", params = { event = "jim-payments:Tickets:Sell:yes" } },
{ icon = "fas fa-circle-xmark", header = "No", txt = "", params = { event = "jim-payments:Tickets:Sell:no" } },
})
end
end
end)
RegisterNetEvent("jim-payments:client:PayPopup", function(amount, biller, billtype, img, billerjob, gang, outside)
local img = img or ""
exports['qb-menu']:openMenu({
{ isMenuHeader = true, header = img.."🧾 "..billerjob.." Payment 🧾", txt = "Do you want accept the payment?" },
{ isMenuHeader = true, header = "", txt = billtype:gsub("^%l", string.upper).." Payment: $"..amount },
{ icon = "fas fa-circle-check", header = "Yes", txt = "", params = { isServer = true, event = "jim-payments:server:PayPopup", args = { accept = true, amount = amount, biller = biller, billtype = billtype, gang = gang, outside = outside } } },
{ icon = "fas fa-circle-xmark", header = "No", txt = "", params = { isServer = true, event = "jim-payments:server:PayPopup", args = { accept = false, amount = amount, biller = biller, billtype = billtype, outside = outside } } }, })
end)
RegisterNetEvent("jim-payments:client:PolPopup", function(amount, biller, billerjob)
exports['qb-menu']:openMenu({
{ isMenuHeader = true, header = "🧾 "..billerjob.." Payment 🧾", txt = "Do you want accept the charge?" },
{ isMenuHeader = true, header = "", txt = "Bank Charge: $"..amount },
{ icon = "fas fa-circle-check", header = "Yes", txt = "", params = { isServer = true, event = "jim-payments:server:PolPopup", args = { accept = true, amount = amount, biller = biller } } },
{ icon = "fas fa-circle-xmark", header = "No", txt = "", params = { isServer = true, event = "jim-payments:server:PolPopup", args = { accept = false, amount = amount, biller = biller } } }, })
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)
AddEventHandler('onResourceStop', function(r) if r ~= GetCurrentResourceName() then return end
for k in pairs(Targets) do exports['qb-target']:RemoveZone(k) end
for i = 1, #till do DeleteEntity(till[i]) end
unloadModel(GetEntityModel(BankPed)) DeletePed(BankPed)
end)

View File

@@ -1,17 +1,20 @@
print("Jim-Payments v2.7 - Payments Script by Jimathy") print("^2Jim^7-^2Payments v^42^7.^47 ^7- ^2Payments Script by ^1Jimathy^7")
-- 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.
-- https://discord.gg/xKgQZ6wZvS -- https://discord.gg/xKgQZ6wZvS
Config = { Config = {
Debug = true, Debug = false,
---------------------------------
-- Default Job Payment Systems --
---------------------------------
Manage = true, -- "true" if using qb-management Manage = true, -- "true" if using qb-management
-- "false" if using qb-bossmenu -- "false" if using qb-bossmenu
TicketSystem = true, -- Enable this if you want to use the ticket system false
List = true, -- "true" to use nearby player list feature in the cash registers, "false" for manual id entry List = true, -- "true" to use nearby player list feature in the cash registers, "false" for manual id entry
PaymentRadius = 30, -- This is how far the playerlist will check for nearby players (based on the person charging) PaymentRadius = 15, -- This is how far the playerlist will check for nearby players (based on the person charging)
Peds = true, -- "true" to enable peds spawning in banks Peds = true, -- "true" to enable peds spawning in banks
PedPool = { PedPool = {
@@ -30,10 +33,6 @@ Config = {
`A_M_Y_Business_03`, `A_M_Y_Business_03`,
`U_F_M_CasinoShop_01`, `U_F_M_CasinoShop_01`,
}, },
useATM = true, -- Enable this to use the scripts ATM's and controls
useBanks = true, -- Enable this to use my banking stuff
BankBlips = true, -- Enable this if you disabled qb-banking and need bank locations
ATMBlips = false, -- Enable this if you are a pyscho and need every ATM to be on the map too
PhoneBank = false, -- Set this to false to use the popup payment system FOR CARD/BANK PAYMENTS instead of using phone invoices PhoneBank = false, -- 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 doesn't affect Cash payments as they by default use confirmation now
@@ -45,13 +44,14 @@ Config = {
CashInLocation = vector4(252.23, 223.11, 106.29, 159.2), -- Default Third Window along in Pacific Bank CashInLocation = vector4(252.23, 223.11, 106.29, 159.2), -- Default Third Window along in Pacific Bank
TicketSystem = true, -- Enable this if you want to use the ticket system false
TicketSystemAll = true, -- Enable this to give tickets to all workers clocked in
Commission = true, -- Set this to true to enable Commissions and give the person charging a percentage of the total Commission = true, -- Set this to true to enable Commissions and give the person charging a percentage of the total
CommissionAll = false, -- Set this to true to give commission to workers clocked in CommissionAll = false, -- Set this to true to give commission to workers clocked in
CommissionDouble = false, -- Set this to true if you want the person charging to get double Commission CommissionDouble = false, -- Set this to true if you want the person charging to get double Commission
CommissionLimit = false, -- If true, this limits the Commission to only be given if over the "MinAmountForTicket". 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 -- If false, Commission will be given for any amount
Gabz = true, -- "true" to enable Gabz Bank locations
-- 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
@@ -66,20 +66,39 @@ Config = {
['tequilala'] = { MinAmountforTicket = 50, PayPerTicket = 50, Commission = 0.10, }, ['tequilala'] = { MinAmountforTicket = 50, PayPerTicket = 50, Commission = 0.10, },
['vanilla'] = { MinAmountforTicket = 50, PayPerTicket = 50, Commission = 0.10, }, ['vanilla'] = { MinAmountforTicket = 50, PayPerTicket = 50, Commission = 0.10, },
['mechanic'] = { MinAmountforTicket = 1000, PayPerTicket = 500, Commission = 0.10, }, ['mechanic'] = { MinAmountforTicket = 1000, PayPerTicket = 500, Commission = 0.10, },
['lostmc'] = { MinAmountforTicket = 50, PayPerTicket = 50, Commission = 0.10, gang = true, }, ['lostmc'] = { MinAmountforTicket = 50, PayPerTicket = 50, Commission = 0.10, gang = true, }, -- Example of a gang being supported
},
------------------------------
-- Custom Job Cash Register --
------------------------------
-- This adds the ability to add multiple locations for each job
-- Basically adding ready made locations, all you need to a vector4 and to confrim if you need a new prop in that location
CustomCashRegisters = {
}, },
-- The /polcharge command requires specific jobs to be set -- The /polcharge command requires specific jobs to be set
-- No tickets for these, it's just commission -- No tickets for these, it's just commission (0.25 = 25%)
FineJobs = { FineJobs = {
['police'] = { Commission = 0.25, }, ['police'] = { Commission = 0.25, },
['ambulance'] = { Commission = 0.25, }, ['ambulance'] = { Commission = 0.25, },
}, },
FineJobConfirmation = true, --"true" makes it so fines need confirmation, "false" skips this ands just removes the money FineJobConfirmation = false, --"true" makes it so fines need confirmation, "false" skips this ands just removes the money
FineJobList = true, -- "true" to use nearby player list feature in the cash registers, "false" for manual id entry FineJobList = true, -- "true" to use nearby player list feature in the cash registers, "false" for manual id entry
ATMModels = { "prop_atm_01", "prop_atm_02", "prop_atm_03", "prop_fleeca_atm" }, ---------------------
-- Banking Systems --
---------------------
useATM = false, -- Enable this to use the scripts ATM's and controls
useBanks = false, -- Enable this to use my banking stuff
BankBlips = false, -- Enable this if you disabled qb-banking and need bank locations
ATMBlips = false, -- Enable this if you are a pyscho and need every ATM to be on the map too
Gabz = true, -- "true" to enable Gabz Bank locations
-- this corrects the ATM/Bank Cashier + Ticket Cash in location
ATMModels = { `prop_atm_01`, `prop_atm_02`, `prop_atm_03`, `prop_fleeca_atm` },
ATMLocations = { ATMLocations = {
--PACIFIC BANK 10 ATMS --PACIFIC BANK 10 ATMS
vector3(265.9, 213.86, 106.28), vector3(265.9, 213.86, 106.28),
@@ -148,6 +167,7 @@ Config = {
vector3(5.27, -919.87, 29.56), vector3(5.27, -919.87, 29.56),
vector3(-1200.61, -885.62, 13.26), vector3(-1200.61, -885.62, 13.26),
}, },
BankLocations = { BankLocations = {
["legion"] = { ["legion"] = {
vector4(149.5, -1042.08, 29.37, 342.74), -- Legion Fleeca vector4(149.5, -1042.08, 29.37, 342.74), -- Legion Fleeca
@@ -176,7 +196,8 @@ Config = {
}, },
}, },
} }
if Config.Gabz then -- If Gabz banks enabled, load these locations instead -- If Gabz banks enabled, load these locations instead
if Config.Gabz then
Config.CashInLocation = vector4(269.28, 217.24, 106.28, 69.0) Config.CashInLocation = vector4(269.28, 217.24, 106.28, 69.0)
Config.BankLocations = { Config.BankLocations = {
["legion"] = { ["legion"] = {

View File

@@ -1,26 +1,11 @@
name "Jim-Payments" name "Jim-Payments"
author "Jimathy" author "Jimathy"
version "v2.7" version "v2.8"
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-target', }
'qb-input', client_scripts { 'client/*.lua' }
'qb-target', server_scripts { '@oxmysql/lib/MySQL.lua', 'server/*.lua' }
} shared_scripts { 'config.lua', 'shared/*.lua' }
client_scripts {
'client.lua',
'atms.lua'
}
server_scripts {
'@oxmysql/lib/MySQL.lua',
'server.lua',
'atmserver.lua'
}
shared_scripts {
'config.lua',
}

View File

@@ -22,15 +22,15 @@ RegisterServerEvent('jim-payments:Tickets:Give', function(data, biller, gang)
if biller then -- If this is found, it ISN'T a phone payment, so add money to society here if biller then -- If this is found, it ISN'T a phone payment, so add money to society here
if gang then if gang then
if Config.Manage then exports["qb-management"]:AddGangMoney(tostring(biller.PlayerData.gang.name), data.amount) if Config.Manage then exports["qb-management"]:AddGangMoney(tostring(biller.PlayerData.gang.name), data.amount)
if Config.Debug then print("QB-Management(Gang): Adding $"..data.amount.." to account '"..tostring(biller.PlayerData.gang.name).."'") end if Config.Debug then print("^5Debug^7: ^3QB^7-^3Management^7(^3Gang^7): ^2Adding ^7$^6"..data.amount.." ^2to account ^7'^6"..tostring(biller.PlayerData.gang.name).."^7' ($^6"..exports["qb-management"]:GetGangAccount(biller.PlayerData.gang.name).."^7)") end
else TriggerEvent("qb-gangmenu:server:addAccountMoney", tostring(biller.PlayerData.gang.name), data.amount) else TriggerEvent("qb-gangmenu:server:addAccountMoney", tostring(biller.PlayerData.gang.name), data.amount)
if Config.Debug then print("QB-GangMenu: Adding $"..data.amount.." to account '"..tostring(biller.PlayerData.gang.name).."'") end if Config.Debug then print("^5Debug^7: ^3QB^7-^3GangMenu^7: ^2Adding ^7$^6"..data.amount.." ^2to account ^7'^6"..tostring(biller.PlayerData.gang.name).."^7'") end
end end
elseif not gang then elseif not gang then
if Config.Manage then exports["qb-management"]:AddMoney(tostring(biller.PlayerData.job.name), data.amount) if Config.Manage then exports["qb-management"]:AddMoney(tostring(biller.PlayerData.job.name), data.amount)
if Config.Debug then print("QB-Management(Job): Adding $"..data.amount.." to account '"..tostring(biller.PlayerData.job.name).."'") end if Config.Debug then print("^5Debug^7: ^3QB-Management^7(^3Job^7): ^2Adding ^7$^6"..data.amount.." ^2to account ^7'^6"..tostring(biller.PlayerData.job.name).."^7' ($^6"..exports["qb-management"]:GetAccount(biller.PlayerData.job.name).."^7)") end
else TriggerEvent("qb-bossmenu:server:addAccountMoney", tostring(biller.PlayerData.job.name), data.amount) else TriggerEvent("qb-bossmenu:server:addAccountMoney", tostring(biller.PlayerData.job.name), data.amount)
if Config.Debug then print("QB-BossMenu: Adding $"..data.amount.." to account '"..tostring(biller.PlayerData.job.name).."'") end if Config.Debug then print("^5Debug^7: ^3QB-BossMenu^7: ^2Adding ^7$^6"..data.amount.." ^2to account ^7'^6"..tostring(biller.PlayerData.job.name).."^7'") end
end end
end end
elseif not biller then --Find the biller from their citizenid elseif not biller then --Find the biller from their citizenid
@@ -47,20 +47,26 @@ RegisterServerEvent('jim-payments:Tickets:Give', function(data, biller, gang)
-- If ticket system enabled, do this -- If ticket system enabled, do this
if duty and Config.TicketSystem then if duty and Config.TicketSystem then
if data.amount >= Config.Jobs[data.society].MinAmountforTicket then if data.amount >= Config.Jobs[data.society].MinAmountforTicket then
for _, v in pairs(QBCore.Functions.GetPlayers()) do if Config.TicketSystemAll then
local Player = QBCore.Functions.GetPlayer(v) for _, v in pairs(QBCore.Functions.GetPlayers()) do
if Player ~= nil or Player ~= billed then local Player = QBCore.Functions.GetPlayer(v)
if Player.PlayerData.job.name == data.society and Player.PlayerData.job.onduty then if Player ~= nil or Player ~= billed then
Player.Functions.AddItem('payticket', 1, false, {["quality"] = nil}) if Player.PlayerData.job.name == data.society and Player.PlayerData.job.onduty then
TriggerClientEvent('QBCore:Notify', Player.PlayerData.source, 'Receipt received', 'success') Player.Functions.AddItem('payticket', 1, false, {["quality"] = nil})
TriggerClientEvent('inventory:client:ItemBox', Player.PlayerData.source, QBCore.Shared.Items['payticket'], "add", 1) TriggerClientEvent('QBCore:Notify', Player.PlayerData.source, 'Receipt received', 'success')
TriggerClientEvent('inventory:client:ItemBox', Player.PlayerData.source, QBCore.Shared.Items['payticket'], "add", 1)
end
end
if gang then
biller.Functions.AddItem('payticket', 1, false, {["quality"] = nil})
TriggerClientEvent('QBCore:Notify', biller.PlayerData.source, 'Receipt received', 'success')
TriggerClientEvent('inventory:client:ItemBox', biller.PlayerData.source, QBCore.Shared.Items['payticket'], "add", 1)
end end
end end
if gang then else
biller.Functions.AddItem('payticket', 1, false, {["quality"] = nil}) biller.Functions.AddItem('payticket', 1, false, {["quality"] = nil})
TriggerClientEvent('QBCore:Notify', biller.PlayerData.source, 'Receipt received', 'success') TriggerClientEvent('QBCore:Notify', biller.PlayerData.source, 'Receipt received', 'success')
TriggerClientEvent('inventory:client:ItemBox', biller.PlayerData.source, QBCore.Shared.Items['payticket'], "add", 1) TriggerClientEvent('inventory:client:ItemBox', biller.PlayerData.source, QBCore.Shared.Items['payticket'], "add", 1)
end
end end
end end
end end
@@ -167,32 +173,44 @@ RegisterServerEvent("jim-payments:server:PolCharge", function(citizen, price)
local src = source local src = source
local biller = QBCore.Functions.GetPlayer(src) local biller = QBCore.Functions.GetPlayer(src)
local billed = QBCore.Functions.GetPlayer(tonumber(citizen)) local billed = QBCore.Functions.GetPlayer(tonumber(citizen))
if tonumber(price) and tonumber(price) > 0 then local price = math.floor(tonumber(price))
local commission = math.floor(price * Config.FineJobs[biller.PlayerData.job.name].Commission)
if price > 0 then
if not Config.FineJobConfirmation then if not Config.FineJobConfirmation then
billed.Functions.RemoveMoney("bank", math.floor(tonumber(price))) if billed.Functions.RemoveMoney("bank", price) then if Config.Debug then print("^5Debug^7: ^3PolCharge^7 - ^2Player^7(^6"..billed.PlayerData.source.."^7) ^2charged ^7$^6"..price.."^7") end end
local commission = (tonumber(price) * Config.FineJobs[biller.PlayerData.job.name].Commission) if biller.Functions.AddMoney("bank", commission) then if Config.Debug then print("^5Debug^7: ^3PolCharge^7 - ^2Commission of ^7$^6"..commission.." ^2sent to Player^7(^6"..biller.PlayerData.source.."^7)") end end
biller.Functions.AddMoney("bank", math.floor(commission))
if Config.Manage then if Config.Manage then
if Config.Manage then exports["qb-management"]:AddMoney(tostring(biller.PlayerData.job.name), price) exports["qb-management"]:AddMoney(tostring(biller.PlayerData.job.name), (price - commission))
if Config.Debug then print("QB-Management(Job): Adding $"..price.." to account '"..tostring(biller.PlayerData.job.name).."'") end if Config.Debug then print("^5Debug^7: ^3QB^7-^3Management^7(^3Job^7): ^2Adding ^7$^6"..(price - commission).." ^2to account ^7'^6"..tostring(biller.PlayerData.job.name).."^7' ($^6"..exports["qb-management"]:GetAccount(biller.PlayerData.job.name).."^7)") end
else TriggerEvent("qb-bossmenu:server:addAccountMoney", tostring(biller.PlayerData.job.name), price) else
if Config.Debug then print("QB-BossMenu: Adding $"..price.." to account '"..tostring(biller.PlayerData.job.name).."'") end TriggerEvent("qb-bossmenu:server:addAccountMoney", tostring(biller.PlayerData.job.name), (price - commission))
end if Config.Debug then print("^5Debug^7: ^3QB^7-^3BossMenu^7: ^2Adding ^7$^6"..(price - commission).." ^2to account ^7'^6"..tostring(biller.PlayerData.job.name).."^7'") end
end end
TriggerClientEvent('QBCore:Notify', src, billed.PlayerData.charinfo.firstname.." was charged for $"..tonumber(price), "success") TriggerClientEvent('QBCore:Notify', src, billed.PlayerData.charinfo.firstname.." was charged for $"..(price - commission), "success")
TriggerClientEvent('QBCore:Notify', billed.PlayerData.source, 'You were charged for $'..tonumber(price)) TriggerClientEvent('QBCore:Notify', billed.PlayerData.source, 'You were charged for $'..(price - commission))
else else
TriggerClientEvent("jim-payments:client:PolPopup", billed.PlayerData.source, tonumber(price), src, biller.PlayerData.job.label) TriggerClientEvent("jim-payments:client:PolPopup", billed.PlayerData.source, price, src, biller.PlayerData.job.label)
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:PolPopup", function(data) RegisterServerEvent("jim-payments:server:PolPopup", function(data)
local src = source local src = source
local billed = QBCore.Functions.GetPlayer(src) local billed = QBCore.Functions.GetPlayer(src)
local biller = QBCore.Functions.GetPlayer(tonumber(data.biller)) local biller = QBCore.Functions.GetPlayer(tonumber(data.biller))
data.amount = math.floor(data.amount)
local commission = math.floor(tonumber(data.amount) * Config.FineJobs[biller.PlayerData.job.name].Commission)
if data.accept == true then if data.accept == true then
billed.Functions.RemoveMoney("bank", data.amount) if billed.Functions.RemoveMoney("bank", data.amount) then if Config.Debug then print("^5Debug^7: ^3PolCharge^7 - ^2Player^7(^6"..billed.PlayerData.source.."^7) ^2charged ^7$^6"..data.amount.."^7") end end
TriggerClientEvent("QBCore:Notify", data.biller, billed.PlayerData.charinfo.firstname.." accepted the $"..data.amount.." charge", "success") TriggerClientEvent("QBCore:Notify", data.biller, billed.PlayerData.charinfo.firstname.." accepted the $"..data.amount.." charge", "success")
if biller.Functions.AddMoney("bank", commission) then if Config.Debug then print("^5Debug^7: ^3PolCharge^7 - ^2Commission^2 of ^7$^6"..commission.." ^2sent to Player^7(^6"..biller.PlayerData.source.."^7)") end end
if Config.Manage then
exports["qb-management"]:AddMoney(tostring(biller.PlayerData.job.name), data.amount - commission)
if Config.Debug then print("^5Debug^7: ^3QB^7-^3Management^7(^3Job^7): ^2Adding ^7$^6"..data.amount - commission.." ^2to account ^7'^6"..tostring(biller.PlayerData.job.name).."^7' ($^6"..exports["qb-management"]:GetAccount(biller.PlayerData.job.name).."^7)") end
else
TriggerEvent("qb-bossmenu:server:addAccountMoney", tostring(biller.PlayerData.job.name), data.amount - commission)
if Config.Debug then print("^5Debug^7: ^3QB^7-^3BossMenu^7: ^2Adding ^6$^7"..data.amount - commission.." ^2to account ^7'^6"..tostring(biller.PlayerData.job.name).."^7'") end
end
else else
TriggerClientEvent("QBCore:Notify", src, "You declined the payment") TriggerClientEvent("QBCore:Notify", src, "You declined the payment")
TriggerClientEvent("QBCore:Notify", data.biller, billed.PlayerData.charinfo.firstname.." declined the $"..data.amount.." charge", "error") TriggerClientEvent("QBCore:Notify", data.biller, billed.PlayerData.charinfo.firstname.." declined the $"..data.amount.." charge", "error")
@@ -201,9 +219,9 @@ 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 _, v in pairs(QBCore.Functions.GetPlayers()) do
local P = QBCore.Functions.GetPlayer(v) local P = QBCore.Functions.GetPlayer(v)
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)

268
server/atmserver.lua Normal file
View File

@@ -0,0 +1,268 @@
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
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)
--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)
if Config.Manage then exports["qb-management"]:RemoveMoney(tostring(Player.PlayerData.job.name), amount)
else TriggerEvent("qb-bossmenu:server:removeAccountMoney", tostring(Player.PlayerData.job.name), amount) end
end
elseif billtype == "deposit" then
if bankB < amount then TriggerClientEvent("QBCore:Notify", src, "Not enough money in your bank", "error")
elseif bankB >= amount then
if Config.Manage then exports["qb-management"]:AddMoney(tostring(Player.PlayerData.job.name), amount)
else TriggerEvent("qb-bossmenu:server:addAccountMoney", tostring(Player.PlayerData.job.name), amount) end
Player.Functions.RemoveMoney('bank', amount) Wait(1500)
TriggerClientEvent("QBCore:Notify", src, "Deposited $"..cv(amount).." into the "..Player.PlayerData.job.label.." account", "success")
end
end
-- Transfer from boss account to players --
elseif account == "societytransfer" then
local bannedCharacters = {'%','$',';'}
local newAmount = tostring(amount)
local newiban = tostring(baccount)
for _, v in pairs(bannedCharacters) do
newAmount = string.gsub(newAmount, '%' .. v, '')
newiban = string.gsub(newiban, '%' .. v, '')
end
baccount = newiban
amount = tonumber(newAmount)
local Player = QBCore.Functions.GetPlayer(src)
if (society - amount) >= 0 then
local query = '%"account":"' .. baccount .. '"%'
local result = MySQL.Sync.fetchAll('SELECT * FROM players WHERE charinfo LIKE ?', {query})
if result[1] then
local Reciever = QBCore.Functions.GetPlayerByCitizenId(result[1].citizenid)
if Config.Manage then exports["qb-management"]:RemoveMoney(tostring(Player.PlayerData.job.name), amount)
else TriggerEvent("qb-bossmenu:server:removeAccountMoney", tostring(Player.PlayerData.job.name), amount) end
if Reciever 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)
MySQL.Async.execute('UPDATE players SET money = ? WHERE citizenid = ?', {json.encode(RecieverMoney), result[1].citizenid})
end
elseif not result[1] then TriggerClientEvent("QBCore:Notify", src, "Error: Account '"..baccount.."' not found", "error")
end
end
--Simple transfers from gang 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)
if Config.Manage then exports["qb-management"]:RemoveGangMoney(tostring(Player.PlayerData.gang.name), amount)
else TriggerEvent("qb-gangmenu:server:removeAccountMoney", tostring(Player.PlayerData.gang.name), amount) end
end
elseif billtype == "deposit" then
if bankB < amount then TriggerClientEvent("QBCore:Notify", src, "Not enough money in your bank", "error")
elseif bankB >= amount then
if Config.Manage then exports["qb-management"]:AddGangMoney(tostring(Player.PlayerData.gang.name), amount)
else TriggerEvent("qb-gangmenu:server:addAccountMoney", tostring(Player.PlayerData.gang.name), amount) end
Player.Functions.RemoveMoney('bank', amount) Wait(1500)
TriggerClientEvent("QBCore:Notify", src, "Deposited $"..cv(amount).." into the "..Player.PlayerData.gang.label.." account", "success")
end
end
-- Transfer from gang account to players --
elseif account == "gangtransfer" then
local bannedCharacters = {'%','$',';'}
local newAmount = tostring(amount)
local newiban = tostring(baccount)
for _, v in pairs(bannedCharacters) do
newAmount = string.gsub(newAmount, '%' .. v, '')
newiban = string.gsub(newiban, '%' .. v, '')
end
baccount = newiban
amount = tonumber(newAmount)
local Player = QBCore.Functions.GetPlayer(src)
if (gsociety - amount) >= 0 then
local query = '%"account":"' .. baccount .. '"%'
local result = MySQL.Sync.fetchAll('SELECT * FROM players WHERE charinfo LIKE ?', {query})
if result[1] then
local Reciever = QBCore.Functions.GetPlayerByCitizenId(result[1].citizenid)
if Config.Manage then exports["qb-management"]:RemoveGangMoney(tostring(Player.PlayerData.gang.name), amount)
else TriggerEvent("qb-bossmenu:server:removeAccountMoney", tostring(Player.PlayerData.gang.name), amount) end
if not Reciever 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)
MySQL.Async.execute('UPDATE players SET money = ? WHERE citizenid = ?', {json.encode(RecieverMoney), result[1].citizenid})
end
elseif not result[1] 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 _, 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 = MySQL.Sync.fetchAll('SELECT * FROM players WHERE charinfo LIKE ?', {query})
if result[1] then
local Reciever = QBCore.Functions.GetPlayerByCitizenId(result[1].citizenid)
Player.Functions.RemoveMoney('bank', amount)
if Reciever 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)
MySQL.Async.execute('UPDATE players SET money = ? WHERE citizenid = ?', {json.encode(RecieverMoney), result[1].citizenid})
end
elseif not result[1] 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 society = 0
local gsociety = 0
-- If qb-management, grab info directly from database
if Config.Manage then
local result = MySQL.Sync.fetchAll('SELECT * FROM management_funds')
for _, v in pairs(result) do
if Player.PlayerData.job.name == v.job_name then society = v.amount end
end
if Player.PlayerData.gang.name ~= "none" then
for _, v in pairs(result) do
if Player.PlayerData.gang.name == v.job_name then gsociety = v.amount end
end
end
else
end
-- Grab Savings account info
local result = MySQL.Sync.fetchAll('SELECT * FROM bank_accounts WHERE citizenid = ? AND account_type = ?', { Player.PlayerData.citizenid, 'Savings' })
if result[1] then
accountID = result[1].record_id
savingBalance = result[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
local result = MySQL.Sync.fetchAll('SELECT * FROM bank_accounts WHERE citizenid = ? AND account_type = ?', { Player.PlayerData.citizenid, 'Savings' })
aid = result[1].record_id
savingBalance = result[1].amount
end
cb({name = name,
cash = cash,
bank = bank,
account = account,
cid = cid,
savbal = savingBalance,
aid = accountID,
society = society,
gsociety = gsociety})
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 "..Player.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)

225
server/server.lua Normal file
View File

@@ -0,0 +1,225 @@
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 Wait(0) end
return formatted
end
AddEventHandler('onResourceStart', function(resource) if GetCurrentResourceName() ~= resource then return end
for k in pairs(Config.Jobs) do
if not QBCore.Shared.Jobs[k] and not QBCore.Shared.Gangs[k] then
print("Jim-Payments: Config.Jobs searched for job/gang '"..k.."' and couldn't find it in the Shared")
end
end
end)
QBCore.Commands.Add("cashregister", "Use mobile cash register", {}, false, function(source) TriggerClientEvent("jim-payments:client:Charge", source, {}, true) end)
QBCore.Commands.Add("polcharge", "Charge another person", {}, false, function(source) TriggerClientEvent("jim-payments:client:PolCharge", source) end)
RegisterServerEvent('jim-payments:Tickets:Give', function(data, biller, gang)
local billed = QBCore.Functions.GetPlayer(source) -- This should always be from the person who accepted the payment
if biller then -- If this is found, it ISN'T a phone payment, so add money to society here
if gang then
if Config.Manage then exports["qb-management"]:AddGangMoney(tostring(biller.PlayerData.gang.name), data.amount)
if Config.Debug then print("^5Debug^7: ^3QB^7-^3Management^7(^3Gang^7): ^2Adding ^7$^6"..data.amount.." ^2to account ^7'^6"..tostring(biller.PlayerData.gang.name).."^7' ($^6"..exports["qb-management"]:GetGangAccount(biller.PlayerData.gang.name).."^7)") end
else TriggerEvent("qb-gangmenu:server:addAccountMoney", tostring(biller.PlayerData.gang.name), data.amount)
if Config.Debug then print("^5Debug^7: ^3QB^7-^3GangMenu^7: ^2Adding ^7$^6"..data.amount.." ^2to account ^7'^6"..tostring(biller.PlayerData.gang.name).."^7'") end
end
elseif not gang then
if Config.Manage then exports["qb-management"]:AddMoney(tostring(biller.PlayerData.job.name), data.amount)
if Config.Debug then print("^5Debug^7: ^3QB-Management^7(^3Job^7): ^2Adding ^7$^6"..data.amount.." ^2to account ^7'^6"..tostring(biller.PlayerData.job.name).."^7' ($^6"..exports["qb-management"]:GetAccount(biller.PlayerData.job.name).."^7)") end
else TriggerEvent("qb-bossmenu:server:addAccountMoney", tostring(biller.PlayerData.job.name), data.amount)
if Config.Debug then print("^5Debug^7: ^3QB-BossMenu^7: ^2Adding ^7$^6"..data.amount.." ^2to account ^7'^6"..tostring(biller.PlayerData.job.name).."^7'") end
end
end
elseif not biller then --Find the biller from their citizenid
for _, v in pairs(QBCore.Functions.GetPlayers()) do
local Player = QBCore.Functions.GetPlayer(v)
if Player.PlayerData.citizenid == data.senderCitizenId then biller = Player end
end
TriggerClientEvent('QBCore:Notify', biller.PlayerData.source, data.sender.." Paid their $"..data.amount.." invoice", "success")
end
local duty = true
if not biller.PlayerData.job.onduty or gang == nil then duty = false end
-- If ticket system enabled, do this
if duty and Config.TicketSystem then
if data.amount >= Config.Jobs[data.society].MinAmountforTicket then
if Config.TicketSystemAll then
for _, v in pairs(QBCore.Functions.GetPlayers()) do
local Player = QBCore.Functions.GetPlayer(v)
if Player ~= nil or Player ~= billed 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
if gang then
biller.Functions.AddItem('payticket', 1, false, {["quality"] = nil})
TriggerClientEvent('QBCore:Notify', biller.PlayerData.source, 'Receipt received', 'success')
TriggerClientEvent('inventory:client:ItemBox', biller.PlayerData.source, QBCore.Shared.Items['payticket'], "add", 1)
end
end
else
biller.Functions.AddItem('payticket', 1, false, {["quality"] = nil})
TriggerClientEvent('QBCore:Notify', biller.PlayerData.source, 'Receipt received', 'success')
TriggerClientEvent('inventory:client:ItemBox', biller.PlayerData.source, QBCore.Shared.Items['payticket'], "add", 1)
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 _, 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)
RegisterServerEvent('jim-payments:Tickets:Sell', function()
local Player = QBCore.Functions.GetPlayer(source)
if Player.Functions.GetItemByName("payticket") then TriggerClientEvent('QBCore:Notify', source, "No tickets to trade", 'error') return
else
tickets = Player.Functions.GetItemByName("payticket").amount
Player.Functions.RemoveItem('payticket', tickets)
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 traded: "..tickets.." Total: $"..cv(pay), 'success')
end
end)
QBCore.Functions.CreateCallback('jim-payments:Ticket:Count', function(source, cb)
cb(QBCore.Functions.GetPlayer(source).Functions.GetItemByName('payticket'))
end)
RegisterServerEvent("jim-payments:server:Charge", function(citizen, price, billtype, img, outside, gang)
local src = source
local biller = QBCore.Functions.GetPlayer(src)
local billed = QBCore.Functions.GetPlayer(tonumber(citizen))
local amount = tonumber(price)
local balance = billed.Functions.GetMoney(billtype)
if amount and amount > 0 then
if balance < amount then
TriggerClientEvent("QBCore:Notify", src, "Customer doesn't have enough cash to pay", "error")
TriggerClientEvent("QBCore:Notify", tonumber(citizen), "You don't have enough cash to pay", "error")
return
end
local label = biller.PlayerData.job.label
if gang == true then label = biller.PlayerData.gang.label end
if Config.PhoneBank == false or gang == true or billtype == "cash" then
TriggerClientEvent("jim-payments:client:PayPopup", billed.PlayerData.source, amount, src, billtype, img, label, gang, outside)
else
if Config.PhoneType == "qb" 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)
elseif Config.PhoneType == "gks" then
MySQL.Async.execute('INSERT INTO gksphone_invoices (citizenid, amount, society, sender, sendercitizenid, label) VALUES (@citizenid, @amount, @society, @sender, @sendercitizenid, @label)', {
['@citizenid'] = billed.PlayerData.citizenid,
['@amount'] = amount,
['@society'] = biller.PlayerData.job.name,
['@sender'] = biller.PlayerData.charinfo.firstname,
['@sendercitizenid'] = biller.PlayerData.citizenid,
['@label'] = biller.PlayerData.job.label,
})
TriggerClientEvent('gksphone:notifi', src, {title = 'Billing', message = 'Invoice Successfully Sent', img= '/html/static/img/icons/logo.png' })
TriggerClientEvent('gksphone:notifi', billed.PlayerData.source, {title = 'Billing', message = 'New Invoice Recieved', img= '/html/static/img/icons/logo.png' })
end
TriggerClientEvent('QBCore:Notify', src, 'Invoice Successfully Sent', 'success')
TriggerClientEvent('QBCore:Notify', billed.PlayerData.source, 'New Invoice Received')
end
else TriggerClientEvent('QBCore:Notify', source, "You can't charge $0", 'error') return 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.gang == true then newdata.society = biller.PlayerData.gang.name end
if data.accept == true then
billed.Functions.RemoveMoney(tostring(data.billtype), data.amount)
TriggerEvent('jim-payments:Tickets:Give', newdata, biller, data.gang)
TriggerClientEvent("QBCore:Notify", data.biller, billed.PlayerData.charinfo.firstname.." accepted the $"..data.amount.." 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 $"..data.amount.." payment", "error")
end
end)
RegisterServerEvent("jim-payments:server:PolCharge", function(citizen, price)
local src = source
local biller = QBCore.Functions.GetPlayer(src)
local billed = QBCore.Functions.GetPlayer(tonumber(citizen))
local price = math.floor(tonumber(price))
local commission = math.floor(price * Config.FineJobs[biller.PlayerData.job.name].Commission)
if price > 0 then
if not Config.FineJobConfirmation then
if billed.Functions.RemoveMoney("bank", price) then if Config.Debug then print("^5Debug^7: ^3PolCharge^7 - ^2Player^7(^6"..billed.PlayerData.source.."^7) ^2charged ^7$^6"..price.."^7") end end
if biller.Functions.AddMoney("bank", commission) then if Config.Debug then print("^5Debug^7: ^3PolCharge^7 - ^2Commission of ^7$^6"..commission.." ^2sent to Player^7(^6"..biller.PlayerData.source.."^7)") end end
if Config.Manage then
exports["qb-management"]:AddMoney(tostring(biller.PlayerData.job.name), (price - commission))
if Config.Debug then print("^5Debug^7: ^3QB^7-^3Management^7(^3Job^7): ^2Adding ^7$^6"..(price - commission).." ^2to account ^7'^6"..tostring(biller.PlayerData.job.name).."^7' ($^6"..exports["qb-management"]:GetAccount(biller.PlayerData.job.name).."^7)") end
else
TriggerEvent("qb-bossmenu:server:addAccountMoney", tostring(biller.PlayerData.job.name), (price - commission))
if Config.Debug then print("^5Debug^7: ^3QB^7-^3BossMenu^7: ^2Adding ^7$^6"..(price - commission).." ^2to account ^7'^6"..tostring(biller.PlayerData.job.name).."^7'") end
end
TriggerClientEvent('QBCore:Notify', src, billed.PlayerData.charinfo.firstname.." was charged for $"..(price - commission), "success")
TriggerClientEvent('QBCore:Notify', billed.PlayerData.source, 'You were charged for $'..(price - commission))
else
TriggerClientEvent("jim-payments:client:PolPopup", billed.PlayerData.source, price, src, biller.PlayerData.job.label)
end
else TriggerClientEvent('QBCore:Notify', source, "You can't charge $0", 'error') return end
end)
RegisterServerEvent("jim-payments:server:PolPopup", function(data)
local src = source
local billed = QBCore.Functions.GetPlayer(src)
local biller = QBCore.Functions.GetPlayer(tonumber(data.biller))
data.amount = math.floor(data.amount)
local commission = math.floor(tonumber(data.amount) * Config.FineJobs[biller.PlayerData.job.name].Commission)
if data.accept == true then
if billed.Functions.RemoveMoney("bank", data.amount) then if Config.Debug then print("^5Debug^7: ^3PolCharge^7 - ^2Player^7(^6"..billed.PlayerData.source.."^7) ^2charged ^7$^6"..data.amount.."^7") end end
TriggerClientEvent("QBCore:Notify", data.biller, billed.PlayerData.charinfo.firstname.." accepted the $"..data.amount.." charge", "success")
if biller.Functions.AddMoney("bank", commission) then if Config.Debug then print("^5Debug^7: ^3PolCharge^7 - ^2Commission^2 of ^7$^6"..commission.." ^2sent to Player^7(^6"..biller.PlayerData.source.."^7)") end end
if Config.Manage then
exports["qb-management"]:AddMoney(tostring(biller.PlayerData.job.name), data.amount - commission)
if Config.Debug then print("^5Debug^7: ^3QB^7-^3Management^7(^3Job^7): ^2Adding ^7$^6"..data.amount - commission.." ^2to account ^7'^6"..tostring(biller.PlayerData.job.name).."^7' ($^6"..exports["qb-management"]:GetAccount(biller.PlayerData.job.name).."^7)") end
else
TriggerEvent("qb-bossmenu:server:addAccountMoney", tostring(biller.PlayerData.job.name), data.amount - commission)
if Config.Debug then print("^5Debug^7: ^3QB^7-^3BossMenu^7: ^2Adding ^6$^7"..data.amount - commission.." ^2to account ^7'^6"..tostring(biller.PlayerData.job.name).."^7'") end
end
else
TriggerClientEvent("QBCore:Notify", src, "You declined the payment")
TriggerClientEvent("QBCore:Notify", data.biller, billed.PlayerData.charinfo.firstname.." declined the $"..data.amount.." charge", "error")
end
end)
QBCore.Functions.CreateCallback('jim-payments:MakePlayerList', function(source, cb)
local onlineList = {}
for _, v in pairs(QBCore.Functions.GetPlayers()) do
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)

123
shared/shared.lua Normal file
View File

@@ -0,0 +1,123 @@
local QBCore = exports['qb-core']:GetCoreObject()
RegisterNetEvent('QBCore:Client:UpdateObject', function() QBCore = exports['qb-core']:GetCoreObject() end)
local time = 1000
function loadModel(model) if not HasModelLoaded(model) then
if Config.Debug then print("^5Debug^7: ^2Loading Model^7: '^6"..model.."^7'") end
while not HasModelLoaded(model) do
if time > 0 then time = time - 1 RequestModel(model)
else time = 1000 print("^5Debug^7: ^3LoadModel^7: ^2Timed out loading model ^7'^6"..model.."^7'") break
end
Wait(10)
end
end end
function unloadModel(model) if Config.Debug then print("^5Debug^7: ^2Removing Model^7: '^6"..model.."^7'") end SetModelAsNoLongerNeeded(model) end
function loadAnimDict(dict) if Config.Debug then print("^5Debug^7: ^2Loading Anim Dictionary^7: '^6"..dict.."^7'") end while not HasAnimDictLoaded(dict) do RequestAnimDict(dict) Wait(5) end end
function unloadAnimDict(dict) if Config.Debug then print("^5Debug^7: ^2Removing Anim Dictionary^7: '^6"..dict.."^7'") end RemoveAnimDict(dict) end
function loadPtfxDict(dict) if Config.Debug then print("^5Debug^7: ^2Loading Ptfx Dictionary^7: '^6"..dict.."^7'") end while not HasNamedPtfxAssetLoaded(dict) do RequestNamedPtfxAsset(dict) Wait(5) end end
function unloadPtfxDict(dict) if Config.Debug then print("^5Debug^7: ^2Removing Ptfx Dictionary^7: '^6"..dict.."^7'") end RemoveNamedPtfxAsset(dict) end
function lookEnt(entity)
if type(entity) == "vector3" then
if not IsPedHeadingTowardsPosition(PlayerPedId(), entity, 10.0) then
TaskTurnPedToFaceCoord(PlayerPedId(), entity, 1500)
if Config.Debug then print("^5Debug^7: ^2Turning Player to^7: '^6"..json.encode(entity).."^7'") end
Wait(1500)
end
else
if DoesEntityExist(entity) then
if not IsPedHeadingTowardsPosition(PlayerPedId(), GetEntityCoords(entity), 30.0) then
TaskTurnPedToFaceCoord(PlayerPedId(), GetEntityCoords(entity), 1500)
if Config.Debug then print("^5Debug^7: ^2Turning Player to^7: '^6"..entity.."^7'") end
Wait(1500)
end
end
end
end
function destroyProp(entity)
if Config.Debug then print("^5Debug^7: ^2Destroying Prop^7: '^6"..entity.."^7'") end
SetEntityAsMissionEntity(entity) Wait(5)
DetachEntity(entity, true, true) Wait(5)
DeleteObject(entity)
end
function makeProp(data, freeze, synced)
loadModel(data.prop)
local prop = CreateObject(data.prop, data.coords.x, data.coords.y, data.coords.z-1.03, synced or false, synced or false, 0)
SetEntityHeading(prop, data.coords.w+180.0)
FreezeEntityPosition(prop, freeze or 0)
if Config.Debug then print("^5Debug^7: ^6Prop ^2Created ^7: '^6"..prop.."^7'") end
return prop
end
function makePed(model, coords, freeze, collision, scenario, anim)
loadModel(model)
local ped = CreatePed(0, model, coords.x, coords.y, coords.z-1.03, coords.w, false, false)
SetEntityInvincible(ped, true)
SetBlockingOfNonTemporaryEvents(ped, true)
FreezeEntityPosition(ped, freeze or true)
if collision then SetEntityNoCollisionEntity(ped, PlayerPedId(), false) end
if scenario then TaskStartScenarioInPlace(ped, scenario, 0, true) end
if anim then
loadAnimDict(anim[1])
TaskPlayAnim(ped, anim[1], anim[2], 1.0, 1.0, -1, 1, 0.2, 0, 0, 0)
end
if Config.Debug then print("^5Debug^7: ^6Ped ^2Created for location^7: '^6"..model.."^7'") end
return ped
end
function makeBlip(data)
local blip = AddBlipForCoord(data.coords)
SetBlipAsShortRange(blip, true)
SetBlipSprite(blip, data.sprite or 1)
SetBlipColour(blip, data.col or 0)
SetBlipScale(blip, data.scale or 0.7)
SetBlipDisplay(blip, (data.disp or 6))
BeginTextCommandSetBlipName('STRING')
AddTextComponentString(tostring(data.name))
EndTextCommandSetBlipName(blip)
if Config.Debug then print("^5Debug^7: ^6Blip ^2created for location^7: '^6"..data.name.."^7'") end
return blip
end
function triggerNotify(title, message, type, src)
if Config.Notify == "okok" then
if not src then exports['okokNotify']:Alert(title, message, 6000, type)
else TriggerClientEvent('okokNotify:Alert', src, title, message, 6000, type) end
elseif Config.Notify == "qb" then
if not src then TriggerEvent("QBCore:Notify", message, type)
else TriggerClientEvent("QBCore:Notify", src, message, type) end
elseif Config.Notify == "t" then
if not src then exports['t-notify']:Custom({title = title, style = type, message = message, sound = true})
else TriggerClientEvent('t-notify:client:Custom', src, { style = type, duration = 6000, title = title, message = message, sound = true, custom = true}) end
elseif Config.Notify == "infinity" then
if not src then TriggerEvent('infinity-notify:sendNotify', message, type)
else TriggerClientEvent('infinity-notify:sendNotify', src, message, type) end
elseif Config.Notify == "rr" then
if not src then exports.rr_uilib:Notify({msg = message, type = type, style = "dark", duration = 6000, position = "top-right", })
else TriggerClientEvent("rr_uilib:Notify", src, {msg = message, type = type, style = "dark", duration = 6000, position = "top-right", }) end
end
end
function pairsByKeys(t)
local a = {}
for n in pairs(t) do a[#a+1] = n end
table.sort(a)
local i = 0
local iter = function() i = i + 1 if a[i] == nil then return nil else return a[i], t[a[i]] end end
return iter
end
function countTable(table) local i = 0 for keys in pairs(table) do i = i + 1 end return i end
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
function toggleItem(give, item, amount) TriggerServerEvent("jim-mining:server:toggleItem", give, item, amount) end