mirror of
https://github.com/jimathy/jim-payments.git
synced 2026-08-19 15:26:03 +01:00
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:
33
server.lua
33
server.lua
@@ -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,22 +53,19 @@ 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
|
MySQL.Async.insert(
|
||||||
if amount and amount > 0 then
|
'INSERT INTO phone_invoices (citizenid, amount, society, sender, sendercitizenid) VALUES (?, ?, ?, ?, ?)',
|
||||||
MySQL.Async.insert(
|
{billed.PlayerData.citizenid, amount, biller.PlayerData.job.name,
|
||||||
'INSERT INTO phone_invoices (citizenid, amount, society, sender, sendercitizenid) VALUES (?, ?, ?, ?, ?)',
|
biller.PlayerData.charinfo.firstname, biller.PlayerData.citizenid})
|
||||||
{billed.PlayerData.citizenid, amount, biller.PlayerData.job.name,
|
TriggerClientEvent('qb-phone:RefreshPhone', billed.PlayerData.source)
|
||||||
biller.PlayerData.charinfo.firstname, biller.PlayerData.citizenid})
|
TriggerClientEvent('QBCore:Notify', source, 'Invoice Successfully Sent', 'success')
|
||||||
TriggerClientEvent('qb-phone:RefreshPhone', billed.PlayerData.source)
|
TriggerClientEvent('QBCore:Notify', billed.PlayerData.source, 'New Invoice Received')
|
||||||
TriggerClientEvent('QBCore:Notify', source, 'Invoice Successfully Sent', 'success')
|
|
||||||
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)
|
||||||
|
|||||||
Reference in New Issue
Block a user