1
0
Fork 0
forked from Simnation/Main
Main/resources/[jobs]/[civ]/nordi_tipjar/client.lua
2025-06-07 08:51:21 +02:00

69 lines
2.5 KiB
Lua

local QBCore = exports['qb-core']:GetCoreObject()
-- QB-Target für die mit CodeWalker platzierten Props
CreateThread(function()
for job, data in pairs(Config.TipBoxes) do
exports['qb-target']:AddTargetModel(data.propModel, {
options = {
{
type = "client",
event = "tips:collectTips",
icon = "fas fa-hand-holding-usd",
label = data.collectLabel,
jobData = { job = job }, -- Geändert zu jobData
canInteract = function()
return QBCore.Functions.GetPlayerData().job.name == job
end,
},
{
type = "client",
event = "tips:giveTip",
icon = "fas fa-coins",
label = data.tipLabel,
jobData = { job = job }, -- Geändert zu jobData
canInteract = function()
return QBCore.Functions.GetPlayerData().job.name ~= job
end,
}
},
distance = 2.5
})
end
end)
RegisterNetEvent('tips:giveTip')
AddEventHandler('tips:giveTip', function(data)
if not data or not data.jobData then return end
local job = data.jobData.job -- Geändert zu jobData.job
local jobData = Config.TipBoxes[job]
local input = exports['qb-input']:ShowInput({
header = "Trinkgeld geben",
submitText = "Bestätigen",
inputs = {
{
text = "Betrag ($" .. jobData.minTip .. " - $" .. jobData.maxTip .. ")",
name = "amount",
type = "number",
isRequired = true
}
}
})
if input then
local amount = tonumber(input.amount)
if amount and amount >= jobData.minTip and amount <= jobData.maxTip then
TriggerServerEvent('tips:giveTipServer', job, amount)
else
QBCore.Functions.Notify('Ungültiger Betrag! Bitte zwischen $' .. jobData.minTip .. ' und $' .. jobData.maxTip .. ' eingeben.', 'error')
end
end
end)
RegisterNetEvent('tips:collectTips')
AddEventHandler('tips:collectTips', function(data)
if data and data.jobData then -- Geändert zu jobData
TriggerServerEvent('tips:collectTipsServer', data.jobData)
end
end)