Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding a bill command #7

Open
wants to merge 6 commits into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 32 additions & 0 deletions server.lua
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,38 @@ local function UniqueAccounts(player)
end
end

QBCore.Commands.Add('bill', 'Bill A Player', {{name = 'id', help = 'Player ID'}, {name = 'amount', help = 'Fine Amount'}, {name = 'message', help = 'Message'}}, false, function(source, args)
local biller = QBCore.Functions.GetPlayer(source)
local billed = QBCore.Functions.GetPlayer(tonumber(args[1]))
local billerJobName = biller.PlayerData.job.name
local amount = math.ceil(tonumber(args[2]))
local message = args[3]

if not Config.BusinessAccounts[billerJobName] then
TriggerClientEvent('QBCore:Notify', source, 'No Access', 'error')
end
if not billed then
TriggerClientEvent('QBCore:Notify', source, 'Player Not Online', 'error')
end
if biller.PlayerData.citizenid == billed.PlayerData.citizenid then
TriggerClientEvent('QBCore:Notify', source, 'You Cannot Bill Yourself', 'error')
end
if not amount or amount <= 0 then
TriggerClientEvent('QBCore:Notify', source, 'Must Be A Valid Amount Above 0', 'error')
end
exports.pefcl:createInvoice(-1, {
to = billed.PlayerData.charinfo.firstname .. billed.PlayerData.charinfo.lastname,
toIdentifier = billed.PlayerData.citizenid,
from = tostring(Config.BusinessAccounts[billerJobName].AccountName),
fromIdentifier = biller.PlayerData.citizenid,
amount = amount,
message = message,
receiverAccountIdentifier = billerJobName
})
TriggerClientEvent('QBCore:Notify', source, 'Invoice Successfully Sent', 'success')
TriggerClientEvent('QBCore:Notify', billed.PlayerData.source, 'New Invoice Received')
end)

local function getCards(source)
local Player = QBCore.Functions.GetPlayer(source)
local cards = Player.Functions.GetItemsByName('visa')
Expand Down