Merge pull request #8 from jimathy/jimathy-v2.8-patch

Jimathy v2.8 patch
This commit is contained in:
Jim Shield
2022-08-22 22:17:45 +01:00
committed by GitHub
8 changed files with 255 additions and 241 deletions

View File

@@ -1,4 +1,5 @@
local QBCore = exports['qb-core']:GetCoreObject() local QBCore = exports['qb-core']:GetCoreObject()
RegisterNetEvent('QBCore:Client:UpdateObject', function() QBCore = exports['qb-core']:GetCoreObject() end)
-- This script is a simple replacement for QB-Banking and QB-ATMs -- This script is a simple replacement for QB-Banking and QB-ATMs
-- It uses QB-Input and server callbacks to retreive info about accounts and cash -- It uses QB-Input and server callbacks to retreive info about accounts and cash
@@ -10,48 +11,16 @@ local Peds = {}
local BankLoc = Config.VanBankLocations local BankLoc = Config.VanBankLocations
local ATMLoc = Config.VanATMLocations local ATMLoc = Config.VanATMLocations
local function cv(amount)
local formatted = amount
while true do
formatted, k = string.gsub(formatted, "^(-?%d+)(%d%d%d)", '%1,%2')
if (k==0) then
break
end
end
return formatted
end
local function 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("^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 _, v in pairs(Config.WallATMLocations) do for _, v in pairs(Config.WallATMLocations) do
blip = AddBlipForCoord(v) makeBlip({coords = v, sprite = 108, col = 3, scale = 0.55, disp = 6, name = "ATM" })
SetBlipSprite(blip, 108)
SetBlipDisplay(blip, 4)
SetBlipScale(blip, 0.55)
SetBlipColour(blip, 3)
SetBlipAsShortRange(blip, true)
BeginTextCommandSetBlipName("STRING")
AddTextComponentString("ATM")
EndTextCommandSetBlipName(blip)
end end
for _, v in pairs(Config.ATMLocations) do for _, v in pairs(Config.ATMLocations) do
blip = AddBlipForCoord(v) makeBlip({coords = v, sprite = 108, col = 3, scale = 0.55, disp = 6, name = "ATM" })
SetBlipSprite(blip, 108)
SetBlipDisplay(blip, 4)
SetBlipScale(blip, 0.55)
SetBlipColour(blip, 3)
SetBlipAsShortRange(blip, true)
BeginTextCommandSetBlipName("STRING")
AddTextComponentString("ATM")
EndTextCommandSetBlipName(blip)
end end
end end
end end
@@ -59,15 +28,7 @@ CreateThread(function()
if Config.BankBlips then if Config.BankBlips then
for _, v in pairs(Config.BankLocations) do for _, v in pairs(Config.BankLocations) do
for _, b in pairs(v) do for _, b in pairs(v) do
blip = AddBlipForCoord(b) makeBlip({coords = b, sprite = 108, col = 2, scale = 0.55, disp = 6, name = "Bank" })
SetBlipSprite(blip, 108)
SetBlipDisplay(blip, 4)
SetBlipScale(blip, 0.55)
SetBlipColour(blip, 2)
SetBlipAsShortRange(blip, true)
BeginTextCommandSetBlipName("STRING")
AddTextComponentString("Bank")
EndTextCommandSetBlipName(blip)
break break
end end
end end
@@ -78,7 +39,7 @@ CreateThread(function()
if QBCore.Shared.Jobs[tostring(k)] then if QBCore.Shared.Jobs[tostring(k)] then
for l 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)] 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
else bossroles[tostring(k)] = tonumber(l) else bossroles[tostring(k)] = tonumber(l)
end end
@@ -91,7 +52,7 @@ CreateThread(function()
for l 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)] then
if gangroles[tostring(k)] > tonumber(l) then gangroles[tostring(k)] = tonumber(l) end if gangroles[tostring(k)] > tonumber(l) then gangroles[tostring(k)] = tonumber(l) end
else gangroles[tostring(k)] = tonumber(l) else gangroles[tostring(k)] = tonumber(l)
end end
@@ -105,14 +66,14 @@ CreateThread(function()
exports['qb-target']:AddTargetModel(Config.ATMModels, { options = { { event = "jim-payments:Client:ATM:use", icon = "fas fa-money-check-alt", label = "Use ATM", id = "atm" },}, distance = 1.5, }) exports['qb-target']:AddTargetModel(Config.ATMModels, { options = { { event = "jim-payments:Client:ATM:use", icon = "fas fa-money-check-alt", label = "Use ATM", id = "atm" },}, distance = 1.5, })
for k,v in pairs(Config.WallATMLocations) do for k,v in pairs(Config.WallATMLocations) do
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(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" }, { 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(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" }, { 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 })
@@ -122,7 +83,7 @@ CreateThread(function()
for k,v in pairs(Config.BankLocations) do for k,v in pairs(Config.BankLocations) do
for l, b in pairs(v) do for l, b in pairs(v) do
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(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" }, { 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" },
@@ -135,10 +96,8 @@ CreateThread(function()
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]) if not Config.Gabz then CreateModelHide(b.xyz, 1.0, `v_corp_bk_chair3`, true) end
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 not Peds["jimbank"..k..l] then Peds["jimbank"..k..l] = makePed(Config.PedPool[i], b, 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("^5Debug^7: ^6Ped ^2Created for location^7: '^6"..k..l.."^7'") end
end end
end end
end end
@@ -147,9 +106,7 @@ end)
local function PlayATMAnimation(animation) local function PlayATMAnimation(animation)
if animation == 'enter' then if animation == 'enter' then
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')
end end
if animation == 'exit' then if animation == 'exit' then
loadAnimDict('amb@prop_human_atm@male@exit') loadAnimDict('amb@prop_human_atm@male@exit')
@@ -162,7 +119,6 @@ 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 cancelled = false
if not Config.Manage then if not Config.Manage then
local p = promise.new() local p = promise.new()
QBCore.Functions.TriggerCallback('qb-bossmenu:server:GetAccount', function(cb) p:resolve(cb) end, PlayerJob.name) info.society = Citizen.Await(p) QBCore.Functions.TriggerCallback('qb-bossmenu:server:GetAccount', function(cb) p:resolve(cb) end, PlayerJob.name) info.society = Citizen.Await(p)
@@ -170,6 +126,7 @@ RegisterNetEvent('jim-payments:Client:ATM:use', function(data)
QBCore.Functions.TriggerCallback('qb-gangmenu:server:GetAccount', function(cb) p2:resolve(cb) end, PlayerGang.name) info.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 bartext = ""
local setoptions = {} local setoptions = {}
if data.id == "atm" then if data.id == "atm" then
@@ -179,21 +136,11 @@ RegisterNetEvent('jim-payments:Client:ATM:use', function(data)
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() if IsObjectNearPoint(v, GetEntityCoords(PlayerPedId()), 1.6) then
local playerCoords = GetEntityCoords(playerPed, true) local obj = GetClosestObjectOfType(GetEntityCoords(PlayerPedId()), 1.6, v, false, false, false)
local hash = GetHashKey(v) local atmCoords = GetEntityCoords(obj)
local atm = IsObjectNearPoint(hash, playerCoords.x, playerCoords.y, playerCoords.z, 1.6) lookEnt(obj)
if atm then bartext = "Accessing ATM"
local obj = GetClosestObjectOfType(playerCoords.x, playerCoords.y, playerCoords.z, 1.6, v, false, false, false)
local atmCoords = GetEntityCoords(obj, false)
TaskTurnPedToFaceEntity(playerPed, obj, 1000)
Wait(1000)
PlayATMAnimation('enter')
QBCore.Functions.Progressbar("accessing_atm", "Accessing ATM", atmbartime, false, true, { disableMovement = false, disableCarMovement = false, disableMouse = false, disableCombat = false, }, {}, {}, {}, function() -- Done
end, function()
TriggerEvent("QBCore:Notify", "Cancelled!", "error")
cancelled = true
end, data.icon)
end end
end end
@@ -203,12 +150,7 @@ RegisterNetEvent('jim-payments:Client:ATM:use', function(data)
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') bartext = "Accessing Bank"
QBCore.Functions.Progressbar("accessing_atm", "Accessing Bank", atmbartime, false, true, { disableMovement = false, disableCarMovement = false, disableMouse = false, disableCombat = false, }, {}, {}, {}, function() -- Done
end, function()
TriggerEvent("QBCore:Notify", "Cancelled!", "error")
cancelled = true
end, data.icon)
elseif data.id == "transfer" then elseif data.id == "transfer" then
setoptions = { { value = "transfer", text = "Transfer" } } setoptions = { { value = "transfer", text = "Transfer" } }
@@ -217,13 +159,8 @@ RegisterNetEvent('jim-payments:Client:ATM:use', function(data)
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')
QBCore.Functions.Progressbar("accessing_atm", "Accessing Transfers", atmbartime, false, true, { disableMovement = false, disableCarMovement = false, disableMouse = false, disableCombat = false, }, {}, {}, {}, function() -- Done bartext = "Accessing Transfers"
end, function()
TriggerEvent("QBCore:Notify", "Cancelled!", "error")
cancelled = true
end, data.icon)
elseif data.id == "savings" then elseif data.id == "savings" then
setoptions = { { value = "withdraw", text = "Withdrawl" }, { value = "deposit", text = "Deposit" } } setoptions = { { value = "withdraw", text = "Withdrawl" }, { value = "deposit", text = "Deposit" } }
@@ -231,13 +168,7 @@ RegisterNetEvent('jim-payments:Client:ATM:use', function(data)
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') bartext = "Accessing Savings"
QBCore.Functions.Progressbar("accessing_atm", "Accessing Savings", atmbartime, false, true, { disableMovement = false, disableCarMovement = false, disableMouse = false, disableCombat = false, }, {}, {}, {}, function() -- Done
end, function()
TriggerEvent("QBCore:Notify", "Cancelled!", "error")
cancelled = true
end, data.icon)
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" } }
@@ -250,13 +181,8 @@ RegisterNetEvent('jim-payments:Client:ATM:use', function(data)
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') bartext = "Accessing Society Account"
QBCore.Functions.Progressbar("accessing_atm", "Accessing Society Account", atmbartime, false, true, { disableMovement = false, disableCarMovement = false, disableMouse = false, disableCombat = false, }, {}, {}, {}, function() -- Done
end, function()
TriggerEvent("QBCore:Notify", "Cancelled!", "error")
cancelled = true
end, data.icon)
elseif data.id == "societytransfer" then elseif data.id == "societytransfer" then
setoptions = { { value = "transfer", text = "Transfer" } } setoptions = { { value = "transfer", text = "Transfer" } }
@@ -265,12 +191,8 @@ RegisterNetEvent('jim-payments:Client:ATM:use', function(data)
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') bartext = "Accessing Society Transfers"
QBCore.Functions.Progressbar("accessing_atm", "Accessing Transfers", atmbartime, false, true, { disableMovement = false, disableCarMovement = false, disableMouse = false, disableCombat = false, }, {}, {}, {}, function() -- Done
end, function()
TriggerEvent("QBCore:Notify", "Cancelled!", "error")
cancelled = true
end, data.icon)
elseif data.id == "gang" then elseif data.id == "gang" then
setheader = "🏢 Society Banking 🏢" setheader = "🏢 Society Banking 🏢"
@@ -278,13 +200,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" } }
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') bartext = "Accessing Gang Society Account"
QBCore.Functions.Progressbar("accessing_atm", "Accessing Society Account", atmbartime, false, true, { disableMovement = false, disableCarMovement = false, disableMouse = false, disableCombat = false, }, {}, {}, {}, function() -- Done
end, function()
TriggerEvent("QBCore:Notify", "Cancelled!", "error")
cancelled = true
end, data.icon)
elseif data.id == "gangtransfer" then elseif data.id == "gangtransfer" then
setoptions = { { value = "transfer", text = "Transfer" } } setoptions = { { value = "transfer", text = "Transfer" } }
@@ -293,29 +210,27 @@ RegisterNetEvent('jim-payments:Client:ATM:use', function(data)
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') bartext = "Accessing Gang Transfers"
QBCore.Functions.Progressbar("accessing_atm", "Accessing Transfers", atmbartime, false, true, { disableMovement = false, disableCarMovement = false, disableMouse = false, disableCombat = false, }, {}, {}, {}, function() -- Done
end, function()
TriggerEvent("QBCore:Notify", "Cancelled!", "error")
cancelled = true
end, data.icon)
end end
Wait(atmbartime+500) loadAnimDict('amb@prop_human_atm@male@enter')
if not cancelled then TaskPlayAnim(PlayerPedId(), 'amb@prop_human_atm@male@enter', "enter", 1.0,-1.0, 1500, 1, 1, true, true, true)
cancelled = false 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 }) local dialog = exports['qb-input']:ShowInput({ header = setheader, txt = "test", submitText = "Transfer", inputs = setinputs })
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) 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) TriggerServerEvent('jim-payments:server:ATM:use', dialog.amount, dialog.billtype, dialog.account, data.id, info.society, info.gsociety)
end end
end end, function() triggerNotify(nil, "Cancelled!", "error")
end, data.icon)
end) end)
RegisterNetEvent('jim-payments:client:ATM:give', function() RegisterNetEvent('jim-payments:client:ATM:give', function()
local onlineList = {} local onlineList = {}
local nearbyList = {} local nearbyList = {}
@@ -331,7 +246,7 @@ RegisterNetEvent('jim-payments:client:ATM:give', function()
end end
dist = nil dist = nil
end end
if not nearbyList[1] then TriggerEvent("QBCore:Notify", "No one near by to charge", "error") return end if not nearbyList[1] then triggerNotify(nil, "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 },
@@ -344,7 +259,7 @@ RegisterNetEvent('jim-payments:client:ATM:give', function()
end) end)
end) end)
AddEventHandler('onResourceStop', function(resource) if resource ~= GetCurrentResourceName() then return 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(Targets) do exports['qb-target']:RemoveZone(k) end
for k in pairs(Peds) do unloadModel(GetEntityModel(Peds[k])) DeletePed(Peds[k]) end for k in pairs(Peds) do unloadModel(GetEntityModel(Peds[k])) DeletePed(Peds[k]) end
end) end)

View File

@@ -1,4 +1,5 @@
local QBCore = exports['qb-core']:GetCoreObject() local QBCore = exports['qb-core']:GetCoreObject()
RegisterNetEvent('QBCore:Client:UpdateObject', function() QBCore = exports['qb-core']:GetCoreObject() end)
PlayerJob = {} PlayerJob = {}
PlayerGang = {} PlayerGang = {}
@@ -6,7 +7,7 @@ PlayerGang = {}
local onDuty = false local onDuty = false
local BankPed = nil local BankPed = nil
local Targets = {} local Targets = {}
local till = {} 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)
@@ -22,9 +23,6 @@ AddEventHandler('onResourceStart', function(resource) if GetCurrentResourceName(
end) end)
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("^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
@@ -38,26 +36,22 @@ CreateThread(function()
distance = 2.0 }) distance = 2.0 })
--Crete Ped at the location --Crete Ped at the location
if Config.Peds then if Config.Peds then
local i = math.random(1, #Config.PedPool)
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 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 BankPed = makePed(Config.PedPool[math.random(1, #Config.PedPool)], Config.CashInLocation, false, false)
if Config.Debug then print("^5Debug^7: ^6Ped ^2Created for location^7: '^6Ticket Trade^7'") end
end end
--Spawn Custom Cash Register Targets --Spawn Custom Cash Register Targets
for k, v in pairs(Config.CustomCashRegisters) do for k, v in pairs(Config.CustomCashRegisters) do
for i = 1, #v 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] = 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 }, 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 = "" }, }, { options = { { event = "jim-payments:client:Charge", icon = "fas fa-credit-card", label = "Charge Customer", job = job, gang = gang, img = "" }, },
distance = 2.0 distance = 2.0 })
})
if v[i].prop then if v[i].prop then
loadModel(`prop_till_03`) Till[#Till+1] = makeProp({prop = `prop_till_03`, coords = v[i].coords}, 1, false)
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
@@ -65,7 +59,7 @@ end)
RegisterNetEvent('jim-payments:client:Charge', function(data, outside) RegisterNetEvent('jim-payments:client:Charge', function(data, outside)
--Check if player is using /cashregister command --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 if not outside and not onDuty and data.gang == nil then triggerNotify(nil, "Not Clocked in!", "error") return end
local newinputs = {} -- Begin qb-input creation here. local newinputs = {} -- Begin qb-input creation here.
if Config.List then -- If nearby player list is wanted: if Config.List then -- If nearby player list is wanted:
--Retrieve a list of nearby players from server --Retrieve a list of nearby players from server
@@ -84,7 +78,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[1] then TriggerEvent("QBCore:Notify", "No one near by to charge", "error") return end if not nearbyList[1] then triggerNotify(nil, "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 #' }
@@ -109,7 +103,7 @@ RegisterNetEvent('jim-payments:client:PolCharge', function()
--Check if player is allowed to use /cashregister command --Check if player is allowed to use /cashregister command
local allowed = false local allowed = false
for k in pairs(Config.FineJobs) do if k == PlayerJob.name then allowed = true end end 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 if not allowed then triggerNotify(nil, "You don't have the required job", "error") return end
local newinputs = {} -- Begin qb-input creation here. local newinputs = {} -- Begin qb-input creation here.
if Config.FineJobList then -- If nearby player list is wanted: if Config.FineJobList then -- If nearby player list is wanted:
@@ -129,7 +123,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[1] then TriggerEvent("QBCore:Notify", "No one near by to charge", "error") return end if not nearbyList[1] then triggerNotify(nil, "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 #" }
@@ -146,12 +140,11 @@ RegisterNetEvent('jim-payments:client:PolCharge', function()
end end
end) end)
RegisterNetEvent('jim-payments:Tickets:Menu', function(data) RegisterNetEvent('jim-payments:Tickets:Menu', function(data)
--Get ticket info --Get ticket info
local p = promise.new() QBCore.Functions.TriggerCallback('jim-payments:Ticket:Count', function(cb) p:resolve(cb) end) local p = promise.new() QBCore.Functions.TriggerCallback('jim-payments:Ticket:Count', function(cb) p:resolve(cb) end)
local amount = Citizen.Await(p) local amount = Citizen.Await(p)
if amount == 0 then TriggerEvent("QBCore:Notify", "You don't have any tickets to trade", "error") return end if not amount then triggerNotify(nil, "You don't have any tickets to trade", "error") amount = 0 return end
local sellable = false local sellable = false
local name = "" local label = "" local name = "" local label = ""
--Check/adjust for job/gang names --Check/adjust for job/gang names
@@ -190,8 +183,8 @@ end)
RegisterNetEvent('jim-payments:Tickets:Sell:yes', function() TriggerServerEvent('jim-payments:Tickets:Sell') end) RegisterNetEvent('jim-payments:Tickets:Sell:yes', function() TriggerServerEvent('jim-payments:Tickets:Sell') end)
RegisterNetEvent('jim-payments:Tickets:Sell:no', function() exports['qb-menu']:closeMenu() end) RegisterNetEvent('jim-payments:Tickets:Sell:no', function() exports['qb-menu']:closeMenu() end)
AddEventHandler('onResourceStop', function(resource) if resource ~= GetCurrentResourceName() then return 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(Targets) do exports['qb-target']:RemoveZone(k) end
for i = 1, #till do DeleteEntity(till[i]) end for i = 1, #Till do DeleteEntity(Till[i]) end
unloadModel(GetEntityModel(BankPed)) DeletePed(BankPed) unloadModel(GetEntityModel(BankPed)) DeletePed(BankPed)
end) end)

View File

@@ -5,8 +5,8 @@ print("^2Jim^7-^2Payments v^42^7.^47 ^7- ^2Payments Script by ^1Jimathy^7")
-- https://discord.gg/xKgQZ6wZvS -- https://discord.gg/xKgQZ6wZvS
Config = { Config = {
Debug = false, Debug = true,
Notify = "qb",
--------------------------------- ---------------------------------
-- Default Job Payment Systems -- -- Default Job Payment Systems --
--------------------------------- ---------------------------------
@@ -14,7 +14,7 @@ Config = {
-- "false" if using qb-bossmenu -- "false" if using qb-bossmenu
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 = {
@@ -95,10 +95,10 @@ Config = {
BankBlips = false, -- Enable this if you disabled qb-banking and need bank locations 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 ATMBlips = false, -- Enable this if you are a pyscho and need every ATM to be on the map too
Gabz = false, -- "true" to enable Gabz Bank locations Gabz = true, -- "true" to enable Gabz Bank locations
-- this corrects the ATM/Bank Cashier + Ticket Cash in location -- this corrects the ATM/Bank Cashier + Ticket Cash in location
ATMModels = { "prop_atm_01", "prop_atm_02", "prop_atm_03", "prop_fleeca_atm" }, 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),

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

@@ -1,4 +1,5 @@
local QBCore = exports['qb-core']:GetCoreObject() local QBCore = exports['qb-core']:GetCoreObject()
RegisterNetEvent('QBCore:Server:UpdateObject', function() if source ~= '' then return false end QBCore = exports['qb-core']:GetCoreObject() end)
local function cv(amount) local function cv(amount)
local formatted = amount local formatted = amount
@@ -21,18 +22,18 @@ RegisterServerEvent('jim-payments:server:ATM:use', function(amount, billtype, ba
--Simple transfers from bank to wallet -- --Simple transfers from bank to wallet --
if account == "bank" or account == "atm" then if account == "bank" or account == "atm" then
if billtype == "withdraw" then if billtype == "withdraw" then
if bankB < amount then TriggerClientEvent("QBCore:Notify", src, "Bank Balance too low", "error") if bankB < amount then triggerNotify(nil, "Bank Balance too low", "error", src)
elseif bankB >= tonumber(amount) then 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 triggerNotify(nil, "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.RemoveMoney('bank', amount) Wait(1500)
Player.Functions.AddMoney('cash', amount) Player.Functions.AddMoney('cash', amount)
end end
elseif billtype == "deposit" then elseif billtype == "deposit" then
if cashB < amount then TriggerClientEvent("QBCore:Notify", src, "Not enough cash", "error") if cashB < amount then triggerNotify(nil, "Not enough cash", "error", src)
elseif cashB >= amount then elseif cashB >= amount then
Player.Functions.RemoveMoney('cash', amount) Wait(1500) Player.Functions.RemoveMoney('cash', amount) Wait(1500)
Player.Functions.AddMoney('bank', amount) Player.Functions.AddMoney('bank', amount)
TriggerClientEvent("QBCore:Notify", src, "Deposited $"..cv(amount).." into the Bank", "success") triggerNotify(nil, "Deposited $"..cv(amount).." into the Bank", "success", src)
end end
end end
-- Transfers from bank to savings account -- -- Transfers from bank to savings account --
@@ -44,41 +45,41 @@ RegisterServerEvent('jim-payments:server:ATM:use', function(amount, billtype, ba
if savbal >= amount then if savbal >= amount then
savbal = savbal - amount savbal = savbal - amount
Player.Functions.AddMoney('bank', amount) Player.Functions.AddMoney('bank', amount)
TriggerClientEvent("QBCore:Notify", src, "$"..cv(amount).." Withdrawn from savings into bank account", "success") triggerNotify(nil, "$"..cv(amount).." Withdrawn from savings into bank account", "success", src)
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
end) end)
elseif savbal < amount then elseif savbal < amount then
TriggerClientEvent("QBCore:Notify", src, "Savings Balance too low", "error") triggerNotify(nil, "Savings Balance too low", "error")
end end
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") triggerNotify(nil, "$"..cv(amount).." Deposited from bank account into savings", "success", src)
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
end) end)
else TriggerClientEvent("QBCore:Notify", src, "Bank Balance too low", "error") else triggerNotify(nil, "Bank Balance too low", "error", src)
end end
end end
--Simple transfers from society account to bank -- --Simple transfers from society account to bank --
elseif account == "society" then elseif account == "society" then
if billtype == "withdraw" then if billtype == "withdraw" then
if tonumber(society) < amount then TriggerClientEvent("QBCore:Notify", src, "Society balance too low", "error") if tonumber(society) < amount then triggerNotify(nil, "Society balance too low", "error", src)
elseif tonumber(society) >= amount then elseif tonumber(society) >= amount then
TriggerClientEvent("QBCore:Notify", src, "Withdrew $"..cv(amount).." from the "..Player.PlayerData.job.label.." account", "success") triggerNotify(nil, "Withdrew $"..cv(amount).." from the "..Player.PlayerData.job.label.." account", "success", src)
Player.Functions.AddMoney('bank', amount) Player.Functions.AddMoney('bank', amount)
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
end end
elseif billtype == "deposit" then elseif billtype == "deposit" then
if bankB < amount then TriggerClientEvent("QBCore:Notify", src, "Not enough money in your bank", "error") if bankB < amount then triggerNotify(nil, "Not enough money in your bank", "error", src)
elseif bankB >= amount then elseif bankB >= amount then
if Config.Manage then exports["qb-management"]:AddMoney(tostring(Player.PlayerData.job.name), amount) 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 else TriggerEvent("qb-bossmenu:server:addAccountMoney", tostring(Player.PlayerData.job.name), amount) end
Player.Functions.RemoveMoney('bank', amount) Wait(1500) Player.Functions.RemoveMoney('bank', amount) Wait(1500)
TriggerClientEvent("QBCore:Notify", src, "Deposited $"..cv(amount).." into the "..Player.PlayerData.job.label.." account", "success") triggerNotify(nil, "Deposited $"..cv(amount).." into the "..Player.PlayerData.job.label.." account", "success", src)
end end
end end
-- Transfer from boss account to players -- -- Transfer from boss account to players --
@@ -86,7 +87,7 @@ RegisterServerEvent('jim-payments:server:ATM:use', function(amount, billtype, ba
local bannedCharacters = {'%','$',';'} local bannedCharacters = {'%','$',';'}
local newAmount = tostring(amount) local newAmount = tostring(amount)
local newiban = tostring(baccount) local newiban = tostring(baccount)
for k, v in pairs(bannedCharacters) do for _, v in pairs(bannedCharacters) do
newAmount = string.gsub(newAmount, '%' .. v, '') newAmount = string.gsub(newAmount, '%' .. v, '')
newiban = string.gsub(newiban, '%' .. v, '') newiban = string.gsub(newiban, '%' .. v, '')
end end
@@ -103,34 +104,34 @@ RegisterServerEvent('jim-payments:server:ATM:use', function(amount, billtype, ba
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 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") triggerNotify(nil, "Sent $"..amount.." to "..Reciever.PlayerData.charinfo.firstname.." "..Reciever.PlayerData.charinfo.lastname, "success", src)
TriggerClientEvent("QBCore:Notify", Reciever.PlayerData.source, "Recieved $"..cv(amount).." from "..tostring(Player.PlayerData.job.label).." account", "success") triggerNotify(nil, "Recieved $"..cv(amount).." from "..tostring(Player.PlayerData.job.label).." account", "success", Reciever.PlayerData.source)
else else
local RecieverMoney = json.decode(result[1].money) local RecieverMoney = json.decode(result[1].money)
RecieverMoney.bank = (RecieverMoney.bank + amount) RecieverMoney.bank = (RecieverMoney.bank + amount)
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 not result[1] then TriggerClientEvent("QBCore:Notify", src, "Error: Account '"..baccount.."' not found", "error") elseif not result[1] then triggerNotify(nil, "Error: Account '"..baccount.."' not found", "error", src)
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
if tonumber(gsociety) < amount then TriggerClientEvent("QBCore:Notify", src, "Society balance too low", "error") if tonumber(gsociety) < amount then triggerNotify(nil, "Society balance too low", "error", src)
elseif tonumber(gsociety) >= amount then elseif tonumber(gsociety) >= amount then
TriggerClientEvent("QBCore:Notify", src, "Withdrew $"..cv(amount).." from the "..Player.PlayerData.gang.label.." account", "success") triggerNotify(nil, "Withdrew $"..cv(amount).." from the "..Player.PlayerData.gang.label.." account", "success", src)
Player.Functions.AddMoney('bank', amount) Player.Functions.AddMoney('bank', amount)
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-gangmenu:server:removeAccountMoney", tostring(Player.PlayerData.gang.name), amount) end else TriggerEvent("qb-gangmenu:server:removeAccountMoney", tostring(Player.PlayerData.gang.name), amount) end
end end
elseif billtype == "deposit" then elseif billtype == "deposit" then
if bankB < amount then TriggerClientEvent("QBCore:Notify", src, "Not enough money in your bank", "error") if bankB < amount then triggerNotify(nil, "Not enough money in your bank", "error", src)
elseif bankB >= amount then elseif bankB >= amount then
if Config.Manage then exports["qb-management"]:AddGangMoney(tostring(Player.PlayerData.gang.name), amount) 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 else TriggerEvent("qb-gangmenu:server:addAccountMoney", tostring(Player.PlayerData.gang.name), amount) end
Player.Functions.RemoveMoney('bank', amount) Wait(1500) Player.Functions.RemoveMoney('bank', amount) Wait(1500)
TriggerClientEvent("QBCore:Notify", src, "Deposited $"..cv(amount).." into the "..Player.PlayerData.gang.label.." account", "success") triggerNotify(nil, "Deposited $"..cv(amount).." into the "..Player.PlayerData.gang.label.." account", "success", src)
end end
end end
-- Transfer from gang account to players -- -- Transfer from gang account to players --
@@ -138,7 +139,7 @@ RegisterServerEvent('jim-payments:server:ATM:use', function(amount, billtype, ba
local bannedCharacters = {'%','$',';'} local bannedCharacters = {'%','$',';'}
local newAmount = tostring(amount) local newAmount = tostring(amount)
local newiban = tostring(baccount) local newiban = tostring(baccount)
for k, v in pairs(bannedCharacters) do for _, v in pairs(bannedCharacters) do
newAmount = string.gsub(newAmount, '%' .. v, '') newAmount = string.gsub(newAmount, '%' .. v, '')
newiban = string.gsub(newiban, '%' .. v, '') newiban = string.gsub(newiban, '%' .. v, '')
end end
@@ -155,24 +156,23 @@ RegisterServerEvent('jim-payments:server:ATM:use', function(amount, billtype, ba
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 not Reciever 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") triggerNotify(nil, "Sent $"..amount.." to "..Reciever.PlayerData.charinfo.firstname.." "..Reciever.PlayerData.charinfo.lastname, "success", src)
TriggerClientEvent("QBCore:Notify", Reciever.PlayerData.source, "Recieved $"..cv(amount).." from "..tostring(Player.PlayerData.gang.label).." account", "success") triggerNotify(nil, Reciever.PlayerData.source, "Recieved $"..cv(amount).." from "..tostring(Player.PlayerData.gang.label).." account", "success", Reciever.PlayerData.source)
else else
local RecieverMoney = json.decode(result[1].money) local RecieverMoney = json.decode(result[1].money)
RecieverMoney.bank = (RecieverMoney.bank + amount) RecieverMoney.bank = (RecieverMoney.bank + amount)
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 not result[1] then TriggerClientEvent("QBCore:Notify", src, "Error: Account '"..baccount.."' not found", "error") elseif not result[1] then triggerNotify(nil, "Error: Account '"..baccount.."' not found", "error", src)
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)
for k, v in pairs(bannedCharacters) do for _, v in pairs(bannedCharacters) do
newAmount = string.gsub(newAmount, '%' .. v, '') newAmount = string.gsub(newAmount, '%' .. v, '')
newiban = string.gsub(newiban, '%' .. v, '') newiban = string.gsub(newiban, '%' .. v, '')
end end
@@ -188,14 +188,14 @@ RegisterServerEvent('jim-payments:server:ATM:use', function(amount, billtype, ba
Player.Functions.RemoveMoney('bank', amount) Player.Functions.RemoveMoney('bank', amount)
if Reciever 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") triggerNotify(nil, "Sent $"..cv(amount).." to "..Reciever.PlayerData.charinfo.firstname.." "..Reciever.PlayerData.charinfo.lastname, "success", src)
TriggerClientEvent("QBCore:Notify", Reciever.PlayerData.source, "Recieved $"..cv(amount).." from "..Player.PlayerData.charinfo.firstname.." "..Player.PlayerData.charinfo.lastname, "success") triggerNotify(nil, "Recieved $"..cv(amount).." from "..Player.PlayerData.charinfo.firstname.." "..Player.PlayerData.charinfo.lastname, "success", Reciever.PlayerData.source)
else else
local RecieverMoney = json.decode(result[1].money) local RecieverMoney = json.decode(result[1].money)
RecieverMoney.bank = (RecieverMoney.bank + amount) RecieverMoney.bank = (RecieverMoney.bank + amount)
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 not result[1] then TriggerClientEvent("QBCore:Notify", src, "Error: Account '"..baccount.."' not found", "error") elseif not result[1] then triggerNotify(nil, "Error: Account '"..baccount.."' not found", "error", src)
end end
end end
@@ -215,11 +215,11 @@ QBCore.Functions.CreateCallback('jim-payments:ATM:Find', function(source, cb)
-- If qb-management, grab info directly from database -- If qb-management, grab info directly from database
if Config.Manage then if Config.Manage then
local result = MySQL.Sync.fetchAll('SELECT * FROM management_funds') local result = MySQL.Sync.fetchAll('SELECT * FROM management_funds')
for k, v in pairs(result) do for _, v in pairs(result) do
if Player.PlayerData.job.name == v.job_name then society = v.amount end if Player.PlayerData.job.name == v.job_name then society = v.amount end
end end
if Player.PlayerData.gang.name ~= "none" then if Player.PlayerData.gang.name ~= "none" then
for k, v in pairs(result) do for _, v in pairs(result) do
if Player.PlayerData.gang.name == v.job_name then gsociety = v.amount end if Player.PlayerData.gang.name == v.job_name then gsociety = v.amount end
end end
end end
@@ -259,11 +259,11 @@ RegisterServerEvent("jim-payments:server:ATM:give", function(citizen, price)
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)
TriggerClientEvent("QBCore:Notify", source, "You gave "..Reciever.PlayerData.charinfo.firstname.." $"..cv(amount), "success") triggerNotify(nil, "You gave "..Reciever.PlayerData.charinfo.firstname.." $"..cv(amount), "success", source)
Reciever.Functions.AddMoney('cash', amount) Reciever.Functions.AddMoney('cash', amount)
TriggerClientEvent("QBCore:Notify", tonumber(citizen), "You got $"..cv(amount).." from "..Player.PlayerData.charinfo.firstname, "success") triggerNotify(nil, "You got $"..cv(amount).." from "..Player.PlayerData.charinfo.firstname, "success", tonumber(citizen))
elseif balance < amount then elseif balance < amount then
TriggerClientEvent("QBCore:Notify", source, "You don't have enough cash to give", "error") triggerNotify(nil, "You don't have enough cash to give", "error", source)
end end
else TriggerClientEvent('QBCore:Notify', source, "You can't give $0", 'error') end else triggerNotify(nil,"You can't give $0", 'error', source) end
end) end)

View File

@@ -1,4 +1,5 @@
local QBCore = exports['qb-core']:GetCoreObject() local QBCore = exports['qb-core']:GetCoreObject()
RegisterNetEvent('QBCore:Server:UpdateObject', function() if source ~= '' then return false end QBCore = exports['qb-core']:GetCoreObject() end)
local function cv(amount) local function cv(amount)
local formatted = amount local formatted = amount
@@ -19,18 +20,19 @@ QBCore.Commands.Add("polcharge", "Charge another person", {}, false, function(so
RegisterServerEvent('jim-payments:Tickets:Give', function(data, biller, gang) 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 local billed = QBCore.Functions.GetPlayer(source) -- This should always be from the person who accepted the payment
local takecomm = math.floor(tonumber(data.amount) * Config.Jobs[data.society].Commission)
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 - takecomm)
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 if Config.Debug then print("^5Debug^7: ^3QB^7-^3Management^7(^3Gang^7): ^2Adding ^7$^6"..data.amount - takecomm.." ^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 - takecomm)
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 if Config.Debug then print("^5Debug^7: ^3QB^7-^3GangMenu^7: ^2Adding ^7$^6"..data.amount - takecomm.." ^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 - takecomm)
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 if Config.Debug then print("^5Debug^7: ^3QB-Management^7(^3Job^7): ^2Adding ^7$^6"..data.amount - takecomm.." ^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 - takecomm)
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 if Config.Debug then print("^5Debug^7: ^3QB-BossMenu^7: ^2Adding ^7$^6"..data.amount - takecomm.." ^2to account ^7'^6"..tostring(biller.PlayerData.job.name - takecomm).."^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
@@ -38,7 +40,7 @@ RegisterServerEvent('jim-payments:Tickets:Give', function(data, biller, gang)
local Player = QBCore.Functions.GetPlayer(v) local Player = QBCore.Functions.GetPlayer(v)
if Player.PlayerData.citizenid == data.senderCitizenId then biller = Player end if Player.PlayerData.citizenid == data.senderCitizenId then biller = Player end
end end
TriggerClientEvent('QBCore:Notify', biller.PlayerData.source, data.sender.." Paid their $"..data.amount.." invoice", "success") triggerNotify(nil, data.sender.." Paid their $"..data.amount.." invoice", "success", biller.PlayerData.source)
end end
local duty = true local duty = true
@@ -53,19 +55,19 @@ RegisterServerEvent('jim-payments:Tickets:Give', function(data, biller, gang)
if Player ~= nil or Player ~= billed then if Player ~= nil or Player ~= billed then
if Player.PlayerData.job.name == data.society and Player.PlayerData.job.onduty then if Player.PlayerData.job.name == data.society and Player.PlayerData.job.onduty then
Player.Functions.AddItem('payticket', 1, false, {["quality"] = nil}) Player.Functions.AddItem('payticket', 1, false, {["quality"] = nil})
TriggerClientEvent('QBCore:Notify', Player.PlayerData.source, 'Receipt received', 'success') triggerNotify(nil, 'Receipt received', 'success', Player.PlayerData.source)
TriggerClientEvent('inventory:client:ItemBox', Player.PlayerData.source, QBCore.Shared.Items['payticket'], "add", 1) TriggerClientEvent('inventory:client:ItemBox', Player.PlayerData.source, QBCore.Shared.Items['payticket'], "add", 1)
end end
end end
if gang then if gang then
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') triggerNotify(nil, 'Receipt received', 'success', biller.PlayerData.source)
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
else 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') triggerNotify(nil, 'Receipt received', 'success', biller.PlayerData.source)
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
@@ -76,9 +78,9 @@ RegisterServerEvent('jim-payments:Tickets:Give', function(data, biller, gang)
if Config.CommissionLimit and data.amount < Config.Jobs[data.society].MinAmountforTicket then return end if Config.CommissionLimit and data.amount < Config.Jobs[data.society].MinAmountforTicket then return end
if Config.CommissionDouble then if Config.CommissionDouble then
biller.Functions.AddMoney("bank", math.floor(tonumber(data.amount) * (comm *2))) 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") triggerNotify(nil, "Recieved $"..math.floor(tonumber(data.amount) * (comm *2)).." in Commission", "success", biller.PlayerData.source)
else biller.Functions.AddMoney("bank", math.floor(tonumber(data.amount) *comm)) 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") triggerNotify(nil, "Recieved $"..math.floor(tonumber(data.amount) * comm).." in Commission", "success", biller.PlayerData.source)
end end
if Config.CommissionAll then if Config.CommissionAll then
for _, v in pairs(QBCore.Functions.GetPlayers()) do for _, v in pairs(QBCore.Functions.GetPlayers()) do
@@ -86,7 +88,7 @@ RegisterServerEvent('jim-payments:Tickets:Give', function(data, biller, gang)
if Player ~= nil and Player ~= biller then if Player ~= nil and Player ~= biller then
if Player.PlayerData.job.name == data.society and Player.PlayerData.job.onduty then if Player.PlayerData.job.name == data.society and Player.PlayerData.job.onduty then
Player.Functions.AddMoney("bank", math.floor(tonumber(data.amount) * comm)) 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") triggerNotify(nil, "Recieved $"..math.floor(tonumber(data.amount) * comm).." in Commission", "success", Player.PlayerData.source)
end end
end end
end end
@@ -96,21 +98,19 @@ end)
RegisterServerEvent('jim-payments:Tickets:Sell', function() RegisterServerEvent('jim-payments:Tickets:Sell', function()
local Player = QBCore.Functions.GetPlayer(source) local Player = QBCore.Functions.GetPlayer(source)
if Player.Functions.GetItemByName("payticket") == nil then TriggerClientEvent('QBCore:Notify', source, "No tickets to trade", 'error') return if Player.Functions.GetItemByName("payticket") then triggerNotify(nil, "No tickets to trade", 'error', source) return
else else
tickets = Player.Functions.GetItemByName("payticket").amount tickets = Player.Functions.GetItemByName("payticket").amount
Player.Functions.RemoveItem('payticket', tickets) Player.Functions.RemoveItem('payticket', tickets)
pay = (tickets * Config.Jobs[Player.PlayerData.job.name].PayPerTicket) pay = (tickets * Config.Jobs[Player.PlayerData.job.name].PayPerTicket)
Player.Functions.AddMoney('bank', pay, 'ticket-payment') Player.Functions.AddMoney('bank', pay, 'ticket-payment')
TriggerClientEvent('inventory:client:ItemBox', source, QBCore.Shared.Items['payticket'], "remove", tickets) TriggerClientEvent('inventory:client:ItemBox', source, QBCore.Shared.Items['payticket'], "remove", tickets)
TriggerClientEvent('QBCore:Notify', source, "Tickets traded: "..tickets.." Total: $"..cv(pay), 'success') triggerNotify(nil, "Tickets traded: "..tickets.." Total: $"..cv(pay), 'success', source)
end end
end) end)
QBCore.Functions.CreateCallback('jim-payments:Ticket:Count', function(source, cb) QBCore.Functions.CreateCallback('jim-payments:Ticket:Count', function(source, cb)
if QBCore.Functions.GetPlayer(source).Functions.GetItemByName('payticket') == nil then amount = 0 cb(QBCore.Functions.GetPlayer(source).Functions.GetItemByName('payticket'))
else amount = QBCore.Functions.GetPlayer(source).Functions.GetItemByName('payticket').amount end
cb(amount)
end) end)
RegisterServerEvent("jim-payments:server:Charge", function(citizen, price, billtype, img, outside, gang) RegisterServerEvent("jim-payments:server:Charge", function(citizen, price, billtype, img, outside, gang)
@@ -121,8 +121,8 @@ RegisterServerEvent("jim-payments:server:Charge", function(citizen, price, billt
local balance = billed.Functions.GetMoney(billtype) local balance = billed.Functions.GetMoney(billtype)
if amount and amount > 0 then if amount and amount > 0 then
if balance < amount then if balance < amount then
TriggerClientEvent("QBCore:Notify", src, "Customer doesn't have enough cash to pay", "error") triggerNotify(nil, "Customer doesn't have enough cash to pay", "error", src)
TriggerClientEvent("QBCore:Notify", tonumber(citizen), "You don't have enough cash to pay", "error") triggerNotify(nil, "You don't have enough cash to pay", "error", tonumber(citizen))
return return
end end
local label = biller.PlayerData.job.label local label = biller.PlayerData.job.label
@@ -147,10 +147,10 @@ RegisterServerEvent("jim-payments:server:Charge", function(citizen, price, billt
TriggerClientEvent('gksphone:notifi', src, {title = 'Billing', message = 'Invoice Successfully Sent', img= '/html/static/img/icons/logo.png' }) 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' }) TriggerClientEvent('gksphone:notifi', billed.PlayerData.source, {title = 'Billing', message = 'New Invoice Recieved', img= '/html/static/img/icons/logo.png' })
end end
TriggerClientEvent('QBCore:Notify', src, 'Invoice Successfully Sent', 'success') triggerNotify(nil, 'Invoice Successfully Sent', 'success', src)
TriggerClientEvent('QBCore:Notify', billed.PlayerData.source, 'New Invoice Received') triggerNotify(nil, 'New Invoice Received', nil, billed.PlayerData.source)
end end
else TriggerClientEvent('QBCore:Notify', source, "You can't charge $0", 'error') return end else triggerNotify(nil, "You can't charge $0", 'error', source) return end
end) end)
RegisterServerEvent("jim-payments:server:PayPopup", function(data) RegisterServerEvent("jim-payments:server:PayPopup", function(data)
@@ -162,10 +162,10 @@ RegisterServerEvent("jim-payments:server:PayPopup", function(data)
if data.accept == true then if data.accept == true then
billed.Functions.RemoveMoney(tostring(data.billtype), data.amount) billed.Functions.RemoveMoney(tostring(data.billtype), data.amount)
TriggerEvent('jim-payments:Tickets:Give', newdata, biller, data.gang) TriggerEvent('jim-payments:Tickets:Give', newdata, biller, data.gang)
TriggerClientEvent("QBCore:Notify", data.biller, billed.PlayerData.charinfo.firstname.." accepted the $"..data.amount.." payment", "success") triggerNotify(nil, billed.PlayerData.charinfo.firstname.." accepted the $"..data.amount.." payment", "success", data.biller)
elseif data.accept == false then elseif data.accept == false then
TriggerClientEvent("QBCore:Notify", src, "You declined the payment") triggerNotify(nil, "You declined the payment", nil, src)
TriggerClientEvent("QBCore:Notify", data.biller, billed.PlayerData.charinfo.firstname.." declined the $"..data.amount.." payment", "error") triggerNotify(nil, billed.PlayerData.charinfo.firstname.." declined the $"..data.amount.." payment", "error", data.biller)
end end
end) end)
@@ -186,12 +186,12 @@ RegisterServerEvent("jim-payments:server:PolCharge", function(citizen, price)
TriggerEvent("qb-bossmenu:server:addAccountMoney", tostring(biller.PlayerData.job.name), (price - commission)) 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 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 $"..(price - commission), "success") triggerNotify(nil, billed.PlayerData.charinfo.firstname.." was charged for $"..(price - commission), "success", src)
TriggerClientEvent('QBCore:Notify', billed.PlayerData.source, 'You were charged for $'..(price - commission)) triggerNotify(nil, 'You were charged for $'..(price - commission), nil, billed.PlayerData.source)
else else
TriggerClientEvent("jim-payments:client:PolPopup", billed.PlayerData.source, 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 triggerNotify(nil, "You can't charge $0", 'error', source) return end
end) end)
RegisterServerEvent("jim-payments:server:PolPopup", function(data) RegisterServerEvent("jim-payments:server:PolPopup", function(data)
@@ -202,7 +202,7 @@ RegisterServerEvent("jim-payments:server:PolPopup", function(data)
local commission = math.floor(tonumber(data.amount) * Config.FineJobs[biller.PlayerData.job.name].Commission) local commission = math.floor(tonumber(data.amount) * Config.FineJobs[biller.PlayerData.job.name].Commission)
if data.accept == true then 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 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") triggerNotify(nil, billed.PlayerData.charinfo.firstname.." accepted the $"..data.amount.." charge", "success", data.biller)
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 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 if Config.Manage then
exports["qb-management"]:AddMoney(tostring(biller.PlayerData.job.name), data.amount - commission) exports["qb-management"]:AddMoney(tostring(biller.PlayerData.job.name), data.amount - commission)
@@ -212,8 +212,8 @@ RegisterServerEvent("jim-payments:server:PolPopup", function(data)
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 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 end
else else
TriggerClientEvent("QBCore:Notify", src, "You declined the payment") triggerNotify(nil, "You declined the payment", nil, src)
TriggerClientEvent("QBCore:Notify", data.biller, billed.PlayerData.charinfo.firstname.." declined the $"..data.amount.." charge", "error") triggerNotify(nil, billed.PlayerData.charinfo.firstname.." declined the $"..data.amount.." charge", "error", data.biller)
end end
end) end)

121
shared/shared.lua Normal file
View File

@@ -0,0 +1,121 @@
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