mirror of
https://github.com/jimathy/jim-payments.git
synced 2026-08-17 06:16:02 +01:00
Compare commits
15 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
487459eda8 | ||
|
|
be931570bb | ||
|
|
e958ae1582 | ||
|
|
d1ea279f4a | ||
|
|
256394bfe3 | ||
|
|
227fbd322c | ||
|
|
4ed398fd9f | ||
|
|
2837a808f1 | ||
|
|
b78c6dc3a9 | ||
|
|
412267a5c8 | ||
|
|
e0321c51c6 | ||
|
|
0ea3f36d42 | ||
|
|
ded2fbb219 | ||
|
|
3722d4b2ba | ||
|
|
63cf7f972d |
10
README.md
10
README.md
@@ -1,8 +1,14 @@
|
||||
# jim-payments
|
||||
QBCore based payment system
|
||||
|
||||
--------------
|
||||
If you use a different phone/invoice system let me know and I will add support for it as best I can!
|
||||
--------------
|
||||
|
||||
Enchanced QB-Input payment system from my other scripts now free on its own
|
||||
|
||||
 
|
||||
|
||||
# Installation
|
||||
|
||||
To make use of this payment system you need trigger the event
|
||||
@@ -39,3 +45,7 @@ Go to [qb] > qb-phone > client > main.lua
|
||||
- Add this line:
|
||||
|
||||
```TriggerServerEvent('jim-payments:Tickets:Give', amount, society)```
|
||||
|
||||
--------------
|
||||
|
||||
NOTE: If you are converting from my older job scripts, I recommend removing the previous triggers from qb-phone
|
||||
|
||||
54
client.lua
54
client.lua
@@ -1,7 +1,6 @@
|
||||
local QBCore = exports['qb-core']:GetCoreObject()
|
||||
|
||||
PlayerJob = {}
|
||||
|
||||
local onDuty = false
|
||||
|
||||
RegisterNetEvent('QBCore:Client:OnPlayerLoaded')
|
||||
@@ -23,30 +22,49 @@ AddEventHandler('QBCore:Client:SetDuty', function(duty)
|
||||
end)
|
||||
|
||||
--Keeps track of duty on script restarts
|
||||
AddEventHandler('onResourceStart', function(resource) if GetCurrentResourceName() == resource then QBCore.Functions.GetPlayerData(function(PlayerData) PlayerJob = PlayerData.job end) end end)
|
||||
AddEventHandler('onResourceStart', function(resource)
|
||||
if GetCurrentResourceName() == resource then QBCore.Functions.GetPlayerData(function(PlayerData) PlayerJob = PlayerData.job onDuty = PlayerJob.onduty end) end end)
|
||||
|
||||
Citizen.CreateThread(function()
|
||||
local jobroles = {}
|
||||
for k, v in pairs(Config.Jobs) do jobroles[tostring(k)] = 0 end
|
||||
exports['qb-target']:AddBoxZone("JimBank", vector3(251.75, 222.17, 106.2), 0.6, 2.0, { name="JimBank", heading = 340.0, debugPoly=false, minZ = 105.75, maxZ = 107.29, },
|
||||
{ options = { { type = 'server', event = "jim-payments:Tickets:Sell", icon = "fas fa-receipt", label = "Cash in Receipts", job = jobroles }, },
|
||||
for k, v in pairs(Config.Jobs) do jobroles[tostring(k)] = 0 end
|
||||
exports['qb-target']:AddBoxZone("JimBank", vector3(251.75, 222.17, 106.2), 0.6, 2.0, { name="JimBank", heading = 340.0, debugPoly=true, minZ = 105.75, maxZ = 107.29, },
|
||||
{ options = { { event = "jim-payments:Tickets:Menu", icon = "fas fa-receipt", label = "Cash in Receipts", job = jobroles } },
|
||||
distance = 2.0
|
||||
})
|
||||
end)
|
||||
|
||||
RegisterNetEvent('jim-payments:client:Charge', function()
|
||||
if not onDuty then TriggerEvent("QBCore:Notify", "Not Clocked in!", "error") return end -- Require to be on duty when making a payment
|
||||
QBCore.Functions.TriggerCallback('jim-payments:server:GetCurrentPlayers', function(playerList)
|
||||
if playerList[1] == nil then TriggerEvent("QBCore:Notify", "No one near by to charge", "error") return end
|
||||
local dialog = exports['qb-input']:ShowInput({ header = "Charge Customer", submitText = "Send",
|
||||
inputs = {
|
||||
{ text = "Citizen", name = "citizen", type = "select", options = playerList },
|
||||
{ type = 'number', isRequired = true, name = 'price', text = 'Amount to Charge' },
|
||||
{ type = 'radio', name = 'billtype', text = 'Payment Type', options = { { value = "cash", text = "Cash" }, { value = "card", text = "Card" } } }, }
|
||||
})
|
||||
if dialog then
|
||||
if not dialog.citizen or not dialog.price then return end
|
||||
TriggerServerEvent('jim-payments:server:Charge', dialog.citizen, dialog.price, dialog.billtype)
|
||||
local playerList = {}
|
||||
for k,v in pairs(QBCore.Functions.GetPlayersFromCoords(GetEntityCoords(PlayerPedId()), Config.PaymentRadius)) do
|
||||
dist = #(GetEntityCoords(GetPlayerPed(v)) - GetEntityCoords(PlayerPedId()))
|
||||
TriggerEvent("QBCore:Notify", "["..GetPlayerServerId(v).."] - "..GetPlayerName(v).." ("..math.floor(dist+0.5).."m)", "error")
|
||||
if v ~= PlayerId() then
|
||||
playerList[#playerList+1] = { value = GetPlayerServerId(v), text = "["..GetPlayerServerId(v).."] - "..GetPlayerName(v).." ("..math.floor(dist+0.5).."m)" }
|
||||
end
|
||||
end)
|
||||
end)
|
||||
end
|
||||
if playerList[1] == nil then TriggerEvent("QBCore:Notify", "No one near by to charge", "error") return end
|
||||
local dialog = exports['qb-input']:ShowInput({ header = "Charge Customer", submitText = "Send",
|
||||
inputs = {
|
||||
{ text = "Citizen", name = "citizen", type = "select", options = playerList },
|
||||
{ type = 'number', isRequired = true, name = 'price', text = 'Amount to Charge' },
|
||||
{ type = 'radio', name = 'billtype', text = 'Payment Type', options = { { value = "cash", text = "Cash" }, { value = "card", text = "Card" } } }, }
|
||||
})
|
||||
if dialog then
|
||||
if not dialog.citizen or not dialog.price then return end
|
||||
TriggerServerEvent('jim-payments:server:Charge', dialog.citizen, dialog.price, dialog.billtype)
|
||||
end
|
||||
end)
|
||||
RegisterNetEvent('jim-payments:Tickets:Menu', function()
|
||||
for k, v in pairs(Config.Jobs) do if k ~= PlayerJob.name then
|
||||
else exports['qb-menu']:openMenu({
|
||||
{ isMenuHeader = true, header = PlayerJob.label.." Ticket Payment", txt = "Do you want trade your tickets for payment?" },
|
||||
{ header = "Yes", txt = "", params = { event = "jim-payments:Tickets:Sell:yes" } },
|
||||
{ header = "No", txt = "", params = { event = "jim-payments:Tickets:Sell:no" } }, })
|
||||
end
|
||||
end
|
||||
end)
|
||||
|
||||
RegisterNetEvent('jim-payments:Tickets:Sell:yes', function() TriggerServerEvent('jim-payments:Tickets:Sell') end)
|
||||
RegisterNetEvent('jim-payments:Tickets:Sell:no', function() exports['qb-menu']:closeMenu() end)
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
print("Jim-Payments v1.0 - Payments Script by Jimathy")
|
||||
print("Jim-Payments v1.1 - 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.
|
||||
|
||||
@@ -17,4 +17,4 @@ Config.Jobs = {
|
||||
['tequilala'] = { MinAmountforTicket = 50, PayPerTicket = 50 },
|
||||
['vanilla'] = { MinAmountforTicket = 50, PayPerTicket = 50 },
|
||||
['mechanic'] = { MinAmountforTicket = 1000, PayPerTicket = 500 },
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,12 +1,13 @@
|
||||
name "Jim-Payments"
|
||||
author "Jimathy"
|
||||
version "v1.0"
|
||||
version "v1.2"
|
||||
description "Payment Script By Jimathy"
|
||||
fx_version "cerulean"
|
||||
game "gta5"
|
||||
|
||||
dependencies {
|
||||
'qb-input',
|
||||
'qb-target'
|
||||
}
|
||||
|
||||
client_scripts {
|
||||
@@ -20,4 +21,4 @@ server_scripts {
|
||||
|
||||
shared_scripts {
|
||||
'config.lua',
|
||||
}
|
||||
}
|
||||
|
||||
@@ -25,7 +25,8 @@ AddEventHandler('jim-payments:Tickets:Sell', function(data)
|
||||
else
|
||||
tickets = Player.Functions.GetItemByName("payticket").amount
|
||||
Player.Functions.RemoveItem('payticket', tickets)
|
||||
Player.Functions.AddMoney('bank', (tickets * Confing.Jobs[Player.PlayerData.job.name].PayPerTicket), 'ticket-payment')
|
||||
pay = (tickets * Config.Jobs[Player.PlayerData.job.name].PayPerTicket)
|
||||
Player.Functions.AddMoney('bank', pay, 'ticket-payment')
|
||||
TriggerClientEvent('inventory:client:ItemBox', source, QBCore.Shared.Items['payticket'], "remove", tickets)
|
||||
TriggerClientEvent('QBCore:Notify', source, "Tickets: "..tickets.." Total: $"..pay, 'success')
|
||||
end
|
||||
@@ -69,8 +70,9 @@ QBCore.Functions.CreateCallback('jim-payments:server:GetCurrentPlayers', functio
|
||||
local Player = QBCore.Functions.GetPlayer(v)
|
||||
if Player ~= nil and v ~= source then
|
||||
local dist = #(vector3(Player.PlayerData.position.x, Player.PlayerData.position.y, Player.PlayerData.position.z) - vector3(SPlayer.PlayerData.position.x, SPlayer.PlayerData.position.y, SPlayer.PlayerData.position.z))
|
||||
if dist < Config.PaymentRadius then onlineList[#onlineList+1] = { value = tonumber(v), text = "["..v.."] - "..Player.PlayerData.charinfo.firstname..' '..Player.PlayerData.charinfo.lastname } end
|
||||
if dist <= Config.PaymentRadius then onlineList[#onlineList+1] = { value = tonumber(v), text = "["..v.."] - "..Player.PlayerData.charinfo.firstname..' '..Player.PlayerData.charinfo.lastname..' ('..math.floor(dist+0.5)..'m)' }
|
||||
elseif dist > Config.PaymentRadius then end
|
||||
end
|
||||
end
|
||||
cb(onlineList)
|
||||
end)
|
||||
end)
|
||||
|
||||
Reference in New Issue
Block a user