Wert Water Dispensers (Coolers)

You can access the setup information you need about this product

INSTALLATION

1 - Upload the script folder to the location of your resources

2 - Check config file for your own settings

3 - Please add the items to your list in the items section below

4 - Installation successful, have a good funs

ITEMS


["water_dispenser"] = {
	["name"] = "water_dispenser",
	["label"] = "Water Dispenser",
	["weight"] = 0,
	["type"] = "item",
	["image"] = "water_dispenser.png",
	["unique"] = true,
	["useable"] = true,
	["shouldClose"] = true,
	["combinable"] = nil,
	["description"] = ""
},
["cold_water_cup"] = {
	["name"] = "cold_water_cup",
	["label"] = "Cold Water",
	["weight"] = 100,
	["type"] = "item",
	["image"] = "cold_water_cup.png",
	["unique"] = false,
	["useable"] = true,
	["expire"] = nil,
	["shouldClose"] = true,
	["combinable"] = nil,
	["description"] = "A Cup Cold Water"
},
["hot_water_cup"] = {
	["name"] = "hot_water_cup",
	["label"] = "Hot Water",
	["weight"] = 100,
	["type"] = "item",
	["image"] = "hot_water_cup.png",
	["unique"] = false,
	["useable"] = true,
	["expire"] = nil,
	["shouldClose"] = true,
	["combinable"] = nil,
	["description"] = "A Cup Hot Water"
},

OX LIB OPTION

There are many ox settings available in the files, if you want, you can configure them.

If you want to use ox_lib, please check if this link is enabled on fxmanifest.check it out from inside lua. this must be turned on before you can use ox_lib. After opening it, it will be enough to use the refresh and ensure commands.

OPEN FILES


Config = {}

Config.OxLib = true
Config.OxInventory = false
Config.DebugPoly = false
Config.UseTarget = true
Config.TargetInteractionDistance = 1.5
Config.NoTargetInteractionDistance = 1.5
Config.NoTargetInteractionKey = 38
Config.NoTargetRemoveKey = 47
Config.NoTargetInteractionType = 'textui' -- | 'textui', 'drawtext'
-- Model settings
Config.UseModelSystem = true
Config.WaterDispenserModels = {
    `prop_watercooler_dark`,
    `prop_watercooler`,
    `ch_chint02_watercooler`,
}

-- Coord settings
Config.UseZoneSystem = false
Config.WaterDispensers = {
    -- If u want use only specific coord machine you need add like this
}


-- Particle settings
Config.FillCup = `prop_cs_paper_cup`
Config.FillMachineOffSet = vector3(0.0, -0.13, 0.6)
Config.FillCupDrawOutline = {
    enable = false,
    color = {69, 250, 61, 255}
}
Config.FillParticle = {
    dict = "core",
    name = "ent_amb_waterfall_splash_p",
    zOffset = 0.17,
    alpha = 10.0
}

-- Drink settings
Config.DirectDrink = true -- | If you set false this value script use item sytem so when you fill water it add auto item your inventory
Config.ColdWaterItem = 'cold_water_cup'
Config.HotWaterItem = 'hot_water_cup'

Config.ColdWaterAddThirst = 50 -- %50
Config.HotWaterAddThirst = 50 -- %50

Config.ColdWaterAddHunger = 0 -- %0 (If u want active set more >)
Config.HotWaterAddHunger = 0 -- %0 (If u want active set more >)

Config.WaterDrinkItems = {
    {item = 'cold_water_cup', action = 'cold'},
    {item = 'hot_water_cup', action = 'hot'},
}


Config.DrinkSoundVolume = 0.2

Config.HotMinigameActive = true
Config.HotMinigameType = 'ps-ui-circle' -- | 'qb-lock', 'ox-ui-circle' 
Config.HotMinigameTimePercante = 2 -- /2 mean example : 1000 milisecond drink time game show 1000/2 so 500. second 

Config.RemoveBackItem = false -- | When u remove ur water dispenser give back item

Config.DrinkSettings = {
    ['hot'] = {
        time = 10000,
        label = 'Drinking (Hot) ...',
        move = false,
        combat = false,
        mouse = false,
        car = false,
        anim = {
            dict = 'mp_player_intdrink',
            clip = 'loop_bottle',
            flag = 49
        },
        prop = {
            model = 'prop_cs_paper_cup',
            pos = vec3(0.12, 0.008, 0.03),
            rot = vec3(240.0, -60.0, 0.0),
            bone = 18905
        }
    },
    ['cold'] = {
        time = 10000,
        label = 'Drinking (Cold) ...',
        move = false,
        combat = false,
        mouse = false,
        car = false,
        anim = {
            dict = 'mp_player_intdrink',
            clip = 'loop_bottle',
            flag = 49
        },
        prop = {
            model = 'prop_cs_paper_cup',
            pos = vec3(0.12, 0.008, 0.03),
            rot = vec3(240.0, -60.0, 0.0),
            bone = 18905
        }
    }
}


-- Placeable items
Config.PlaceableItems = {
    {item = "water_dispenser", model = 'prop_watercooler'},
    -- If u want add more item here
}
-- Editable client side
local ESX = exports["es_extended"]:getSharedObject()
MyDispensers = {}

function CustomNotifVariation(text, style, time)
    ESX.ShowNotification(text, style or 'info', time or 3000)
end

function ShowTextUI(text)
    if Config.OxLib then
        lib.showTextUI(text, {position = 'left-center'})
    else
           -- If u use own textui system u can edit
        -- exports['qb-core']:DrawText(text, 'left')
    end
end

function HideTextUI()
    if Config.OxLib then
        lib.hideTextUI()
    else
            -- If u use own textui system u can edit
        -- exports['qb-core']:HideText()
    end
end

function IsMyDispenser(entity)
    local state = false
    for i=1, #MyDispensers do
        if MyDispensers[i] and entity == MyDispensers[i] then
            state = true
            break
        end
    end
    return state
end

function RemoveMyDispenser(entity)
    local found = nil
    for i=1, #MyDispensers do
        if MyDispensers[i] and entity == MyDispensers[i] then
            found = i
            break
        end
    end
    if found then table.remove(MyDispensers, found) end
end

function LoadDispenserTargets()
    if Config.UseModelSystem then
        exports['qb-target']:AddTargetModel(Config.WaterDispenserModels, {
            options = {
                {
                    type = "client",
                    icon = 'fas fa-caret-right',
                    label = LANG.target_label,
                    targeticon = 'fas fa-droplet',
                    action = function(entity)
                        TriggerEvent('wert-waterdispensers:client:open-water-dispenser', entity)
                    end,
                },
                {
                    type = "client",
                    icon = 'fa-regular fa-trash-can',
                    label = LANG.delete_dispenser,
                    action = function(entity)
                        RemoveMyDispenser(entity)
                        TriggerServerEvent('wert-waterdispensers:server:remove-dispenser', GetEntityCoords(entity))
                    end,
                    canInteract = function(entity)
                        if IsMyDispenser(entity) then
                            return true
                        else
                            return false
                        end
                    end,
                },
            },
            distance = Config.TargetInteractionDistance,
        })
    else
        for i=1, #Config.WaterDispensers do
            local row = Config.WaterDispensers[i]
            local zone_name = "WertWaterDispenser"..i
            exports["qb-target"]:AddBoxZone(zone_name, row.coord, row.width, row.length, { -- Yeni
                name = zone_name,
                heading = row.heading,
                debugPoly = Config.DebugPoly,
                minZ = row.minZ,
                maxZ = row.maxZ
            }, {
                options = {
                    {
                        type = "client",
                        icon = 'fas fa-caret-right',
                        label = LANG.target_label,
                        targeticon = 'fas fa-droplet',
                        action = function(entity)
                            TriggerEvent('wert-waterdispensers:client:open-water-dispenser', entity)
                        end,
                    },
                    {
                        type = "client",
                        icon = 'fa-regular fa-trash-can',
                        label = LANG.delete_dispenser,
                        action = function(entity)
                            RemoveMyDispenser(entity)
                            TriggerServerEvent('wert-waterdispensers:server:remove-dispenser', GetEntityCoords(entity))
                        end,
                        canInteract = function(entity)
                            if IsMyDispenser(entity) then
                                return true
                            else
                                return false
                            end
                        end,
                    },
                },
                distance = 1.5
            })
        end
    end
end

function CustomMiniGame(cb)
    if Config.HotMinigameType == 'ps-ui-circle' then
        exports['ps-ui']:Circle(function(success)
            if success then
                cb(true)
            else
                cb(false)
            end
        end, 1, 10)
    elseif Config.HotMinigameType == 'ox-ui-circle' then
        local success = lib.skillCheck({'easy', 'easy', {areaSize = 60, speedMultiplier = 2}, 'hard'}, {'w', 'a', 's', 'd'})
        if success then
            cb(true)
        else
            cb(false)
        end
    elseif Config.HotMinigameType == 'qb-lock' then
        local time = math.random(7, 10)
        local circles = 1
        local success = exports['qb-lock']:StartLockPickCircle(circles, time, success)
        if success then
            cb(true)
        else
            cb(false)
        end
    end
    -- If u want add more minigame like example these 
end

function CustomProgressbar(data, cb)
    if Config.OxLib then
        if lib.progressBar({
            duration = data.time,
            label = data.label,
            useWhileDead = false,
            canCancel = true,
            disable = {
                move = data.move,
                combat = data.combat,
                mouse = data.mouse,
                car = data.car,
            },
            anim = data.anim,
            prop = data.prop,
        }) then
            cb('true') 
        else
            cb('false')
        end
    else
        -- https://github.com/qbcore-framework/progressbar
        Progressbar('waterdispenser_pg', data.label, data.time, false, true, {
            disableMovement = data.move,
            disableCarMovement = data.car,
            disableMouse = data.mouse,
            disableCombat = data.combat,
        }, data.anim, data.prop, {}, function()
            cb('true')
        end, function()
            cb('false')
        end)
    end
end

function CancelCurrentProgressbar()
    if Config.OxLib then
        lib.cancelProgress()
    else
        TriggerEvent('progressbar:client:cancel')
    end
end

function DrawText3D(x, y, z, text)
    -- Use local function instead
    SetTextScale(0.35, 0.35)
    SetTextFont(4)
    SetTextProportional(1)
    SetTextColour(255, 255, 255, 215)
    SetTextEntry('STRING')
    SetTextCentre(true)
    AddTextComponentString(text)
    SetDrawOrigin(x, y, z, 0)
    DrawText(0.0, 0.0)
    local factor = (string.len(text)) / 370
    DrawRect(0.0, 0.0 + 0.0125, 0.017 + factor, 0.03, 0, 0, 0, 75)
    ClearDrawOrigin()
end


-- # Events
RegisterNetEvent('wert-waterdispensers:client:custom-notif-variation', function(text, style, time)
    CustomNotifVariation(text, style, time)
end)
-- Editable server side
local ESX = exports["es_extended"]:getSharedObject()

function GiveBackWaterDispenserItem(src, item)
    if not item then return end
    local ply = ESX.GetPlayerFromId(src)
    if not ply then return end
    ply.addInventoryItem(item, 1)
end

RegisterNetEvent('wert-waterdispensers:server:add-water-item', function(item)
    local src = source
    local ply = ESX.GetPlayerFromId(src)
    if not ply then return end
    if Config.OxInventory then
        exports.ox_inventory:AddItem(src, item, 1)
    else
        ply.addInventoryItem(item, 1)
    end
end)

RegisterNetEvent('wert-waterdispensers:server:add-status', function(thirst, hunger)
    local src = source
    local ply = ESX.GetPlayerFromId(src)
    if not ply then return end
    if hunger > 0 then
        hunger = hunger * 10000
        TriggerClientEvent('esx_status:add', src, 'hunger', hunger)
    end
    if thirst > 0 then
        thirst = thirst * 10000
        TriggerClientEvent('esx_status:add', src, 'thirst', thirst)
    end
end)

RegisterNetEvent('wert-waterdispensers:server:item-action', function(data)
    local src = source
    local ply = ESX.GetPlayerFromId(src)
    if not ply then return end
    if data.action == 'add' then
        if Config.OxInventory then
            exports.ox_inventory:AddItem(src, data.name, data.amount)
        else
            ply.addInventoryItem(data.name, data.amount)
        end
    else
        if Config.OxInventory then
            exports.ox_inventory:RemoveItem(src, data.name, data.amount)
        else
            ply.removeInventoryItem(data.name, data.amount)
        end
    end
end)


ESX.RegisterUsableItem(Config.ColdWaterItem, function(src)
    TriggerClientEvent('wert-waterdispensers:client:use-drinkitem', src, 'cold', Config.ColdWaterItem)
end)

ESX.RegisterUsableItem(Config.HotWaterItem, function(src)
    TriggerClientEvent('wert-waterdispensers:client:use-drinkitem', src, 'hot', Config.HotWaterItem)
end)
-- Locales
LANG = {
    target_label = "Water Dispenser",
    dispenser_busy = "This Dispenser Busy, Please Wait For Available Status",
    no_target_interaction = "[E] Water Dispenser",
    no_target_interaction_remove = "[E] Water Dispenser | [G] Remove Dispenser",
    delete_dispenser = "Remove Dispenser",
    placement = {
        header = "Placement Keyboard",
        arrow_up = '<i class="fa-solid fa-arrow-up"></i>',
        arrow_left = '<i class="fa-solid fa-arrow-left"></i>',
        arrow_right = '<i class="fa-solid fa-arrow-right"></i>',
        arrow_desc = "MOVE",
        zkey = "Z",
        z_desc = "Reduce Height",
        qkey = "Q",
        ekey = "E",
        rotate = "Rotate",
        ctrl = "CTRL",
        shift = "SHIFT",
        right_dip = "Right Dip",
        left_dip = "Left Dip",
        fixground = "Fix Ground",
        finish = "Finish",
        cancel = "Cancel",
        space = "SPACE",
        enter = "ENTER",
        backspace = "BACKSPACE"
    },
    ui = {
        machine_label = "Water Cooler",
        guide_header = "Water Cooler",
        guide_bar_one_header = "Glass",
        guide_bar_one_description = "Take a new glass from the cup holder and place your glass in the cold or hot area",
        guide_bar_two_header = "Cold Water",
        guide_bar_two_description = "After placing your glass, you can start the filling process by pressing the cold water filling button",
        guide_bar_three_header = "Hot Water",
        guide_bar_three_description = "After placing your glass, you can start the filling process by pressing the hot water filling button",
        guide_count_one_header = '500 ML',
        guide_count_one_description = 'Drink for your health',
        guide_count_two_header = '250 ML',
        guide_count_two_description = 'It okey for a short period of time but just enough',
        guide_count_three_header = '100 ML',
        guide_count_three_description = 'Very bad, inadequate',
    },
}

Last updated