Skip to content

Commit

Permalink
feat: remove all alcohol stuff & move consumables config to server
Browse files Browse the repository at this point in the history
  • Loading branch information
TonybynMp4 authored Feb 18, 2024
1 parent d4fb458 commit 2e24cb8
Show file tree
Hide file tree
Showing 5 changed files with 114 additions and 221 deletions.
77 changes: 13 additions & 64 deletions client/consumables.lua
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
local sharedConfig = require 'config.shared'
local alcoholCount, healing, smokingWeed, relieveCount = 0, false, false, 0
local healing, smokingWeed, relieveCount = false, false, 0

local function healOxy()
if not healing then
Expand Down Expand Up @@ -137,8 +137,7 @@ local function smokeWeed()
end)
end

lib.callback.register('consumables:client:Eat', function(itemName)
local item = sharedConfig.consumables.food[itemName]
lib.callback.register('consumables:client:Eat', function(itemName, itemParams)
if lib.progressBar({
duration = 5000,
label = 'Eating...',
Expand All @@ -150,12 +149,12 @@ lib.callback.register('consumables:client:Eat', function(itemName)
mouse = false,
combat = true
},
anim = item.anim or {
anim = itemParams.anim or {
clip = 'mp_player_int_eat_burger',
dict = 'mp_player_inteat@burger',
flag = 49
},
prop = item.prop or {
prop = itemParams.prop or {
{
model = 'prop_cs_burger_01',
bone = 18905,
Expand All @@ -164,16 +163,17 @@ lib.callback.register('consumables:client:Eat', function(itemName)
}
}
}) then -- if completed
TriggerServerEvent('hud:server:RelieveStress', math.random(item.stressRelief.min, item.stressRelief.max))
if itemParams.stressRelief then
TriggerServerEvent('hud:server:RelieveStress', math.random(itemParams.stressRelief.min, itemParams.stressRelief.max))
end
return true
else -- if canceled
exports.qbx_core:Notify('Canceled...', 'error')
return false
end
end)

lib.callback.register('consumables:client:Drink', function(itemName)
local item = sharedConfig.consumables.drink[itemName]
lib.callback.register('consumables:client:Drink', function(itemName, itemParams)
if lib.progressBar({
duration = 5000,
label = 'Drinking...',
Expand All @@ -185,12 +185,12 @@ lib.callback.register('consumables:client:Drink', function(itemName)
mouse = false,
combat = true
},
anim = item.anim or {
anim = itemParams.anim or {
clip = 'loop_bottle',
dict = 'mp_player_intdrink',
flag = 49
},
prop = item.prop or {
prop = itemParams.prop or {
{
model = 'prop_ld_flow_bottle',
bone = 18905,
Expand All @@ -199,47 +199,8 @@ lib.callback.register('consumables:client:Drink', function(itemName)
}
}
}) then -- if completed
TriggerServerEvent('hud:server:RelieveStress', math.random(item.stressRelief.min, item.stressRelief.max))
return true
else -- if canceled
exports.qbx_core:Notify('Canceled...', 'error')
return false
end
end)

lib.callback.register('consumables:client:DrinkAlcohol', function(itemName)
local item = sharedConfig.consumables.alcohol[itemName]
if lib.progressBar({
duration = math.random(3000, 6000),
label = 'Drinking liquor...',
useWhileDead = false,
canCancel = true,
disable = {
move = false,
car = false,
mouse = false,
combat = true
},
anim = item.anim or {
clip = 'loop_bottle',
dict = 'mp_player_intdrink',
flag = 49
},
prop = item.prop or {
{
model = 'prop_amb_beer_bottle',
bone = 18905,
pos = {x = 0.12, y = 0.008, z = 0.03},
rot = {x = 240.0, y = -60.0, z = 0.0}
}
}
}) then -- if completed
TriggerServerEvent('hud:server:RelieveStress', math.random(item.stressRelief.min, item.stressRelief.max))
alcoholCount += item.alcoholLevel or 1
if alcoholCount > 1 and alcoholCount < 4 then
TriggerEvent('evidence:client:SetStatus', 'alcohol', 200)
elseif alcoholCount >= 4 then
TriggerEvent('evidence:client:SetStatus', 'heavyalcohol', 200)
if itemParams.stressRelief then
TriggerServerEvent('hud:server:RelieveStress', math.random(itemParams.stressRelief.min, itemParams.stressRelief.max))
end
return true
else -- if canceled
Expand Down Expand Up @@ -410,16 +371,4 @@ RegisterNetEvent('consumables:client:UseJoint', function()
else -- if canceled
exports.qbx_core:Notify('Canceled...', 'error')
end
end)

CreateThread(function()
while true do
Wait(10)
if alcoholCount > 0 then
Wait(1000 * 60 * 15)
alcoholCount -= 1
else
Wait(2000)
end
end
end)
end)
98 changes: 98 additions & 0 deletions config/server.lua
Original file line number Diff line number Diff line change
@@ -1,4 +1,102 @@
return {
---@class anim
---@field clip string
---@field dict string
---@field flag number

---@class prop
---@field model string
---@field bone number
---@field pos vector3
---@field rot vector3

---@class stressRelief
---@field min number
---@field max number

---@class consumable
---@field min number
---@field max number
---@field anim anim?
---@field prop table?
---@field stressRelief table?

consumables = {
---@type table<string, consumable>
food = {
sandwich = {
min = 35,
max = 54,
stressRelief = {
min = 1,
max = 4
},
},
tosti = {
min = 40,
max = 50,
stressRelief = {
min = 1,
max = 4
},
},
twerks_candy = {
min = 35,
max = 54,
stressRelief = {
min = 1,
max = 4
},
},
snikkel_candy = {
min = 40,
max = 50,
stressRelief = {
min = 1,
max = 4
},
},
},

---@type table<string, consumable>
drink = {
water_bottle = {
min = 35,
max = 54,
stressRelief = {
min = 1,
max = 4
},
},
kurkakola = {
min = 35,
max = 54,
stressRelief = {
min = 1,
max = 4
},
},
coffee = {
min = 40,
max = 50,
anim = {
clip = 'idle_c',
dict = 'amb@world_human_drinking@coffee@male@idle_a',
flag = 49
},
prop = {
model = 'p_amb_coffeecup_01',
bone = 28422,
pos = {x = 0.0, y = 0.0, z = 0.0},
rot = {x = 0.0, y = 0.0, z = 0.0}
},
stressRelief = {
min = -10,
max = -1
},
},
},
},

-- The amount of seconds it takes for you to stand AFK and get kicked
timeUntilAFKKick = 1000,
Expand Down
133 changes: 0 additions & 133 deletions config/shared.lua

This file was deleted.

5 changes: 1 addition & 4 deletions fxmanifest.lua
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,7 @@ client_scripts {

server_script 'server/*.lua'

files {
'config/client.lua',
'config/shared.lua'
}
file 'config/client.lua'

lua54 'yes'
use_experimental_fxv2_oal 'yes'
Loading

0 comments on commit 2e24cb8

Please sign in to comment.