Files
jim-payments/client/tickets.lua

70 lines
3.4 KiB
Lua
Raw Normal View History

if not Config.Banks.enable or not Config.Receipts.CashInAnywhere then
onPlayerLoaded(function()
local locations = BankLocations
if not Config.Receipts.CashInAnywhere then
locations = {
["receipts"] = Config.Receipts.CashInLocations
}
end
for k, v in pairs(locations) do
for i = 1, #v do
local name = getScript()..":BankLocation:"..k..i
if Config.General.Peds then
if not Config.Gabz then CreateModelHide(v[i].xyz, 1.0, `v_corp_bk_chair3`, true) end
if not Peds[name] then
Peds[name] = makePed(Config.General.PedPool[math.random(1, #Config.General.PedPool)], v[i], false, false)
if isStarted("jim-talktonpc") then
exports["jim-talktonpc"]:createDistanceMessage("hi", Peds[name], 3.0, false)
end
end
end
local jobroles = {}
local gangroles = {}
for k, v in pairs(Config.Receipts.Jobs) do
if v.gang then
gangroles[k] = 0
else
jobroles[k] = 0
end
end
createCircleTarget(
{ name, vec3(v[i].x, v[i].y, v[i].z+0.2), 2.0, { name = name, debugPoly = debugMode, useZ = true, }, }, {
{ action = function() TriggerEvent(getScript()..":Tickets:Menu", { gang = false }) end,
icon = "fas fa-receipt", label = locale("target", "cashin_boss"), job = jobroles,
},
{ action = function() TriggerEvent(getScript()..":Tickets:Menu", { gang = true }) end,
icon = "fas fa-receipt", label = locale("target", "cashin_gang"), gang = gangroles,
},
}, 2.5)
end
end
end, true)
end
2025-02-21 13:54:49 +00:00
RegisterNetEvent(getScript()..":Tickets:Menu", function(data)
2025-02-22 13:23:43 +00:00
local PlayerInfo = getPlayer()
2024-01-27 21:57:05 +00:00
local hasItem, hasTable = hasItem("payticket", 1)
2025-02-21 13:54:49 +00:00
if not hasItem then
2025-02-22 13:23:43 +00:00
triggerNotify(nil, locale("error" ,"no_ticket"), "error")
2025-02-21 13:54:49 +00:00
return
end
2024-01-27 21:57:05 +00:00
local amount, sellable, name, label = hasTable["payticket"].count, false, "", ""
for k, v in pairs(Config.Receipts.Jobs) do
2025-02-22 13:23:43 +00:00
sellable = (data.gang and v.gang and k == PlayerInfo.gang) or (not data.gang and not v.gang and k == PlayerInfo.job)
if sellable then name, label = k, (data.gang and Gangs[PlayerInfo.gang].label) or (not data.gang and Jobs[PlayerInfo.job].label) break end
2024-01-27 21:57:05 +00:00
end
if sellable then local Menu = {}
Menu[#Menu+1] = {
isMenuHeader = true,
2025-02-22 13:23:43 +00:00
txt = locale("menu" ,"ticket_amount")..amount..locale("menu" ,"total_pay")..(Config.Receipts.Jobs[name].PayPerTicket * amount)
2024-01-27 21:57:05 +00:00
}
Menu[#Menu+1] = {
2025-02-22 13:23:43 +00:00
icon = "fas fa-circle-check", header = locale("menu" ,"yes"),
onSelect = function()
TriggerServerEvent(getScript()..":Tickets:Sell")
playAnim("pickup_object", "putdown_low", 2000, 1)
end,
2024-01-27 21:57:05 +00:00
}
2025-02-22 13:23:43 +00:00
openMenu(Menu, { header = "🧾 "..label..locale("menu" ,"receipt"), headertxt = locale("menu" ,"trade_confirm"), canClose = true, })
2024-01-27 21:57:05 +00:00
end
end)