mirror of
https://github.com/jimathy/jim-payments.git
synced 2026-08-16 22:06:02 +01:00
an attempted name grab fix
let me know if this has any issues
This commit is contained in:
37
client.lua
37
client.lua
@@ -7,6 +7,7 @@ RegisterNetEvent('QBCore:Client:OnPlayerLoaded')
|
||||
AddEventHandler('QBCore:Client:OnPlayerLoaded', function()
|
||||
QBCore.Functions.GetPlayerData(function(PlayerData)
|
||||
PlayerJob = PlayerData.job
|
||||
PlayerGang = PlayerData.gang
|
||||
end)
|
||||
end)
|
||||
|
||||
@@ -21,36 +22,40 @@ AddEventHandler('QBCore:Client:SetDuty', function(duty)
|
||||
onDuty = duty
|
||||
end)
|
||||
|
||||
RegisterNetEvent('QBCore:Client:OnGangUpdate')
|
||||
AddEventHandler('QBCore:Client:OnGangUpdate', function(GangInfo)
|
||||
PlayerGang = GangInfo
|
||||
end)
|
||||
|
||||
--Keeps track of duty on script restarts
|
||||
AddEventHandler('onResourceStart', function(resource)
|
||||
if GetCurrentResourceName() == resource then QBCore.Functions.GetPlayerData(function(PlayerData) PlayerJob = PlayerData.job onDuty = PlayerJob.onduty end) end end)
|
||||
if GetCurrentResourceName() == resource then QBCore.Functions.GetPlayerData(function(PlayerData) PlayerJob = PlayerData.job PlayerGang = PlayerData.gang 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 = { { event = "jim-payments:Tickets:Menu", icon = "fas fa-receipt", label = "Cash in Receipts", job = jobroles } },
|
||||
distance = 2.0
|
||||
})
|
||||
{ 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
|
||||
local playerList = {}
|
||||
local playerList = { }
|
||||
local name = nil
|
||||
for k,v in pairs(QBCore.Functions.GetPlayersFromCoords(GetEntityCoords(PlayerPedId()), Config.PaymentRadius)) do
|
||||
--Distance info, cosmetic for adding the "(5m)" when opening the register
|
||||
local dist = #(GetEntityCoords(GetPlayerPed(v)) - GetEntityCoords(PlayerPedId()))
|
||||
|
||||
--Moved the script to client, and needed to grab full character name not the username
|
||||
local name = nil
|
||||
while name == nil do QBCore.Functions.TriggerCallback('jim-payments:Name:Find', function(cb) name = cb end, GetPlayerServerId(v)) Citizen.Wait(1) end
|
||||
|
||||
--Debugging notification, this shows the info it finds regardless of it adds to the list or not
|
||||
--TriggerEvent("QBCore:Notify", "["..GetPlayerServerId(v).."] - "..name.." ("..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)" }
|
||||
while name == nil do
|
||||
QBCore.Functions.TriggerCallback('jim-payments:Name:Find', function(cb) name = cb
|
||||
--Debugging notification, this shows the info it finds regardless of it adds to the list or not
|
||||
--TriggerEvent("QBCore:Notify", "Table Number: "..#playerList.." ["..GetPlayerServerId(v).."] - "..name.." ("..math.floor(dist+0.5).."m)", "error")
|
||||
if v ~= PlayerId() then
|
||||
playerList[#playerList+1] = { value = GetPlayerServerId(v), text = "["..GetPlayerServerId(v).."] - "..name.." ("..math.floor(dist+0.5).."m)" }
|
||||
end
|
||||
end, GetPlayerServerId(v))
|
||||
Citizen.Wait(100)
|
||||
end
|
||||
name,dist = nil
|
||||
end
|
||||
|
||||
if playerList[#playerList] == nil then TriggerEvent("QBCore:Notify", "No one near by to charge", "error") return end
|
||||
@@ -80,4 +85,4 @@ RegisterNetEvent('jim-payments:Tickets:Menu', function()
|
||||
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)
|
||||
RegisterNetEvent('jim-payments:Tickets:Sell:no', function() exports['qb-menu']:closeMenu() end)
|
||||
|
||||
Reference in New Issue
Block a user