Skip to content

Commit

Permalink
🦄 Release v1.1.0
Browse files Browse the repository at this point in the history
  • Loading branch information
imkuroneko authored Mar 24, 2024
1 parent 06ec627 commit a649c54
Show file tree
Hide file tree
Showing 5 changed files with 66 additions and 62 deletions.
61 changes: 36 additions & 25 deletions client.lua
Original file line number Diff line number Diff line change
@@ -1,41 +1,52 @@
local QBCore = exports['qb-core']:GetCoreObject()
lib.locale()

exports['qb-target']:AddTargetModel(Config.props, {
options = { { type = 'client', event = 'neko_waterdispenser:take:cup', icon = Config.icon, label = Config.label } },
distance = 2.0
options = {
{ type = 'client', event = 'neko_waterdispenser:take:drink_water', icon = Config.qbTargetIcon, label = locale('qbtarget_label') }
},
distance = Config.qbTargetDistance
})

RegisterNetEvent('neko_waterdispenser:take:cup')
AddEventHandler('neko_waterdispenser:take:cup', function()
RegisterNetEvent('neko_waterdispenser:take:drink_water')
AddEventHandler('neko_waterdispenser:take:drink_water', function()
QBCore.Functions.GetPlayerData(function(PlayerData)
if not PlayerData.metadata["isdead"] and not PlayerData.metadata["inlaststand"] and not PlayerData.metadata["ishandcuffed"] and not IsPauseMenuActive() then
local dispenserMachine = GetClosestWaterDispenser(Config.props)
if dispenserMachine ~= nil then
QBCore.Functions.Progressbar(
'neko_waterdispenser_drink',
Config.labelAction,
Config.TimeInMS,
false,
true,
{ disableMovement = false, disableCarMovement = false, disableMouse = false, disableCombat = true },
{ animDict = "amb@world_human_drinking@coffee@male@idle_a", anim = "idle_c" },
{ model = "prop_plastic_cup_02", bone = 28422, coords = { x = 0.022, y = 0.00, z = 0.025 }, rotation = { x = 10.0, y = -0.0, z = 0.0 } },
{},
function()
StopAnimTask(PlayerPedId(), "amb@world_human_drinking@coffee@male@idle_a", "idle_c", 1.0)
TriggerServerEvent('neko_waterdispenser:server:thirst')
end,
function()
StopAnimTask(PlayerPedId(), "amb@world_human_drinking@coffee@male@idle_a", "idle_c", 1.0)
end
)
local progressParams = {
duration = Config.TimeInMS,
label = locale('action'),
useWhileDead = false,
position = 'bottom',
canCancel = true,
disable = { car = true, move = true, combat = true },
anim = { dict = 'amb@world_human_drinking@coffee@male@idle_a', clip = 'idle_c' },
prop = { model = "prop_plastic_cup_02", bone = 28422, pos = { x = 0.022, y = 0.00, z = 0.025 }, rot = { x = 10.0, y = -0.0, z = 0.0 } }
}

if Config.VerifyNearby then
local dispenserMachine = GetClosestWaterDispenser(Config.props)
if dispenserMachine ~= nil then
DrinkWater(progressParams)
else
lib.notify({ description = locale('not_available'), type = 'error' })
end
else
QBCore.Functions.Notify(Config.OutOfService, "error")
DrinkWater(progressParams)
end
end
end)
end)

function DrinkWater(params)
if lib.progressCircle(params) then
TriggerServerEvent('neko_waterdispenser:server:drinked_water')

lib.notify({ description = locale('drinked_water_ok'), type = 'success' })
else
lib.notify({ description = locale('drinked_water_cancelled'), type = 'error' })
end
end

function GetClosestWaterDispenser(props)
local ped = PlayerPedId()
local pos = GetEntityCoords(ped)
Expand Down
23 changes: 7 additions & 16 deletions config.lua
Original file line number Diff line number Diff line change
@@ -1,22 +1,13 @@
Config = {}

-- Visualización del qb-target a los dispensadores
Config.label = 'Dispensador de agua'
Config.icon = 'fas fa-droplet'
Config.qbTargetIcon = 'fas fa-droplet' -- icon for the option
Config.qbTargetDistance = 1.4 -- distance

-- Label para progressbar
Config.labelAction = 'Bebiendo agua...'
Config.VerifyNearby = false -- if true, will check you are veery nearby of the water dispenser
Config.amountThirst = math.random(10, 15) -- how much a cup of water will fill
Config.TimeInMS = 5500 -- time for exec the action (5.5s)

-- Cuanto debe llenar
Config.amountThirst = math.random(10, 15)

-- Cuanto debe tardar para beber agua
Config.TimeInMS = 5500 -- 5.5s

-- Props dispensadores
Config.props = {
Config.props = { -- on which props will work this
'prop_watercooler',
'prop_watercooler_dark'
}

Config.OutOfService = 'Este dispensador de agua se encuentra fuera de servicio'
}
35 changes: 15 additions & 20 deletions fxmanifest.lua
Original file line number Diff line number Diff line change
@@ -1,20 +1,15 @@
fx_version 'cerulean'
game 'gta5'

author 'imkuroneko'
description 'Sistema de dispensador de agua'
version '1.0.0'

server_scripts {
'config.lua',
'server.lua',
}

client_scripts {
'config.lua',
'client.lua',
}

dependencies {
'qb-target'
}
fx_version 'cerulean'
game 'gta5'
lua54 'yes'
-- ===========================================================
description 'Complemento para utilizar dispensadores de agua'
author 'KuroNeko'
-- ===========================================================
version '1.1.0'

-- ===========================================================
shared_scripts { '@ox_lib/init.lua', 'config.lua' }
server_scripts { 'server.lua' }
client_scripts { 'client.lua' }
files { 'locales/es.json' }
dependencies { 'qb-target' }
7 changes: 7 additions & 0 deletions locales/es.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"qbtarget_label" : "Dispensador de agua",
"action" : "Bebiendo agua...",
"not_available" : "Este dispensador de agua está ocupado o no se encuentra disponible",
"drinked_water_ok" : "Te has hidratado un poco...",
"drinked_water_cancelled" : "Has dejado de beber el agua"
}
2 changes: 1 addition & 1 deletion server.lua
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
local QBCore = exports['qb-core']:GetCoreObject()

RegisterNetEvent('neko_waterdispenser:server:thirst', function()
RegisterNetEvent('neko_waterdispenser:server:drinked_water', function()
local Player = QBCore.Functions.GetPlayer(source)
local newThirst = (Player.PlayerData.metadata.thirst + Config.amountThirst)
Player.Functions.SetMetaData('thirst', newThirst)
Expand Down

0 comments on commit a649c54

Please sign in to comment.