diff --git a/client/consumables.lua b/client/consumables.lua index 35ea4a8..f29c561 100644 --- a/client/consumables.lua +++ b/client/consumables.lua @@ -1,157 +1,37 @@ -- Variables -local alcoholCount, parachuteEquipped, currentVest, currentVestTexture, healing, smokingWeed, relieveCount = 0, false, nil, nil, false, false, 0 +local prop = 0 +local alcoholCount = 0 +local drunk = false +local drunkDriving = false +local timing = false +local ParachuteEquiped = false --- Functions -local function equipParachuteAnim() - local hasLoaded = lib.requestAnimDict('clothingshirt') - if not hasLoaded then return end - TaskPlayAnim(cache.ped, 'clothingshirt', 'try_shirt_positive_d', 8.0, 1.0, -1, 49, 0, false, false, false) -end - -local function healOxy() - if not healing then - healing = true - else - return - end - - local count = 9 - while count > 0 do - Wait(1000) - count -= 1 - SetEntityHealth(cache.ped, GetEntityHealth(cache.ped) + 6) - end - healing = false -end - -local function trevorEffect() - AnimpostfxPlay('DrugsTrevorClownsFightIn', 3.0, 0) - Wait(3000) - AnimpostfxPlay('DrugsTrevorClownsFight', 3.0, 0) - Wait(3000) - AnimpostfxPlay('DrugsTrevorClownsFightOut', 3.0, 0) - AnimpostfxStop('DrugsTrevorClownsFight') - AnimpostfxStop('DrugsTrevorClownsFightIn') - AnimpostfxStop('DrugsTrevorClownsFightOut') -end - -local function methBagEffect() - local startStamina = 8 - trevorEffect() - SetRunSprintMultiplierForPlayer(cache.playerId, 1.49) - while startStamina > 0 do - Wait(1000) - if math.random(5, 100) < 10 then - RestorePlayerStamina(cache.playerId, 1.0) - end - startStamina = startStamina - 1 - if math.random(5, 100) < 51 then - trevorEffect() - end - end - SetRunSprintMultiplierForPlayer(cache.playerId, 1.0) -end - -local function ecstasyEffect() - local startStamina = 30 - SetFlash(0, 0, 500, 7000, 500) - while startStamina > 0 do - Wait(1000) - startStamina -= 1 - RestorePlayerStamina(cache.playerId, 1.0) - if math.random(1, 100) < 51 then - SetFlash(0, 0, 500, 7000, 500) - ShakeGameplayCam('SMALL_EXPLOSION_SHAKE', 0.08) - end - end - if IsPedRunning(cache.ped) then - SetPedToRagdoll(cache.ped, math.random(1000, 3000), math.random(1000, 3000), 3, false, false, false) - end -end +RegisterNetEvent('consumables:client:Eat', function(itemName) + if not Config.ConsumablesEat[itemName] then return end -local function alienEffect() - AnimpostfxPlay('DrugsMichaelAliensFightIn', 3.0, 0) - Wait(math.random(5000, 8000)) - AnimpostfxPlay('DrugsMichaelAliensFight', 3.0, 0) - Wait(math.random(5000, 8000)) - AnimpostfxPlay('DrugsMichaelAliensFightOut', 3.0, 0) - AnimpostfxStop('DrugsMichaelAliensFightIn') - AnimpostfxStop('DrugsMichaelAliensFight') - AnimpostfxStop('DrugsMichaelAliensFightOut') -end + local consume = Config.ConsumablesEat[itemName] -local function crackBaggyEffect() - local startStamina = 8 - alienEffect() - SetRunSprintMultiplierForPlayer(cache.playerId, 1.3) - while startStamina > 0 do - Wait(1000) - if math.random(1, 100) < 10 then - RestorePlayerStamina(cache.playerId, 1.0) - end - startStamina -= 1 - if math.random(1, 100) < 60 and IsPedRunning(cache.ped) then - SetPedToRagdoll(cache.ped, math.random(1000, 2000), math.random(1000, 2000), 3, false, false, false) - end - if math.random(1, 100) < 51 then - alienEffect() - end - end - if IsPedRunning(cache.ped) then - SetPedToRagdoll(cache.ped, math.random(1000, 3000), math.random(1000, 3000), 3, false, false, false) + if consume.prop then + local propData = consume.prop + lib.requestModel(propData.model) + prop = CreateObject(joaat(propData.model), 0, 0, 0, true, true, true) + AttachEntityToEntity(prop, cache.ped, GetPedBoneIndex(cache.ped, propData.bone), propData.coords.x, propData.coords.y, propData.coords.z, propData.rot.x, propData.rot.y, propData.rot.z, true, true, false, true, 1, true) end - SetRunSprintMultiplierForPlayer(cache.playerId, 1.0) -end -local function cokeBaggyEffect() - local startStamina = 20 - alienEffect() - SetRunSprintMultiplierForPlayer(cache.playerId, 1.1) - while startStamina > 0 do - Wait(1000) - if math.random(1, 100) < 20 then - RestorePlayerStamina(cache.playerId, 1.0) - end - startStamina -= 1 - if math.random(1, 100) < 10 and IsPedRunning(cache.ped) then - SetPedToRagdoll(cache.ped, math.random(1000, 3000), math.random(1000, 3000), 3, false, false, false) - end - if math.random(1, 300) < 10 then - alienEffect() - Wait(math.random(3000, 6000)) - end - end - if IsPedRunning(cache.ped) then - SetPedToRagdoll(cache.ped, math.random(1000, 3000), math.random(1000, 3000), 3, false, false, false) + if consume.anim then + local anim = consume.anim + lib.requestAnimDict(anim.lib) + TaskPlayAnim(cache.ped, anim.lib, anim.name, 8.0, 1.0, -1, anim.flag, 0, false, false, false) + elseif consume.scenario then + TaskStartScenarioInPlace(cache.ped, consume.scenario, 0, true) + else + exports.scully_emotemenu:playEmoteByCommand(consume.emote or "eat") end - SetRunSprintMultiplierForPlayer(cache.playerId, 1.0) -end - -local function smokeWeed() - CreateThread(function() - while smokingWeed do - Wait(10000) - TriggerServerEvent('hud:server:RelieveStress', math.random(15, 18)) - relieveCount += 1 - if relieveCount == 6 then - exports.scully_emotemenu:cancelEmote() - if smokingWeed then - smokingWeed = false - relieveCount = 0 - end - end - end - end) -end --- Events - -RegisterNetEvent('consumables:client:Eat', function(itemName) - exports.scully_emotemenu:playEmoteByCommand('eat') if lib.progressBar({ - duration = 5000, - label = 'Eating...', + duration = consume.progress or 5000, + label = consume.label or 'Eating...', useWhileDead = false, canCancel = true, disable = { @@ -161,68 +41,63 @@ RegisterNetEvent('consumables:client:Eat', function(itemName) combat = true } }) then -- if completed - TriggerEvent('inventory:client:ItemBox', exports.ox_inventory:Items()[itemName], 'remove') - exports.scully_emotemenu:cancelEmote() - TriggerServerEvent('consumables:server:addHunger', QBX.PlayerData.metadata.hunger + ConsumablesEat[itemName]) - TriggerServerEvent('hud:server:RelieveStress', math.random(2, 4)) + if consume.anim or consume.scenario then + ClearPedTasks(cache.ped) + else + exports.scully_emotemenu:cancelEmote() + end + if prop ~= 0 then + DeleteEntity(prop) + prop = 0 + end + lib.callback('consumables:server:AddHunger', false, function(retreval) + if retreval then + if consume.relieveStress then + TriggerServerEvent('hud:server:RelieveStress', consume.relieveStress) + end + if consume.action then + consume.action(itemName) + end + end + end, itemName) + else + if consume.anim or consume.scenario then + ClearPedTasks(cache.ped) + else + exports.scully_emotemenu:cancelEmote() + end + lib.notify({ + description = "Cancelled", + type = "error", + }) end end) RegisterNetEvent('consumables:client:Drink', function(itemName) - exports.scully_emotemenu:playEmoteByCommand('drink') - if lib.progressBar({ - duration = 5000, - label = 'Drinking...', - useWhileDead = false, - canCancel = true, - disable = { - move = false, - car = false, - mouse = false, - combat = true - } - }) then -- if completed - TriggerEvent('inventory:client:ItemBox', exports.ox_inventory:Items()[itemName], 'remove') - exports.scully_emotemenu:cancelEmote() - TriggerServerEvent('consumables:server:addThirst', QBX.PlayerData.metadata.thirst + ConsumablesDrink[itemName]) + if not Config.ConsumablesDrink[itemName] then return end + + local consume = Config.ConsumablesDrink[itemName] + + if consume.prop then + local propData = consume.prop + lib.requestModel(propData.model) + prop = CreateObject(joaat(propData.model), 0, 0, 0, true, true, true) + AttachEntityToEntity(prop, cache.ped, GetPedBoneIndex(cache.ped, propData.bone), propData.coords.x, propData.coords.y, propData.coords.z, propData.rot.x, propData.rot.y, propData.rot.z, true, true, false, true, 1, true) end -end) -RegisterNetEvent('consumables:client:DrinkAlcohol', function(itemName) - exports.scully_emotemenu:playEmoteByCommand('beer7') - if lib.progressBar({ - duration = math.random(3000, 6000), - label = 'Drinking liquor...', - useWhileDead = false, - canCancel = true, - disable = { - move = false, - car = false, - mouse = false, - combat = true - } - }) then -- if completed - exports.scully_emotemenu:cancelEmote() - TriggerEvent('inventory:client:ItemBox', exports.ox_inventory:Items()[itemName], 'remove') - TriggerServerEvent('consumables:server:drinkAlcohol', itemName) - TriggerServerEvent('consumables:server:addThirst', QBX.PlayerData.metadata.thirst + ConsumablesAlcohol[itemName]) - TriggerServerEvent('hud:server:RelieveStress', math.random(2, 4)) - alcoholCount += 1 - if alcoholCount > 1 and alcoholCount < 4 then - TriggerEvent('evidence:client:SetStatus', 'alcohol', 200) - elseif alcoholCount >= 4 then - TriggerEvent('evidence:client:SetStatus', 'heavyalcohol', 200) - end - else -- if canceled - exports.scully_emotemenu:cancelEmote() - exports.qbx_core:Notify('Canceled...', 'error') + if consume.anim then + local anim = consume.anim + lib.requestAnimDict(anim.lib) + TaskPlayAnim(cache.ped, anim.lib, anim.name, 8.0, 1.0, -1, anim.flag, 0, false, false, false) + elseif consume.scenario then + TaskStartScenarioInPlace(cache.ped, consume.scenario, 0, true) + else + exports.scully_emotemenu:playEmoteByCommand(consume.emote or "drink") end -end) -RegisterNetEvent('consumables:client:Cokebaggy', function() if lib.progressBar({ - duration = math.random(5000, 8000), - label = 'Quick sniff...', + duration = consume.progress or 5000, + label = consume.label or 'Drinking...', useWhileDead = false, canCancel = true, disable = { @@ -230,79 +105,65 @@ RegisterNetEvent('consumables:client:Cokebaggy', function() car = false, mouse = false, combat = true - }, - anim = { - dict = 'switch@trevor@trev_smoking_meth', - clip = 'trev_smoking_meth_loop', - flag = 49 } }) then -- if completed - TriggerServerEvent('consumables:server:useCokeBaggy') - TriggerEvent('inventory:client:ItemBox', exports.ox_inventory:Items()['cokebaggy'], 'remove') - TriggerEvent('evidence:client:SetStatus', 'widepupils', 200) - cokeBaggyEffect() - else -- if canceled - exports.qbx_core:Notify('Canceled...', 'error') + if consume.anim or consume.scenario then + ClearPedTasks(cache.ped) + else + exports.scully_emotemenu:cancelEmote() + end + if prop ~= 0 then + DeleteEntity(prop) + prop = 0 + end + lib.callback('consumables:server:AddThirst', false, function(retreval) + if retreval then + if consume.relieveStress then + TriggerServerEvent('hud:server:RelieveStress', consume.relieveStress) + end + if consume.action then + consume.action(itemName) + end + end + end, itemName) + else + if consume.anim or consume.scenario then + ClearPedTasks(cache.ped) + else + exports.scully_emotemenu:cancelEmote() + end + lib.notify({ + description = "Cancelled", + type = "error", + }) end end) -RegisterNetEvent('consumables:client:Crackbaggy', function() - if lib.progressBar({ - duration = math.random(7000, 10000), - label = 'Smoking crack...', - useWhileDead = false, - canCancel = true, - disable = { - move = false, - car = false, - mouse = false, - combat = true - }, - anim = { - dict = 'switch@trevor@trev_smoking_meth', - clip = 'trev_smoking_meth_loop', - flag = 49 - } - }) then -- if completed - TriggerServerEvent('consumables:server:useCrackBaggy') - TriggerEvent('inventory:client:ItemBox', exports.ox_inventory:Items()['crack_baggy'], 'remove') - TriggerEvent('evidence:client:SetStatus', 'widepupils', 300) - crackBaggyEffect() - else -- if canceled - exports.qbx_core:Notify('Canceled...', 'error') +RegisterNetEvent('consumables:client:Addiction', function(itemName) + if not Config.ConsumablesAddiction[itemName] then return end + + local consume = Config.ConsumablesAddiction[itemName] + + if consume.prop then + local propData = consume.prop + lib.requestModel(propData.model) + prop = CreateObject(joaat(propData.model), 0, 0, 0, true, true, true) + AttachEntityToEntity(prop, cache.ped, GetPedBoneIndex(cache.ped, propData.bone), propData.coords.x, propData.coords.y, propData.coords.z, propData.rot.x, propData.rot.y, propData.rot.z, true, true, false, true, 1, true) end -end) -RegisterNetEvent('consumables:client:EcstasyBaggy', function() - if lib.progressBar({ - duration = 3000, - label = 'Popping pills...', - useWhileDead = false, - canCancel = true, - disable = { - move = false, - car = false, - mouse = false, - combat = true - }, - anim = { - dict = 'mp_suicide', - clip = 'pill', - flag = 49 - } - }) then -- if completed - TriggerServerEvent('consumables:server:useXTCBaggy') - TriggerEvent('inventory:client:ItemBox', exports.ox_inventory:Items().xtcbaggy, 'remove') - ecstasyEffect() - else -- if canceled - exports.qbx_core:Notify('Canceled...', 'error') + if consume.anim then + local anim = consume.anim + lib.requestAnimDict(anim.lib) + TaskPlayAnim(cache.ped, anim.lib, anim.name, 8.0, 1.0, -1, anim.flag, 0, false, false, false) + elseif consume.scenario then + TaskStartScenarioInPlace(cache.ped, consume.scenario, 0, true) + else + exports.scully_emotemenu:playEmoteByCommand(consume.emote or "smokeweed") end -end) -RegisterNetEvent('consumables:client:oxy', function() if lib.progressBar({ - duration = 2000, - label = 'Healing...', + duration = consume.progress or 5000, + label = consume.label or 'Doing addiction...', useWhileDead = false, canCancel = true, disable = { @@ -310,75 +171,65 @@ RegisterNetEvent('consumables:client:oxy', function() car = false, mouse = false, combat = true - }, - anim = { - dict = 'mp_suicide', - clip = 'pill', - flag = 49 } }) then -- if completed - TriggerServerEvent('consumables:server:useOxy') - TriggerEvent('inventory:client:ItemBox', exports.ox_inventory:Items()['oxy'], 'remove') - ClearPedBloodDamage(cache.ped) - healOxy() - else -- if canceled - exports.qbx_core:Notify('Canceled', 'error') + if consume.anim or consume.scenario then + ClearPedTasks(cache.ped) + else + exports.scully_emotemenu:cancelEmote() + end + if prop ~= 0 then + DeleteEntity(prop) + prop = 0 + end + lib.callback('consumables:server:useIllegal', false, function(retreval) + if retreval then + if consume.relieveStress then + TriggerServerEvent('hud:server:RelieveStress', consume.relieveStress) + end + if consume.action then + consume.action(itemName) + end + end + end, itemName) + else + if consume.anim or consume.scenario then + ClearPedTasks(cache.ped) + else + exports.scully_emotemenu:cancelEmote() + end + lib.notify({ + description = "Cancelled", + type = "error", + }) end end) -RegisterNetEvent('consumables:client:meth', function() - if lib.progressBar({ - duration = 1500, - label = 'Smoking meth...', - useWhileDead = false, - canCancel = true, - disable = { - move = false, - car = false, - mouse = false, - combat = true - }, - anim = { - dict = 'switch@trevor@trev_smoking_meth', - clip = 'trev_smoking_meth_loop', - flag = 49 - } - }) then -- if completed - TriggerServerEvent('consumables:server:useMeth') - TriggerEvent('inventory:client:ItemBox', exports.ox_inventory:Items()['meth'], 'remove') - TriggerEvent('evidence:client:SetStatus', 'widepupils', 300) - TriggerEvent('evidence:client:SetStatus', 'agitated', 300) - methBagEffect() - else -- if canceled - exports.qbx_core:Notify('Canceled...', 'error') - end -end) +RegisterNetEvent('consumables:client:Item', function(itemName) + if not Config.ConsumablesItems[itemName] then return end -RegisterNetEvent('consumables:client:UseJoint', function() - if lib.progressBar({ - duration = 1500, - label = 'Lighting joint...', - useWhileDead = false, - canCancel = true, - disable = { - move = false, - car = false, - mouse = false, - combat = true - } - }) then -- if completed - TriggerEvent('inventory:client:ItemBox', exports.ox_inventory:Items()['joint'], 'remove') - exports.scully_emotemenu:playEmoteByCommand('joint') - TriggerEvent('evidence:client:SetStatus', 'weedsmell', 300) - smokeWeed() + local consume = Config.ConsumablesItems[itemName] + + if consume.prop then + local propData = consume.prop + lib.requestModel(propData.model) + prop = CreateObject(joaat(propData.model), 0, 0, 0, true, true, true) + AttachEntityToEntity(prop, cache.ped, GetPedBoneIndex(cache.ped, propData.bone), propData.coords.x, propData.coords.y, propData.coords.z, propData.rot.x, propData.rot.y, propData.rot.z, true, true, false, true, 1, true) + end + + if consume.anim then + local anim = consume.anim + lib.requestAnimDict(anim.lib) + TaskPlayAnim(cache.ped, anim.lib, anim.name, 8.0, 1.0, -1, anim.flag, 0, false, false, false) + elseif consume.scenario then + TaskStartScenarioInPlace(cache.ped, consume.scenario, 0, true) + elseif consume.emote then + exports.scully_emotemenu:playEmoteByCommand(consume.emote) end -end) -RegisterNetEvent('consumables:client:UseParachute', function() - equipParachuteAnim() if lib.progressBar({ - duration = 5000, - label = 'Putting on parachute...', + duration = consume.progress or 5000, + label = consume.label or 'Using item...', useWhileDead = false, canCancel = true, disable = { @@ -388,20 +239,39 @@ RegisterNetEvent('consumables:client:UseParachute', function() combat = true } }) then -- if completed - TriggerEvent('inventory:client:ItemBox', exports.ox_inventory:Items()['parachute'], 'remove') - GiveWeaponToPed(cache.ped, `GADGET_PARACHUTE`, 1, false, false) - local parachuteData = { - outfitData = {['bag'] = {item = 7, texture = 0}} -- Adding Parachute Clothing - } - TriggerEvent('qb-clothing:client:loadOutfit', parachuteData) - parachuteEquipped = true - TaskPlayAnim(cache.ped, 'clothingshirt', 'exit', 8.0, 1.0, -1, 49, 0, false, false, false) + if consume.anim or consume.scenario then + ClearPedTasks(cache.ped) + elseif consume.emote then + exports.scully_emotemenu:cancelEmote() + end + if prop ~= 0 then + DeleteEntity(prop) + prop = 0 + end + lib.callback('consumables:server:useItem', false, function(retreval) + if retreval then + if consume.action then + consume.action(itemName) + end + end + end, itemName) + else + if consume.anim or consume.scenario then + ClearPedTasks(cache.ped) + elseif consume.emote then + exports.scully_emotemenu:cancelEmote() + end + lib.notify({ + description = "Cancelled", + type = "error", + }) end end) RegisterNetEvent('consumables:client:ResetParachute', function() - if parachuteEquipped then - equipParachuteAnim() + if GetterParachute() then + lib.requestAnimDict("clothingshirt") + TaskPlayAnim(cache.ped, "clothingshirt", "try_shirt_positive_d", 8.0, 1.0, -1, 49, 0, false, false, false) if lib.progressBar({ duration = 40000, label = 'Packing parachute...', @@ -414,107 +284,155 @@ RegisterNetEvent('consumables:client:ResetParachute', function() combat = true } }) then -- if completed - local parachuteRemoveData = { - outfitData = {['bag'] = {item = 0, texture = 0}} -- Removing Parachute Clothing + local ped = cache.ped + local ParachuteRemoveData = { + outfitData = { + ["bag"] = { item = 0, texture = 0} -- Removing Parachute Clothing + } } - TriggerEvent('qb-clothing:client:loadOutfit', parachuteRemoveData) - TaskPlayAnim(cache.ped, 'clothingshirt', 'exit', 8.0, 1.0, -1, 49, 0, false, false, false) - TriggerServerEvent('qb-smallpenis:server:AddParachute') - parachuteEquipped = false + TriggerEvent('qb-clothing:client:loadOutfit', ParachuteRemoveData) + TaskPlayAnim(ped, "clothingshirt", "exit", 8.0, 1.0, -1, 49, 0, false, false, false) + TriggerServerEvent("consumables:server:AddParachute") + SetterParachute(false) end else - exports.qbx_core:Notify('You don\'t have a parachute...', 'error') + lib.notify({ + description = 'No parachute found', + type = "error", + }) end end) -RegisterNetEvent('consumables:client:UseArmor', function() - if GetPedArmour(cache.ped) >= 75 then exports.qbx_core:Notify('You already have enough armor on!', 'error') return end - if lib.progressBar({ - duration = 5000, - label = 'Putting on the body armour...', - useWhileDead = false, - canCancel = true, - disable = { - move = false, - car = false, - mouse = false, - combat = true - } - }) then -- if completed - TriggerEvent('inventory:client:ItemBox', exports.ox_inventory:Items()['armor'], 'remove') - TriggerServerEvent('hospital:server:SetArmor', 75) - TriggerServerEvent('consumables:server:useArmor') - SetPedArmour(cache.ped, 75) - end -end) +local function timer() + local time = 300 + CreateThread( function() + if not timing then + timing = true + while timer ~= 0 do + Wait(5000) --- update timer every 5 seconds + time = time - 5 + if time == 0 then + Sober() + return + end + end + end + end) +end -RegisterNetEvent('consumables:client:UseHeavyArmor', function() - if GetPedArmour(cache.ped) == 100 then exports.qbx_core:Notify('You already have enough armor on!', 'error') return end - if lib.progressBar({ - duration = 5000, - label = 'Putting on body armor...', - useWhileDead = false, - canCancel = true, - disable = { - move = false, - car = false, - mouse = false, - combat = true - } - }) then -- if completed - if QBX.PlayerData.charinfo.gender == 0 then - currentVest = GetPedDrawableVariation(cache.ped, 9) - currentVestTexture = GetPedTextureVariation(cache.ped, 9) - if GetPedDrawableVariation(cache.ped, 9) == 7 then - SetPedComponentVariation(cache.ped, 9, 19, GetPedTextureVariation(cache.ped, 9), 2) - else - SetPedComponentVariation(cache.ped, 9, 5, 2, 2) -- Blue - end - else - currentVest = GetPedDrawableVariation(cache.ped, 30) - currentVestTexture = GetPedTextureVariation(cache.ped, 30) - SetPedComponentVariation(cache.ped, 9, 30, 0, 2) - end - TriggerEvent('inventory:client:ItemBox', exports.ox_inventory:Items()['heavyarmor'], 'remove') - TriggerServerEvent('consumables:server:useHeavyArmor') - SetPedArmour(cache.ped, 100) - end -end) +-- Return to reality +function Sober() + CreateThread(function() + local playerPed = cache.ped + timing = false + drunk = false + drunkDriving = false + ClearTimecycleModifier() + ResetScenarioTypesEnabled() + ResetPedMovementClipset(playerPed, 0) + SetPedIsDrunk(playerPed, false) + SetPedMotionBlur(playerPed, false) + ClearPedSecondaryTask(playerPed) + ShakeGameplayCam("DRUNK_SHAKE", 0.0) -RegisterNetEvent('consumables:client:ResetArmor', function() - if currentVest ~= nil and currentVestTexture ~= nil then - if lib.progressBar({ - duration = 2500, - label = 'Removing the body armour...', - useWhileDead = false, - canCancel = true, - disable = { - move = false, - car = false, - mouse = false, - combat = true - } - }) then -- if completed - SetPedComponentVariation(cache.ped, 9, currentVest, currentVestTexture, 2) - SetPedArmour(cache.ped, 0) - TriggerEvent('inventory:client:ItemBox', exports.ox_inventory:Items()['heavyarmor'], 'add') - TriggerServerEvent('consumables:server:resetArmor') - end - else - exports.qbx_core:Notify('You\'re not wearing a vest...', 'error') - end -end) + end) +end ---Threads +local function fuckDrunkDriver() -CreateThread(function() - while true do - Wait(10) - if alcoholCount > 0 then - Wait(1000 * 60 * 15) - alcoholCount -= 1 - else - Wait(2000) - end + math.randomseed(GetGameTimer()) + + local shitFuckDamn = math.random(1, #Config.RandomVehicleInteraction) + return Config.RandomVehicleInteraction[shitFuckDamn] +end + +local function setPlayerDrunk(anim, shake) + local PlayerPed = cache.ped + + RequestAnimSet(anim) + + while not HasAnimSetLoaded(anim) do + Wait(100) + end + + SetPedMovementClipset(PlayerPed, anim, 1) + ShakeGameplayCam("DRUNK_SHAKE", shake) + SetPedMotionBlur(PlayerPed, true) + SetPedIsDrunk(PlayerPed, true) + +end + +local function alcoholAction() + local anim = 'move_m@drunk@slightlydrunk' + local shake = 1.0 + if alcoholCount <= 1 then return end + if alcoholCount == 2 then + setPlayerDrunk(anim, shake) + elseif alcoholCount == 3 then + anim = "move_m@drunk@moderatedrunk" + shake = 2.0 + setPlayerDrunk(anim, shake) + elseif alcoholCount >= 4 then + anim = "move_m@drunk@verydrunk" + shake = 2.0 + setPlayerDrunk(anim, shake) + end + + if not drunk then + drunk = true + timer() + CreateThread(function() + local PlayerPed = cache.ped + drunkDriving = true + + while drunkDriving do + Wait(Config.Fuckage) -- How often you want to fuck with the driver + if IsPedInAnyVehicle(PlayerPed, false) or IsPedInAnyVehicle(PlayerPed, false) == 0 then + local vehicle = GetVehiclePedIsIn(PlayerPed, false) + if GetPedInVehicleSeat(vehicle, -1) == PlayerPed then + local class = GetVehicleClass(vehicle) + + if class ~= 15 or 16 or 21 or 13 then + local whatToFuckThemWith = fuckDrunkDriver() + TaskVehicleTempAction(PlayerPed, vehicle, whatToFuckThemWith.interaction, whatToFuckThemWith.time) + end + end + end + end + end) + end +end + +local looped = false +function AlcoholLoop() + alcoholCount = alcoholCount + 1 + if alcoholCount > 1 and alcoholCount < 4 then + TriggerEvent("evidence:client:SetStatus", "alcohol", 200) + elseif alcoholCount >= 4 then + TriggerEvent("evidence:client:SetStatus", "heavyalcohol", 200) end -end) \ No newline at end of file + alcoholAction() + if not looped then + looped = true + CreateThread(function() + while true do + Wait(10) + if alcoholCount > 0 then + Wait(1000 * 60 * 15) + alcoholCount -= 1 + else + looped = false + break + end + end + end) + end +end + +function GetterParachute() + return ParachuteEquiped +end + +function SetterParachute(data) + ParachuteEquiped = data +end \ No newline at end of file diff --git a/config.lua b/config.lua index 0ded6c8..111c7e0 100644 --- a/config.lua +++ b/config.lua @@ -31,25 +31,6 @@ Config.Density = { ['scenario'] = 0.8, } -ConsumablesEat = { - ['sandwich'] = math.random(35, 54), - ['tosti'] = math.random(40, 50), - ['twerks_candy'] = math.random(35, 54), - ['snikkel_candy'] = math.random(40, 50), -} - -ConsumablesDrink = { - ['water_bottle'] = math.random(35, 54), - ['kurkakola'] = math.random(35, 54), - ['coffee'] = math.random(40, 50), -} - -ConsumablesAlcohol = { - ['whiskey'] = math.random(20, 30), - ['beer'] = math.random(30, 40), - ['vodka'] = math.random(20, 40), -} - Config.BlacklistedScenarios = { ['TYPES'] = { 'WORLD_VEHICLE_MILITARY_PLANES_SMALL', diff --git a/consumable.lua b/consumable.lua new file mode 100644 index 0000000..be000b8 --- /dev/null +++ b/consumable.lua @@ -0,0 +1,308 @@ +Config.ConsumablesEat = { + ["sandwich"] = { + label = "Eating Sandwich", + progress = 5000, + emote = "sandwich", + fill = math.random(35, 54), + }, + ["tosti"] = { + label = "Eating Tosti", + progress = 5000, + emote = "croissant", + fill = math.random(40, 50), + }, + ["twerks_candy"] = { + label = "Eating Twerks Candy", + progress = 5000, + emote = "candyapple", + fill = math.random(35, 54), + }, + ["snikkel_candy"] = { + label = "Eating Snikkel Candy", + progress = 5000, + emote = "candyapple", + fill = math.random(40, 50), + } +} + +-- Drinking +Config.ConsumablesDrink = { + ["water_bottle"] = { + label = "Drinking Water", + progress = 5000, + emote = "water", + fill = math.random(35, 54), + }, + ["kurkakola"] = { + label = "Drinking Kurkakola", + progress = 5000, + emote = "soda", + fill = math.random(35, 54), + }, + ["coffee"] = { + label = "Drinking Coffee", + progress = 5000, + emote = "coffee", + fill = math.random(40, 50), + }, +} + +Config.ConsumablesAddiction = { + + -- Alcohol + + ["whiskey"] = { + label = "Drinking Whiskey", + progress = 5000, + emote = "whiskeyb2", + relieveStress = 10, + filltype = 'thirst', + fill = math.random(10, 20), + action = function() + AlcoholLoop() + end + }, + ["beer"] = { + label = "Drinking Beer", + progress = 5000, + emote = "beer3", + relieveStress = 10, + filltype = 'thirst', + fill = math.random(10, 20), + action = function() + AlcoholLoop() + end + }, + ["vodka"] = { + label = "Drinking Vodka", + progress = 5000, + prop = { + model = 'prop_vodka_bottle', + bone = 60309, + coords = vector3(-0.005, 0.00, -0.09), + rot = vector3(0.0, 0.0, 0.0), + }, + anim = { + lib = "mp_player_intdrink", + name = "loop_bottle", + flag = 49, + }, + relieveStress = 10, + filltype = 'thirst', + fill = math.random(10, 20), + action = function() + AlcoholLoop() + end + }, + + --drugs + + ["cokebaggy"] = { + label = "Snorting Coke", + progress = 5000, + anim = { + lib = "switch@trevor@trev_smoking_meth", + name = "trev_smoking_meth_loop", + flag = 49, + }, + relieveStress = 10, + action = function() + local function AlienEffect() + StartScreenEffect("DrugsMichaelAliensFightIn", 3.0, false) + Wait(math.random(5000, 8000)) + StartScreenEffect("DrugsMichaelAliensFight", 3.0, false) + Wait(math.random(5000, 8000)) + StartScreenEffect("DrugsMichaelAliensFightOut", 3.0, false) + StopScreenEffect("DrugsMichaelAliensFightIn") + StopScreenEffect("DrugsMichaelAliensFight") + StopScreenEffect("DrugsMichaelAliensFightOut") + end + + local startStamina = 20 + local ped = cache.ped + AlienEffect() + SetRunSprintMultiplierForPlayer(cache.playerId, 1.1) + while startStamina > 0 do + Wait(1000) + if math.random(1, 100) < 20 then + RestorePlayerStamina(cache.playerId, 1.0) + end + startStamina -= 1 + if math.random(1, 100) < 10 and IsPedRunning(ped) then + SetPedToRagdoll(ped, math.random(1000, 3000), math.random(1000, 3000), 3, false, false, false) + end + if math.random(1, 300) < 10 then + AlienEffect() + Wait(math.random(3000, 6000)) + end + end + if IsPedRunning(ped) then + SetPedToRagdoll(ped, math.random(1000, 3000), math.random(1000, 3000), 3, false, false, false) + end + SetRunSprintMultiplierForPlayer(cache.playerId, 1.0) + end + }, + ["crack_baggy"] = { + label = "Snorting Crack", + progress = 5000, + anim = { + lib = "switch@trevor@trev_smoking_meth", + name = "trev_smoking_meth_loop", + flag = 49, + }, + relieveStress = 10, + }, + ["meth"] = { + label = "Snorting Meth", + progress = 5000, + anim = { + lib = "switch@trevor@trev_smoking_meth", + name = "trev_smoking_meth_loop", + flag = 49, + }, + relieveStress = 10, + action = function () + local function TrevorEffect() + StartScreenEffect("DrugsTrevorClownsFightIn", 3.0, false) + Wait(3000) + StartScreenEffect("DrugsTrevorClownsFight", 3.0, false) + Wait(3000) + StartScreenEffect("DrugsTrevorClownsFightOut", 3.0, false) + StopScreenEffect("DrugsTrevorClownsFight") + StopScreenEffect("DrugsTrevorClownsFightIn") + StopScreenEffect("DrugsTrevorClownsFightOut") + end + + local startStamina = 8 + TrevorEffect() + SetRunSprintMultiplierForPlayer(cache.playerId, 1.49) + while startStamina > 0 do + Wait(1000) + if math.random(5, 100) < 10 then + RestorePlayerStamina(cache.playerId, 1.0) + end + startStamina = startStamina - 1 + if math.random(5, 100) < 51 then + TrevorEffect() + end + end + SetRunSprintMultiplierForPlayer(cache.playerId, 1.0) + end + }, + ["xtcbaggy"] = { + label = "Taking XTC", + progress = 5000, + anim = { + lib = "mp_suicide", + name = "pill", + flag = 49, + }, + relieveStress = 10, + action = function() + local startStamina = 30 + SetFlash(0, 0, 500, 7000, 500) + while startStamina > 0 do + Wait(1000) + startStamina -= 1 + RestorePlayerStamina(cache.playerId, 1.0) + if math.random(1, 100) < 51 then + SetFlash(0, 0, 500, 7000, 500) + ShakeGameplayCam('SMALL_EXPLOSION_SHAKE', 0.08) + end + end + if IsPedRunning(cache.ped) then + SetPedToRagdoll(cache.ped, math.random(1000, 3000), math.random(1000, 3000), 3, false, false, false) + end + end + }, + ["oxy"] = { + label = "Taking OXY", + progress = 5000, + anim = { + lib = "mp_suicide", + name = "pill", + flag = 49, + }, + relieveStress = 10, + }, + + --smoke + + ["joint"] = { + label = "Smoking Joint", + progress = 5000, + emote = "smokeweed", + relieveStress = 20, + }, +} + + +Config.ConsumablesItems = { + ['armor'] = { + label = 'Using Armor', + progress = 5000, --ms + anim = { + lib = 'clothingshirt', + name = 'try_shirt_positive_d', + flag = 49, + }, + removeItem = true, + action = function() + TriggerServerEvent('hospital:server:SetArmor', 50) + SetPedArmour(cache.ped, 50) + end + }, + ['heavyarmor'] = { + label = 'Using Armor', + progress = 5000, --ms + anim = { + lib = 'clothingshirt', + name = 'try_shirt_positive_d', + flag = 49, + }, + removeItem = true, + action = function() + TriggerServerEvent('hospital:server:SetArmor', 100) + SetPedArmour(cache.ped, 100) + end + }, + ['parachute'] = { + label = 'Preparing Parachute', + progress = 15000, --ms + anim = { + lib = 'clothingshirt', + name = 'try_shirt_positive_d', + flag = 49, + }, + removeItem = true, + action = function() + if not GetterParachute() then + local ped = cache.ped + GiveWeaponToPed(ped, `GADGET_PARACHUTE`, 1, false, false) + local ParachuteData = { + outfitData = { + ["bag"] = { item = 8, texture = 0}, -- Adding Parachute Clothing + } + } + TriggerEvent('qb-clothing:client:loadOutfit', ParachuteData) + SetterParachute(true) + end + end + }, +} + +Config.Fuckage = 2000 -- in MS + +-- Adjust the time to change how long the driver is forced into the random event. IN MS +-- There are more random events you can add on the fivem native wiki + +Config.RandomVehicleInteraction = { + {interaction = 27, time = 1500}, + {interaction = 6, time = 1000}, + {interaction = 7, time = 800}, --turn left and accel + {interaction = 8, time = 800}, --turn right and accel + {interaction = 10, time = 800}, --turn left and restore wheel pos + {interaction = 11, time = 800}, --turn right and restore wheel pos + {interaction = 23, time = 2000}, -- accel fast + {interaction = 31, time = 2000} -- accel fast and then handbrake +} \ No newline at end of file diff --git a/consumable.md b/consumable.md new file mode 100644 index 0000000..1ea3e0e --- /dev/null +++ b/consumable.md @@ -0,0 +1,111 @@ +** Add Eat AS Item ** +```lua +Config.ConsumablesEat = { + [itemName: string] = { + label? = `string`, -- text showing on progressbar + progress? = `number`, --ms + prop? = { + bone = `number`, + coords? = `vec(x, y, z)`, + rot? = `vec(x, y, z)`, + }, + anim? = { -- TaskPllayAnim + lib = `string`, + name = `string`, + flag = `number`, + }, + scenario? = string, -- TaskStartScenarioInPlace + emote? = string, -- emote on animation script name + relieveStress? = `number`, -- will relieve stress + fill = `number`, --- filling of hunger/thrist + action? = function(itemName: string) --- do some crazy stuff + print('Function Running') + end + } +} +``` + +** Add Drink AS Item ** +```lua +Config.ConsumablesDrink = { + [itemName: string] = { + label? = `string`, + progress? = `number`, --ms + prop? = { + bone = `number`, + coords? = `vec(x, y, z)`, + rot? = `vec(x, y, z)`, + }, + anim? = { + lib = `string`, + name = `string`, + flag = `number`, + }, + scenario? = `string`, + emote? = `string`, + relieveStress? = `number`, + fill = `number`, + action? = function(itemName: string) + print('Function Running') + end + } +} +``` + +** Add Addiction AS Item ** +```lua +Config.ConsumablesAddiction = { + [itemName: string] = { + label? = `string`, + progress? = `number`, --ms + prop? = { + bone = `number`, + coords? = `vec(x, y, z)`, + rot? = `vec(x, y, z)`, + }, + anim? = { + lib = `string`, + name = `string`, + flag = `number`, + }, + scenario? = `string`, + emote? = `string`, + relieveStress? = `number`, + filltype? = string (hunger|thirst), + fill = `number`, + action? = function(itemName: string) + print('Function Running') + end + } +} +``` + + +** Add Use Item ** +```lua +Config.ConsumablesAddiction = { + [itemName: string] = { + event? = `string`, -- any one of them (event/serverEvent) , if declared below lines will override + serverEvent? = `string`, -- any one of them (event/serverEvent) , if declared below lines will override + args? = `any`, + label? = `string`, + progress? = `number`, --ms + prop? = { + bone = `number`, + coords? = `vec(x, y, z)`, + rot? = `vec(x, y, z)`, + }, + anim? = { + lib = `string`, + name = `string`, + flag = `number`, + }, + scenario? = `string`, + emote? = `string`, + action? = function(itemName: string) + print('Function Running') + end + + } +} +``` \ No newline at end of file diff --git a/server/consumables.lua b/server/consumables.lua index b346192..b1fa284 100644 --- a/server/consumables.lua +++ b/server/consumables.lua @@ -1,224 +1,193 @@ ------------ / alcohol -for cAl in pairs(ConsumablesAlcohol) do - exports.qbx_core:CreateUseableItem(cAl, function(source, item) - local src = source - local player = exports.qbx_core:GetPlayer(src) - if player.Functions.RemoveItem(item.name, 1, item.slot) then - TriggerClientEvent('consumables:client:DrinkAlcohol', src, item.name) - end - end) -end - ------------ / Non-Alcoholic Drinks -for cDr in pairs(ConsumablesDrink) do - exports.qbx_core:CreateUseableItem(cDr, function(source, item) - local src = source - local player = exports.qbx_core:GetPlayer(src) - if player.Functions.RemoveItem(item.name, 1, item.slot) then - TriggerClientEvent('consumables:client:Drink', src, item.name) - end - end) -end - ------------ / Food -for cEa in pairs(ConsumablesEat) do - exports.qbx_core:CreateUseableItem(cEa, function(source, item) - local src = source - local player = exports.qbx_core:GetPlayer(src) - if player.Functions.RemoveItem(item.name, 1, item.slot) then - TriggerClientEvent('consumables:client:Eat', src, item.name) - end - end) -end - ------------ / Drug - -exports.qbx_core:CreateUseableItem('joint', function(source, item) - local player = exports.qbx_core:GetPlayer(source) - if not player.Functions.RemoveItem(item.name, 1, item.slot) then return end - TriggerClientEvent('consumables:client:UseJoint', source) -end) - -exports.qbx_core:CreateUseableItem('cokebaggy', function(source) - TriggerClientEvent('consumables:client:Cokebaggy', source) -end) - -exports.qbx_core:CreateUseableItem('crack_baggy', function(source) - TriggerClientEvent('consumables:client:Crackbaggy', source) -end) - -exports.qbx_core:CreateUseableItem('xtcbaggy', function(source, _) - TriggerClientEvent('consumables:client:EcstasyBaggy', source) -end) - -exports.qbx_core:CreateUseableItem('oxy', function(source) - TriggerClientEvent('consumables:client:oxy', source) -end) - -exports.qbx_core:CreateUseableItem('meth', function(source) - TriggerClientEvent('consumables:client:meth', source) -end) - ------------ / Tools - -exports.qbx_core:CreateUseableItem('armor', function(source) - TriggerClientEvent('consumables:client:UseArmor', source) -end) - -exports.qbx_core:CreateUseableItem('heavyarmor', function(source) - TriggerClientEvent('consumables:client:UseHeavyArmor', source) -end) - -lib.addCommand('resetvest', { - help = 'Resets Vest (Police Only)', -}, function(source) - local Player = exports.qbx_core:GetPlayer(source) - if Player.PlayerData.job.name == 'police' then - TriggerClientEvent('consumables:client:ResetArmor', source) - else - TriggerClientEvent('QBCore:Notify', source, 'For Police Officer Only', 'error') +lib.callback.register('consumables:server:AddHunger', function(source, item) + local src = source + local Player = exports.qbx_core:GetPlayer(src) + + if not Player then return false end + + if Player.Functions.RemoveItem(item, 1) then + local hunger = Player.PlayerData.metadata['hunger'] + (Config.ConsumablesEat[item].fill or 0) + hunger = hunger > 100 and 100 or hunger + Player.Functions.SetMetaData('hunger', hunger) + TriggerClientEvent('hud:client:UpdateNeeds', src, hunger, Player.PlayerData.metadata.thirst) + return true end -end) - -exports.qbx_core:CreateUseableItem('parachute', function(source, item) - local player = exports.qbx_core:GetPlayer(source) - if not player.Functions.RemoveItem(item.name, 1, item.slot) then return end - TriggerClientEvent('consumables:client:UseParachute', source) -end) - -lib.addCommand('resetparachute', { - help = 'Resets Parachute', -}, function(source) - TriggerClientEvent('consumables:client:ResetParachute', source) -end) - -RegisterNetEvent('qb-smallpenis:server:AddParachute', function() - local player = exports.qbx_core:GetPlayer(source) - - if not player then return end - - player.Functions.AddItem('parachute', 1) -end) - ------------ / Lockpicking - -exports.qbx_core:CreateUseableItem('lockpick', function(source) - TriggerClientEvent('lockpicks:UseLockpick', source, false) - TriggerEvent('lockpicks:UseLockpick', source, false) -end) - -exports.qbx_core:CreateUseableItem('advancedlockpick', function(source) - TriggerClientEvent('lockpicks:UseLockpick', source, true) - TriggerEvent('lockpicks:UseLockpick', source, true) -end) - ------------ / Unused - --- exports.qbx_core:CreateUseableItem('smoketrailred', function(source, item) --- local player = exports.qbx_core:GetPlayer(source) --- if not player.Functions.RemoveItem(item.name, 1, item.slot) then return end --- TriggerClientEvent('consumables:client:UseRedSmoke', source) --- end) - --- Events for adding and removing specific items to fix some exploits - -RegisterNetEvent('consumables:server:resetArmor', function() - local player = exports.qbx_core:GetPlayer(source) - - if not player then return end - player.Functions.AddItem('heavyarmor', 1) + return false end) -RegisterNetEvent('consumables:server:useHeavyArmor', function() - local player = exports.qbx_core:GetPlayer(source) +lib.callback.register('consumables:server:AddThirst', function(source, item) + local src = source + local Player = exports.qbx_core:GetPlayer(src) - if not player then return end + if not Player then return false end - player.Functions.RemoveItem('heavyarmor', 1) -end) - -RegisterNetEvent('consumables:server:useArmor', function() - local player = exports.qbx_core:GetPlayer(source) - - if not player then return end + if Player.Functions.RemoveItem(item, 1) then + local thirst = Player.PlayerData.metadata['thirst'] + (Config.ConsumablesDrink[item].fill or 0) + thirst = thirst > 100 and 100 or thirst + Player.Functions.SetMetaData('thirst', thirst) + TriggerClientEvent('hud:client:UpdateNeeds', src, Player.PlayerData.metadata.hunger, thirst) + return true + end - player.Functions.RemoveItem('armor', 1) + return false +end) + +lib.callback.register('consumables:server:useIllegal', function(source, item) + local src = source + local Player = exports.qbx_core:GetPlayer(src) + + if not Player then return false end + if Player.Functions.RemoveItem(item, 1) then + if Config.ConsumablesAddiction[item].fill then + if Config.ConsumablesAddiction[item].filltype == 'hunger' then + local hunger = Player.PlayerData.metadata['hunger'] + (Config.ConsumablesAddiction[item].fill or 0) + hunger = hunger > 100 and 100 or hunger + Player.Functions.SetMetaData('hunger', hunger) + TriggerClientEvent('hud:client:UpdateNeeds', src, hunger, Player.PlayerData.metadata.thirst) + elseif Config.ConsumablesAddiction[item].filltype == 'thirst' then + local thirst = Player.PlayerData.metadata['thirst'] + (Config.ConsumablesAddiction[item].fill or 0) + thirst = thirst > 100 and 100 or thirst + Player.Functions.SetMetaData('thirst', thirst) + TriggerClientEvent('hud:client:UpdateNeeds', src, Player.PlayerData.metadata.hunger, thirst) + end + end + return true + end + return false end) -RegisterNetEvent('consumables:server:useMeth', function() - local player = exports.qbx_core:GetPlayer(source) +lib.callback.register('consumables:server:useItem', function(source, item) + local src = source + local Player = exports.qbx_core:GetPlayer(src) - if not player then return end + if not Player then return false end - player.Functions.RemoveItem('meth', 1) -end) - -RegisterNetEvent('consumables:server:useOxy', function() - local player = exports.qbx_core:GetPlayer(source) - - if not player then return end + if not Config.ConsumablesItems[item].removeItem then return true end - player.Functions.RemoveItem('oxy', 1) + if Player.Functions.RemoveItem(item, 1) then + return true + end + return false end) -RegisterNetEvent('consumables:server:useXTCBaggy', function() - local player = exports.qbx_core:GetPlayer(source) - - if not player then return end +-- Add CreateUseable Events - player.Functions.RemoveItem('xtcbaggy', 1) -end) +----------- / alcohol +for k,_ in pairs(Config.ConsumablesAddiction) do + exports.qbx_core:CreateUseableItem(k, function(source, item) + TriggerClientEvent("consumables:client:Addiction", source, item.name) + end) +end -RegisterNetEvent('consumables:server:useCrackBaggy', function() - local player = exports.qbx_core:GetPlayer(source) +----------- / Eat +for k,_ in pairs(Config.ConsumablesEat) do + exports.qbx_core:CreateUseableItem(k, function(source, item) + TriggerClientEvent("consumables:client:Eat", source, item.name) + end) +end - if not player then return end +----------- / Drink +for k,_ in pairs(Config.ConsumablesDrink) do + exports.qbx_core:CreateUseableItem(k, function(source, item) + TriggerClientEvent("consumables:client:Drink", source, item.name) + end) +end - player.Functions.RemoveItem('crack_baggy', 1) -end) +----------- / Item +for k,_ in pairs(Config.ConsumablesItems) do + exports.qbx_core:CreateUseableItem(k, function(source, item) + local consume = Config.ConsumablesItems[item.name] + if consume.event then + TriggerClientEvent(consume.event, source, consume.args or nil) + elseif consume.serverEvent then + TriggerEvent(consume.serverEvent, source, consume.args or nil) + else + TriggerClientEvent("consumables:client:Item", source, item.name) + end + end) +end -RegisterNetEvent('consumables:server:useCokeBaggy', function() - local player = exports.qbx_core:GetPlayer(source) - if not player then return end +----------- / external useable item +local function CreateItem(name,type) + exports.qbx_core:CreateUseableItem(name, function(source, item) + TriggerClientEvent("consumables:client:"..type, source, item.name) + end) +end - player.Functions.RemoveItem('cokebaggy', 1) -end) +local function AddDrink(drinkname, replenish) + if Config.ConsumablesDrink[drinkname] ~= nil then + return {false, "already added"} + else + Config.ConsumablesDrink[drinkname] = replenish + CreateItem(drinkname, 'Drink') + return {true, "success"} + end +end -RegisterNetEvent('consumables:server:drinkAlcohol', function(item) - local player = exports.qbx_core:GetPlayer(source) +exports('AddDrink', AddDrink) - if not player then return end +local function AddFood(foodname, replenish) + if Config.ConsumablesEat[foodname] ~= nil then + return {false, "already added"} + else + Config.ConsumablesEat[foodname] = replenish + CreateItem(foodname, 'Eat') + return {true, "success"} + end +end - local foundItem = nil +exports('AddFood', AddFood) - for k in pairs(ConsumablesAlcohol) do - if k == item then - foundItem = k - break - end +local function Addiction(alcoholname, replenish) + if Config.ConsumablesAlcohol[alcoholname] ~= nil then + return {false, "already added"} + else + Config.ConsumablesAlcohol[alcoholname] = replenish + CreateItem(alcoholname, 'Addiction') + return {true, "success"} end +end - if not foundItem then return end +exports('Addiction', Addiction) - player.Functions.RemoveItem(foundItem, 1) +lib.addCommand('adminheal', { + help = 'Admin heal command', + params = {}, + restricted = 'group.admin' +}, function(source) + local src = source + local Player = exports.qbx_core:GetPlayer(src) + if not Player then return false end + Player.Functions.SetMetaData('hunger', 100) + Player.Functions.SetMetaData('thirst', 100) + TriggerClientEvent('hud:client:UpdateNeeds', src, 100, 100) +end) + +lib.addCommand('adminremove', { + help = 'Admin Thirsty command', + params = {}, + restricted = 'group.admin' +}, function(source) + local src = source + local Player = exports.qbx_core:GetPlayer(src) + if not Player then return false end + Player.Functions.SetMetaData('hunger', 10) + Player.Functions.SetMetaData('thirst', 10) + TriggerClientEvent('hud:client:UpdateNeeds', src, 10, 10) end) -RegisterNetEvent('consumables:server:addThirst', function(amount) - local player = exports.qbx_core:GetPlayer(source) - - if not player then return end - - player.Functions.SetMetaData('thirst', amount) - TriggerClientEvent('hud:client:UpdateNeeds', source, player.PlayerData.metadata.hunger, amount) +lib.addCommand("removeparachute", { + help = 'Take off your Parachute', + params = {}, +}, function(source) + TriggerClientEvent("consumables:client:ResetParachute", source) end) -RegisterNetEvent('consumables:server:addHunger', function(amount) - local player = exports.qbx_core:GetPlayer(source) +RegisterNetEvent('consumables:server:AddParachute', function() + local Player = exports.qbx_core:GetPlayer(source) - if not player then return end + if not Player then return end - player.Functions.SetMetaData('hunger', amount) - TriggerClientEvent('hud:client:UpdateNeeds', source, amount, player.PlayerData.metadata.thirst) -end) + Player.Functions.AddItem("parachute", 1) +end) \ No newline at end of file