Commission update

This commit is contained in:
jimathy
2022-04-11 18:59:47 +01:00
committed by GitHub
parent 65f51520fb
commit f9029f0951
4 changed files with 66 additions and 30 deletions

View File

@@ -51,7 +51,7 @@ end)
RegisterNetEvent('jim-payments:Tickets:Menu', function() RegisterNetEvent('jim-payments:Tickets:Menu', function()
local amount = nil local amount = nil
while amount == nil do QBCore.Functions.TriggerCallback('jim-payments:Ticket:Count', function(cb) amount = cb end) Citizen.Wait(1) end local p = promise.new() QBCore.Functions.TriggerCallback('jim-payments:Ticket:Count', function(cb) p:resolve(cb) end) amount = Citizen.Await(p)
for k, v in pairs(Config.Jobs) do if k ~= PlayerJob.name then for k, v in pairs(Config.Jobs) do if k ~= PlayerJob.name then
else exports['qb-menu']:openMenu({ else exports['qb-menu']:openMenu({
{ isMenuHeader = true, header = "🧾 "..PlayerJob.label.." Receipts 🧾", txt = "Do you want trade your receipts for payment?" }, { isMenuHeader = true, header = "🧾 "..PlayerJob.label.." Receipts 🧾", txt = "Do you want trade your receipts for payment?" },

View File

@@ -1,4 +1,4 @@
print("Jim-Payments v2.1 - Payments Script by Jimathy") print("Jim-Payments v2.2 - Payments Script by Jimathy")
-- If you need support I now have a discord available, it helps me keep track of issues and give better support. -- If you need support I now have a discord available, it helps me keep track of issues and give better support.
@@ -18,17 +18,24 @@ Config.ATMBlips = false -- Enable this if you are a pyscho and need every ATM to
Config.PhoneBank = true -- Set this to false to use the popup payment system FOR CARD/BANK PAYMENTS instead of using phone invoices Config.PhoneBank = true -- Set this to false to use the popup payment system FOR CARD/BANK PAYMENTS instead of using phone invoices
-- This doesn't affect Cash payments as they by default use confirmation now -- This doesn't affect Cash payments as they by default use confirmation now
-- This is helpful for phones that don't support invoices well -- This is helpful for phones that don't support invoices well
Config.Commission = false -- Set this to true to enable Commissions and give the person charging a percentage of the total
Config.CommissionAll = false -- Set this to true to give commission to workers clocked in
Config.CommissionDouble = false -- Set this to true if you want the person charging to get double Commission
Config.CommissionLimit = false -- If true, this limits the Commission to only be given if over the "MinAmountForTicket". If false, Commission will be given for any amount
-- MinAmountforTicket should be your cheapest item -- MinAmountforTicket should be your cheapest item
-- PayPerTicket should never be higher than MinAmountforTicket -- PayPerTicket should never be higher than MinAmountforTicket
-- Commission is a percentage eg "0.10" becomes 10%
Config.Jobs = { Config.Jobs = {
['beanmachine'] = { MinAmountforTicket = 50, PayPerTicket = 50 }, ['beanmachine'] = { MinAmountforTicket = 50, PayPerTicket = 50, Commission = 0.10, },
['burgershot'] = { MinAmountforTicket = 50, PayPerTicket = 50 }, ['burgershot'] = { MinAmountforTicket = 50, PayPerTicket = 50 , Commission = 0.10,},
['catcafe'] = { MinAmountforTicket = 50, PayPerTicket = 50 }, ['catcafe'] = { MinAmountforTicket = 50, PayPerTicket = 50, Commission = 0.10, },
['henhouse'] = { MinAmountforTicket = 50, PayPerTicket = 50 }, ['henhouse'] = { MinAmountforTicket = 50, PayPerTicket = 50, Commission = 0.10, },
['pizzathis'] = { MinAmountforTicket = 50, PayPerTicket = 50 }, ['pizzathis'] = { MinAmountforTicket = 50, PayPerTicket = 50, Commission = 0.10, },
['popsdiner'] = { MinAmountforTicket = 50, PayPerTicket = 50 }, ['popsdiner'] = { MinAmountforTicket = 50, PayPerTicket = 50, Commission = 0.10, },
['tequilala'] = { MinAmountforTicket = 50, PayPerTicket = 50 }, ['tequilala'] = { MinAmountforTicket = 50, PayPerTicket = 50, Commission = 0.10, },
['vanilla'] = { MinAmountforTicket = 50, PayPerTicket = 50 }, ['vanilla'] = { MinAmountforTicket = 50, PayPerTicket = 50, Commission = 0.10, },
['mechanic'] = { MinAmountforTicket = 1000, PayPerTicket = 500 }, ['mechanic'] = { MinAmountforTicket = 1000, PayPerTicket = 500, Commission = 0.10, },
} }

View File

@@ -1,6 +1,6 @@
name "Jim-Payments" name "Jim-Payments"
author "Jimathy" author "Jimathy"
version "v2" version "v2.2"
description "Payment Script By Jimathy" description "Payment Script By Jimathy"
fx_version "cerulean" fx_version "cerulean"
game "gta5" game "gta5"

View File

@@ -13,18 +13,45 @@ end
--QBCore.Commands.Add("cashregister", "Use mobile cash register", {}, false, function(source) TriggerClientEvent("jim-payments:client:Charge", source, true) 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) RegisterServerEvent('jim-payments:Tickets:Give', function(data, biller)
if Config.TicketSystem then --Find the biller from their citizenid
if biller == nil then
for k, v in pairs(QBCore.Functions.GetPlayers()) do for k, v in pairs(QBCore.Functions.GetPlayers()) do
local Player = QBCore.Functions.GetPlayer(v) local Player = QBCore.Functions.GetPlayer(v)
if Player ~= nil then if Player.PlayerData.citizenid == data.senderCitizenId then biller = Player end
if Player.PlayerData.job.name == job and Player.PlayerData.job.onduty then end
if amount >= Config.Jobs[job].MinAmountforTicket then end
if Config.TicketSystem then
if data.amount >= Config.Jobs[data.society].MinAmountforTicket then
for k, v in pairs(QBCore.Functions.GetPlayers()) do
local Player = QBCore.Functions.GetPlayer(v)
if Player ~= nil then
if Player.PlayerData.job.name == data.society and Player.PlayerData.job.onduty then
Player.Functions.AddItem('payticket', 1, false, {["quality"] = nil}) Player.Functions.AddItem('payticket', 1, false, {["quality"] = nil})
TriggerClientEvent('QBCore:Notify', Player.PlayerData.source, 'Receipt received', 'success') TriggerClientEvent('QBCore:Notify', Player.PlayerData.source, 'Receipt received', 'success')
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)
elseif amount < Config.Jobs[job].MinAmountforTicket then end
TriggerClientEvent("QBCore:Notify", Player.PlayerData.source, "Amount too low, didn't receive a receipt", "error") end
end
end
end
-- Commission section, does each config option separately
local comm = tonumber(Config.Jobs[data.society].Commission)
if Config.Commission and comm ~= 0 then
if Config.CommissionLimit and data.amount < Config.Jobs[data.society].MinAmountforTicket then return end
if Config.CommissionDouble then
biller.Functions.AddMoney("bank", math.floor(tonumber(data.amount) * (comm *2)))
TriggerClientEvent("QBCore:Notify", biller.PlayerData.source, "Recieved $"..math.floor(tonumber(data.amount) * (comm *2)).." in Commission", "success")
else biller.Functions.AddMoney("bank", math.floor(tonumber(data.amount) *comm))
TriggerClientEvent("QBCore:Notify", biller.PlayerData.source, "Recieved $"..math.floor(tonumber(data.amount) * comm).." in Commission", "success")
end
if Config.CommissionAll then
for k, v in pairs(QBCore.Functions.GetPlayers()) do
local Player = QBCore.Functions.GetPlayer(v)
if Player ~= nil and Player ~= biller then
if Player.PlayerData.job.name == data.society and Player.PlayerData.job.onduty then
Player.Functions.AddMoney("bank", math.floor(tonumber(data.amount) * comm))
TriggerClientEvent("QBCore:Notify", Player.PlayerData.source, "Recieved $"..math.floor(tonumber(data.amount) * comm).." in Commission", "success")
end end
end end
end end
@@ -56,14 +83,15 @@ RegisterServerEvent("jim-payments:server:Charge", function(citizen, price, billt
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))
local amount = tonumber(price) local amount = tonumber(price)
local balance = billed.Functions.GetMoney(billtype)
if amount and amount > 0 then if amount and amount > 0 then
if billtype == "cash" then balance = billed.Functions.GetMoney(billtype) if balance < amount then
if balance >= amount then TriggerClientEvent("QBCore:Notify", src, "Customer doesn't have enough cash to pay", "error")
TriggerClientEvent("jim-payments:client:PayPopup", billed.PlayerData.source, amount, src, billtype, img) TriggerClientEvent("QBCore:Notify", tonumber(citizen), "You don't have enough cash to pay", "error")
elseif balance < amount then return
TriggerClientEvent("QBCore:Notify", src, "Customer doesn't have enough cash to pay", "error") end
TriggerClientEvent("QBCore:Notify", tonumber(citizen), "You don't have enough cash to pay", "error") if billtype == "cash" then
end TriggerClientEvent("jim-payments:client:PayPopup", billed.PlayerData.source, amount, src, billtype, img)
elseif billtype == "bank" then elseif billtype == "bank" then
if Config.PhoneBank == false then if Config.PhoneBank == false then
TriggerClientEvent("jim-payments:client:PayPopup", billed.PlayerData.source, amount, src, billtype, img) TriggerClientEvent("jim-payments:client:PayPopup", billed.PlayerData.source, amount, src, billtype, img)
@@ -83,11 +111,12 @@ RegisterServerEvent("jim-payments:server:PayPopup", 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))
local newdata = { senderCitizenId = biller.PlayerData.citizenid, society = biller.PlayerData.job.name, amount = data.amount }
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)
exports["qb-management"]:AddMoney(tostring(biller.PlayerData.job.name), data.amount) exports["qb-management"]:AddMoney(tostring(biller.PlayerData.job.name), data.amount)
--TriggerEvent("qb-bossmenu:server:addAccountMoney", tostring(biller.PlayerData.job.name), data.amount) --TriggerEvent("qb-bossmenu:server:addAccountMoney", tostring(biller.PlayerData.job.name), data.amount)
TriggerEvent('jim-payments:Tickets:Give', data.amount, tostring(biller.PlayerData.job.name)) TriggerEvent('jim-payments:Tickets:Give', newdata, biller)
TriggerClientEvent("QBCore:Notify", data.biller, billed.PlayerData.charinfo.firstname.." accepted the payment", "success") TriggerClientEvent("QBCore:Notify", data.biller, billed.PlayerData.charinfo.firstname.." accepted the payment", "success")
elseif data.accept == false then elseif data.accept == false then
TriggerClientEvent("QBCore:Notify", src, "You declined the payment") TriggerClientEvent("QBCore:Notify", src, "You declined the payment")