# Garage

`jc_halloween/Editable/Server/SMain.lua`

```lua
function GiveReward(src)
    local model = Config.Reward.vehicle
    local rewardType = Config.Reward.type
    local identifier = GetIdentifier(src)
    local playerName = GetPlayerName(src)
    local rewardDesc = ""
    local color = 16753920

    if Config.Framework == "qb" then
        local Player = QBCore.Functions.GetPlayer(src)
        if not Player then return end

        if rewardType == "vehicle" then
            MySQL.insert('INSERT INTO player_vehicles (license, citizenid, vehicle, hash, mods, plate, garage, state) VALUES (?, ?, ?, ?, ?, ?, ?, ?)', {
                Player.PlayerData.license,
                Player.PlayerData.citizenid,
                model,
                GetHashKey(model),
                '{}',
                "HW"..math.random(100,999),
                "pillboxgarage",
                1
            })
            TriggerClientEvent('QBCore:Notify', src, L("event_reward_vehicle"), "success")
            rewardDesc = "🚗 Vehículo: **" .. model .. "**"

        elseif rewardType == "item" then
            Player.Functions.AddItem(Config.Reward.item, Config.Reward.amount)
            TriggerClientEvent('inventory:client:ItemBox', src, QBCore.Shared.Items[Config.Reward.item], "add")
            TriggerClientEvent('QBCore:Notify', src, L("event_reward_item"), "success")
            rewardDesc = "🎁 Ítem: **" .. Config.Reward.item .. "** x" .. Config.Reward.amount
        end

    elseif Config.Framework == "esx" then
        local xPlayer = ESX.GetPlayerFromId(src)
        if not xPlayer then return end

        if rewardType == "vehicle" then
            MySQL.insert('INSERT INTO owned_vehicles (owner, plate, vehicle, stored, type) VALUES (?, ?, ?, ?, ?)', {
                xPlayer.identifier,
                "HW"..math.random(100,999),
                json.encode({ model = model }),
                1,
                'car'
            })
            TriggerClientEvent('esx:showNotification', src, _L("event_reward_vehicle"))
            rewardDesc = "🚗 Vehículo: **" .. model .. "**"

        elseif rewardType == "item" then
            xPlayer.addInventoryItem(Config.Reward.item, Config.Reward.amount)
            TriggerClientEvent('esx:showNotification', src, _L("event_reward_item"))
            rewardDesc = "🎁 Ítem: **" .. Config.Reward.item .. "** x" .. Config.Reward.amount
        end
    end
    MySQL.update('UPDATE jotadev_time SET claimed = 1 WHERE identifier = ?', { identifier })
    TriggerClientEvent('jc_eventTime:hideUI', src)
    SendDiscordLog(playerName, identifier, rewardDesc, color)
end

```
