Update layout and removal of reduntant statement

Nothing mayjor, just removal of pointless events like "if player offline don't charge" this should be possible to charge them as it retrieves a list of online players nearby
This commit is contained in:
jimathy
2022-02-11 18:29:47 +00:00
committed by GitHub
parent 8fcea104da
commit 24ea006d60

View File

@@ -18,8 +18,7 @@ AddEventHandler('jim-payments:Tickets:Give', function(amount, job)
end end
end) end)
RegisterServerEvent('jim-payments:Tickets:Sell') RegisterServerEvent('jim-payments:Tickets:Sell', function()
AddEventHandler('jim-payments:Tickets:Sell', function(data)
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") == nil then TriggerClientEvent('QBCore:Notify', source, "No tickets to trade", 'error') return
else else
@@ -28,7 +27,7 @@ AddEventHandler('jim-payments:Tickets:Sell', function(data)
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: "..tickets.." Total: $"..pay, 'success') TriggerClientEvent('QBCore:Notify', source, "Tickets traded: "..tickets.." Total: $"..pay, 'success')
end end
end) end)
@@ -44,9 +43,8 @@ RegisterServerEvent("jim-payments:server:Charge", function(citizen, price, billt
local amount = tonumber(price) local amount = tonumber(price)
local billtype = string.lower(tostring(billtype)) local billtype = string.lower(tostring(billtype))
if billed ~= nil 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)
--if source == tonumber(citizen) then TriggerClientEvent('QBCore:Notify', source, 'You Cannot Bill Yourself', 'error') return end
if balance >= amount then if balance >= amount then
billed.Functions.RemoveMoney('cash', amount) TriggerEvent("qb-bossmenu:server:addAccountMoney", tostring(biller.PlayerData.job.name), amount) billed.Functions.RemoveMoney('cash', amount) TriggerEvent("qb-bossmenu:server:addAccountMoney", tostring(biller.PlayerData.job.name), amount)
TriggerEvent('jim-payments:Tickets:Give', amount, tostring(biller.PlayerData.job.name)) TriggerEvent('jim-payments:Tickets:Give', amount, tostring(biller.PlayerData.job.name))
@@ -55,8 +53,6 @@ RegisterServerEvent("jim-payments:server:Charge", function(citizen, price, billt
TriggerClientEvent("QBCore:Notify", tonumber(citizen), "You don't have enough cash to pay", "error") TriggerClientEvent("QBCore:Notify", tonumber(citizen), "You don't have enough cash to pay", "error")
end end
elseif billtype == "card" then elseif billtype == "card" then
--if biller.PlayerData.citizenid == billed.PlayerData.citizenid then TriggerClientEvent('QBCore:Notify', source, 'You Cannot Bill Yourself', 'error') return end
if amount and amount > 0 then
MySQL.Async.insert( MySQL.Async.insert(
'INSERT INTO phone_invoices (citizenid, amount, society, sender, sendercitizenid) VALUES (?, ?, ?, ?, ?)', 'INSERT INTO phone_invoices (citizenid, amount, society, sender, sendercitizenid) VALUES (?, ?, ?, ?, ?)',
{billed.PlayerData.citizenid, amount, biller.PlayerData.job.name, {billed.PlayerData.citizenid, amount, biller.PlayerData.job.name,
@@ -64,13 +60,12 @@ RegisterServerEvent("jim-payments:server:Charge", function(citizen, price, billt
TriggerClientEvent('qb-phone:RefreshPhone', billed.PlayerData.source) TriggerClientEvent('qb-phone:RefreshPhone', billed.PlayerData.source)
TriggerClientEvent('QBCore:Notify', source, 'Invoice Successfully Sent', 'success') TriggerClientEvent('QBCore:Notify', source, 'Invoice Successfully Sent', 'success')
TriggerClientEvent('QBCore:Notify', billed.PlayerData.source, 'New Invoice Received') TriggerClientEvent('QBCore:Notify', billed.PlayerData.source, 'New Invoice Received')
else TriggerClientEvent('QBCore:Notify', source, 'Must Be A Valid Amount Above 0', 'error') end
end end
else TriggerClientEvent('QBCore:Notify', source, 'Player Not Online', 'error') end else TriggerClientEvent('QBCore:Notify', source, "You can't charge $0", 'error') return end
end) end)
QBCore.Functions.CreateCallback('jim-payments:Name:Find', function(source, cb, user) QBCore.Functions.CreateCallback('jim-payments:Name:Find', function(source, cb, userid)
local Player = QBCore.Functions.GetPlayer(tonumber(user)) local Player = QBCore.Functions.GetPlayer(tonumber(userid))
name = Player.PlayerData.charinfo.firstname..' '..Player.PlayerData.charinfo.lastname local name = Player.PlayerData.charinfo.firstname..' '..Player.PlayerData.charinfo.lastname
cb(name) cb(name)
end) end)