mirror of
https://github.com/jimathy/jim-payments.git
synced 2026-08-19 07:16:03 +01:00
Add ability to disable receipts
This commit is contained in:
@@ -6,6 +6,8 @@ print("Jim-Payments v2 - Payments Script by Jimathy")
|
|||||||
|
|
||||||
Config = {}
|
Config = {}
|
||||||
|
|
||||||
|
Config.TicketSystem = true -- Enable this if you want to use the ticket system
|
||||||
|
|
||||||
Config.PaymentRadius = 30 -- This is how far the player list will check
|
Config.PaymentRadius = 30 -- This is how far the player list will check
|
||||||
|
|
||||||
-- MinAmountforTicket should be your cheapest item
|
-- MinAmountforTicket should be your cheapest item
|
||||||
|
|||||||
47
server.lua
47
server.lua
@@ -1,21 +1,35 @@
|
|||||||
local QBCore = exports['qb-core']:GetCoreObject()
|
local QBCore = exports['qb-core']:GetCoreObject()
|
||||||
|
|
||||||
RegisterServerEvent('jim-payments:Tickets:Give')
|
local function cv(amount)
|
||||||
AddEventHandler('jim-payments:Tickets:Give', function(amount, job)
|
local formatted = amount
|
||||||
for k, v in pairs(QBCore.Functions.GetPlayers()) do
|
while true do
|
||||||
local Player = QBCore.Functions.GetPlayer(v)
|
formatted, k = string.gsub(formatted, "^(-?%d+)(%d%d%d)", '%1,%2')
|
||||||
if Player ~= nil then
|
if (k==0) then
|
||||||
if Player.PlayerData.job.name == job and Player.PlayerData.job.onduty then
|
break
|
||||||
if amount >= Config.Jobs[job].MinAmountforTicket then
|
|
||||||
Player.Functions.AddItem('payticket', 1, false, {["quality"] = nil})
|
|
||||||
TriggerClientEvent('QBCore:Notify', Player.PlayerData.source, 'Receipt received', 'success')
|
|
||||||
TriggerClientEvent('inventory:client:ItemBox', Player.PlayerData.source, QBCore.Shared.Items['payticket'], "add", 1)
|
|
||||||
elseif amount < Config.Jobs[job].MinAmountforTicket then
|
|
||||||
TriggerClientEvent("QBCore:Notify", Player.PlayerData.source, "Amount too low, didn't receive a receipt", "error")
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
return formatted
|
||||||
|
end
|
||||||
|
|
||||||
|
QBCore.Commands.Add("cashregister", "Use mobile cash register", {}, false, function(source) TriggerClientEvent("jim-payments:client:Charge", source, true) end)
|
||||||
|
|
||||||
|
RegisterServerEvent('jim-payments:Tickets:Give', function(amount, job)
|
||||||
|
if Config.TicketSystem then
|
||||||
|
for k, v in pairs(QBCore.Functions.GetPlayers()) do
|
||||||
|
local Player = QBCore.Functions.GetPlayer(v)
|
||||||
|
if Player ~= nil then
|
||||||
|
if Player.PlayerData.job.name == job and Player.PlayerData.job.onduty then
|
||||||
|
if amount >= Config.Jobs[job].MinAmountforTicket then
|
||||||
|
Player.Functions.AddItem('payticket', 1, false, {["quality"] = nil})
|
||||||
|
TriggerClientEvent('QBCore:Notify', Player.PlayerData.source, 'Receipt received', 'success')
|
||||||
|
TriggerClientEvent('inventory:client:ItemBox', Player.PlayerData.source, QBCore.Shared.Items['payticket'], "add", 1)
|
||||||
|
elseif amount < Config.Jobs[job].MinAmountforTicket then
|
||||||
|
TriggerClientEvent("QBCore:Notify", Player.PlayerData.source, "Amount too low, didn't receive a receipt", "error")
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
end)
|
end)
|
||||||
|
|
||||||
RegisterServerEvent('jim-payments:Tickets:Sell', function()
|
RegisterServerEvent('jim-payments:Tickets:Sell', function()
|
||||||
@@ -27,7 +41,7 @@ RegisterServerEvent('jim-payments:Tickets:Sell', function()
|
|||||||
pay = (tickets * Config.Jobs[Player.PlayerData.job.name].PayPerTicket)
|
pay = (tickets * Config.Jobs[Player.PlayerData.job.name].PayPerTicket)
|
||||||
Player.Functions.AddMoney('bank', pay, 'ticket-payment')
|
Player.Functions.AddMoney('bank', pay, 'ticket-payment')
|
||||||
TriggerClientEvent('inventory:client:ItemBox', source, QBCore.Shared.Items['payticket'], "remove", tickets)
|
TriggerClientEvent('inventory:client:ItemBox', source, QBCore.Shared.Items['payticket'], "remove", tickets)
|
||||||
TriggerClientEvent('QBCore:Notify', source, "Tickets traded: "..tickets.." Total: $"..pay, 'success')
|
TriggerClientEvent('QBCore:Notify', source, "Tickets traded: "..tickets.." Total: $"..cv(pay), 'success')
|
||||||
end
|
end
|
||||||
end)
|
end)
|
||||||
|
|
||||||
@@ -41,7 +55,6 @@ RegisterServerEvent("jim-payments:server:Charge", function(citizen, price, billt
|
|||||||
local biller = QBCore.Functions.GetPlayer(source)
|
local biller = QBCore.Functions.GetPlayer(source)
|
||||||
local billed = QBCore.Functions.GetPlayer(tonumber(citizen))
|
local billed = QBCore.Functions.GetPlayer(tonumber(citizen))
|
||||||
local amount = tonumber(price)
|
local amount = tonumber(price)
|
||||||
local billtype = string.lower(tostring(billtype))
|
|
||||||
|
|
||||||
if amount and amount > 0 then
|
if amount and amount > 0 then
|
||||||
if billtype == "cash" then balance = billed.Functions.GetMoney(billtype)
|
if billtype == "cash" then balance = billed.Functions.GetMoney(billtype)
|
||||||
@@ -71,4 +84,4 @@ QBCore.Functions.CreateCallback('jim-payments:MakePlayerList', function(source,
|
|||||||
onlineList[#onlineList+1] = { value = tonumber(v), text = "["..v.."] - "..P.PlayerData.charinfo.firstname..' '..P.PlayerData.charinfo.lastname }
|
onlineList[#onlineList+1] = { value = tonumber(v), text = "["..v.."] - "..P.PlayerData.charinfo.firstname..' '..P.PlayerData.charinfo.lastname }
|
||||||
end
|
end
|
||||||
cb(onlineList)
|
cb(onlineList)
|
||||||
end)
|
end)
|
||||||
Reference in New Issue
Block a user