mirror of
https://github.com/jimathy/jim-consumables.git
synced 2026-08-17 06:26:03 +01:00
1.5 - ox_prog/correct emotes/import system update
Refactor Support for ox_progressbar Sorted out the fucking default emotes Item/Emote System update, works better and syncs better Update Readme to reflect the chagnes
This commit is contained in:
76
README.md
76
README.md
@@ -1,38 +1,51 @@
|
||||
# jim-consumables
|
||||
# Jim-Consumables
|
||||
Consumables script for QBCore
|
||||
|
||||
# What is this?
|
||||
This script is designed as a replacement/override for food and drink consumables in qb-smallresources
|
||||
This script is designed as a replacement/override for food and drink consumables in `qb-smallresources`
|
||||
|
||||
It's main purpose was to make it possible to not stand up while sitting due to lazy events such as ClearPedTasks in most scripts, this one is designed to cancel the animation you have chosen, not all animations. This includes progressbar.
|
||||
It's main purpose was to make it so players did not stand up while sitting with my scripts due to lazy events such as ClearPedTasks in progressbar and dpemotes, this one is designed to cancel the animation you have chosen, not all animations.
|
||||
|
||||
## v1.4 Beta Information
|
||||
I've added a export system that allows scripts to easily add new foods and drinks to be usable and then sync them between players
|
||||
This should work but may have issues.
|
||||
It's recommended to set `Config.UseProgBar` to `false` to get this effect.
|
||||
|
||||
But because of the export system being used, Jim-Consumables **NEEDS** to start before any scripts that use it.
|
||||
## v1.5 Update Information
|
||||
I've added a export system that allows scripts to easily add new foods and drinks to be usable and then sync them between players
|
||||
This should work but may have issues.
|
||||
|
||||
And small example snippet for this imports the item and the emote, then syncs it to players
|
||||
But because of the export system being used, Jim-Consumables **NEEDS** to start before any scripts that use it.
|
||||
|
||||
```lua
|
||||
local foodTable = {
|
||||
["shotfries"] = { emote = "bsfries", canRun = false, time = math.random(5000, 6000), stress = math.random(2, 4), heal = 0, armor = 0, type = "food", stats = { hunger = math.random(55,65), }},
|
||||
}
|
||||
local emoteTable = {
|
||||
["bsfries"] = {"mp_player_inteat@burger", "mp_player_int_eat_burger_fp", "Fries", AnimationOptions = { Prop = "prop_food_bs_chips", PropBone = 18905, PropPlacement = {0.09, -0.06, 0.05, 300.0, 150.0}, EmoteMoving = true, EmoteLoop = true, }},
|
||||
}
|
||||
|
||||
for k, v in pairs(emoteTable) do exports["jim-consumables"]:importEmote(k, v) end
|
||||
for k, v in pairs(foodTable) do exports["jim-consumables"]:importConsumable(k, v) end
|
||||
```
|
||||
This will grab the `shotfries` item info and add it to the `Config.Consumables` while the servers running and the same with the built-in emote system
|
||||
This will be built into my scripts that use consumables to make it more plug and play
|
||||
|
||||
# Installation
|
||||
|
||||
This script is recommended to be ran last/at the bottom of your server.cfg because this is intended to take control of items, if ran too early the original script may override this one.
|
||||
- I always recommend starting my scripts **AFTER** `[qb]` not inside it as it can mess with any dependancies on server load
|
||||
- I have a separate folder called `[jimextras]` (that is also in the resources folder) that starts before any scripts would use it.
|
||||
- This ensure's it has everything it requires before trying to load
|
||||
- Example of my load order:
|
||||
```CSS
|
||||
# QBCore & Extra stuff
|
||||
ensure qb-core
|
||||
ensure [qb]
|
||||
ensure [standalone]
|
||||
ensure [voice]
|
||||
ensure [defaultmaps]
|
||||
ensure [vehicles]
|
||||
|
||||
It already takes control of default qbcore food and drink, but you would probably want to add more.
|
||||
# Extra Jim Stuff
|
||||
ensure [jimextras]
|
||||
ensure [jim]
|
||||
```
|
||||
|
||||
## QB-SmallResources
|
||||
|
||||
- It should already take control of default qbcore food, drink and drugs.
|
||||
- If it fails to do this and attempts to use qb-smallresources still you will need to:
|
||||
- `[qb]` > `qb-smallresources` > `server` > `consumables.lua`
|
||||
- Remove or comment out the `CreateUseableItem` events for *alcohol*, *eat*, *drink* and *drug* in this file
|
||||
- Not all of them! (such as armour related items)
|
||||
- This ***should*** stop `qb-smallresources` taking control and confusing `jim-consumables`
|
||||
|
||||
## New Items
|
||||
To add an item, you only need to add a new item table in the Config.Consumables like this:
|
||||
```lua
|
||||
["heartstopper"] = {
|
||||
@@ -89,3 +102,22 @@ If this script is enabled it will automatically try to use their system to apply
|
||||
```
|
||||
|
||||
This script supports dpemotes style emotes, so if you have some that you want to be triggered when eating or drinking drop it in the Config.Emotes section.
|
||||
|
||||
|
||||
## Add consumables from external scripts
|
||||
|
||||
A small example of a server-sided snippet for this imports the item and the emote, then syncs it to players before and after they connect.
|
||||
|
||||
```lua
|
||||
local foodTable = {
|
||||
["shotfries"] = { emote = "bsfries", canRun = false, time = math.random(5000, 6000), stress = math.random(2, 4), heal = 0, armor = 0, type = "food", stats = { hunger = math.random(55,65), }},
|
||||
}
|
||||
|
||||
local emoteTable = {
|
||||
["bsfries"] = {"mp_player_inteat@burger", "mp_player_int_eat_burger_fp", "Fries", AnimationOptions = { Prop = "prop_food_bs_chips", PropBone = 18905, PropPlacement = {0.09, -0.06, 0.05, 300.0, 150.0}, EmoteMoving = true, EmoteLoop = true, }},
|
||||
}
|
||||
|
||||
for k, v in pairs(foodTable) do TriggerEvent("jim-consumables:server:syncAddItem", k, v) end
|
||||
for k, v in pairs(emoteTable) do TriggerEvent("jim-consumables:server:syncAddEmote", k, v) end
|
||||
```
|
||||
This will grab the `shotfries` item info and add it to the `Config.Consumables` while the servers running and the same with the built-in emote system
|
||||
@@ -1,46 +1,58 @@
|
||||
local QBCore = exports['qb-core']:GetCoreObject()
|
||||
local QBCore = exports[Config.Core]:GetCoreObject()
|
||||
|
||||
local alcoholCount = 0
|
||||
local drugCount = 0
|
||||
local alcoholCount, drugCount, consuming, cancelled = 0, 0, false, false
|
||||
local Consumables, Emotes = {}, {}
|
||||
|
||||
--Convert Prop Model Names to Model HashKeys now to be more optimized when loading later
|
||||
for k in pairs(Config.Emotes) do
|
||||
if Config.Emotes[k].AnimationOptions.Prop then
|
||||
Config.Emotes[k].AnimationOptions.Prop = GetHashKey(Config.Emotes[k].AnimationOptions.Prop)
|
||||
if Config.Emotes[k].AnimationOptions.SecondProp then
|
||||
Config.Emotes[k].AnimationOptions.SecondProp = GetHashKey(Config.Emotes[k].AnimationOptions.SecondProp)
|
||||
local function propConvert() --Convert Prop Model Names to Model HashKeys now to be more optimized when loading later
|
||||
for k in pairs(Emotes) do
|
||||
if Emotes[k].AnimationOptions.Prop then
|
||||
Emotes[k].AnimationOptions.Prop = GetHashKey(Emotes[k].AnimationOptions.Prop)
|
||||
if Emotes[k].AnimationOptions.SecondProp then
|
||||
Emotes[k].AnimationOptions.SecondProp = GetHashKey(Emotes[k].AnimationOptions.SecondProp)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
local consuming = false
|
||||
local cancelled = false
|
||||
local function syncConsumables()
|
||||
local p = promise.new() QBCore.Functions.TriggerCallback('jim-consumables:server:syncConsumables', function(cb) p:resolve(cb) end) Consumables = Citizen.Await(p)
|
||||
local p2 = promise.new() QBCore.Functions.TriggerCallback('jim-consumables:server:syncEmotes', function(cb) p2:resolve(cb) end) Emotes = Citizen.Await(p2)
|
||||
if Config.Debug then print("^5Debug^7: ^2Retrieved ^6"..countTable(Consumables).." ^2Items and ^6"..countTable(Emotes).." ^2Emotes^7") end
|
||||
propConvert()
|
||||
end
|
||||
|
||||
AddEventHandler('onResourceStart', function(r) if GetCurrentResourceName() ~= r then return end TriggerServerEvent("jim-consumables:getSync") end)
|
||||
RegisterNetEvent('QBCore:Client:OnPlayerLoaded', function() TriggerServerEvent("jim-consumables:getSync") end)
|
||||
RegisterNetEvent("jim-consumables:syncItems", function(consumables, emotes)
|
||||
if consumables then for k, v in pairs(consumables) do if not Config.Consumables[k] then Config.Consumables[k] = v print("^5Debug^7 ^2Adding Item^7: '^6"..k.."^7'") end end end
|
||||
if emotes then for k, v in pairs(emotes) do if not Config.Emotes[k] then Config.Emotes[k] = v print("^5Debug^7 ^2Adding Emote^7: '^6"..k.."^7'") end end end
|
||||
RegisterNetEvent("jim-consumables:client:syncConsumables", function(NewConsumables)
|
||||
if Config.Debug then for k, v in pairs(NewConsumables) do if not Consumables[k] then print("^5Debug^7: ^2New Item Info added^7: ^6"..k.."^7") end end end
|
||||
Consumables = NewConsumables
|
||||
end)
|
||||
RegisterNetEvent("jim-consumables:client:syncEmotes", function(NewEmotes)
|
||||
if Config.Debug then for k, v in pairs(NewEmotes) do if not Emotes[k] then print("^5Debug^7: ^2New Emote Info added^7: ^6"..k.."^7") end end end
|
||||
Emotes = NewEmotes
|
||||
propConvert()
|
||||
end)
|
||||
|
||||
AddEventHandler('onResourceStart', function(r) if GetCurrentResourceName() ~= r then return end syncConsumables() end)
|
||||
RegisterNetEvent('QBCore:Client:OnPlayerLoaded', function() syncConsumables() end)
|
||||
|
||||
RegisterNetEvent('jim-consumables:Consume', function(itemName)
|
||||
if not HasItem(itemName, 1) then print("^5Debug^7: ^1Error^7: ^2Item not found in inventory^7, ^2stopping^7..") end
|
||||
if Config.Debug then print("^5Debug^7: ^3Consume^7: ^2Starting event, locking inventory and grabbing data^7..") end
|
||||
LocalPlayer.state:set("inv_busy", true, true) TriggerEvent('inventory:client:busy:status', true) TriggerEvent('canUseInventoryAndHotbar:toggle', false)
|
||||
local Player = PlayerPedId()
|
||||
local emote = Config.Emotes[Config.Consumables[itemName].emote] or Config.Emotes["crisps"]
|
||||
local returnItem = Config.Consumables[itemName].returnItem or nil
|
||||
local emote = Emotes[Consumables[itemName].emote] or Emotes["crisps"]
|
||||
local returnItem = Consumables[itemName].returnItem or nil
|
||||
local animDict, anim = tostring(emote[1]), tostring(emote[2])
|
||||
local model, model2, bone, bone2, drugeffect, stress
|
||||
local P1, P2, P3, P4, P5, P6, P7, P8, P9, P10, P11, P12 = table.unpack({0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0}) -- Default placement coord cariable
|
||||
local RewardItem = Config.Consumables[itemName].rewards or nil
|
||||
local time = Config.Consumables[itemName].time or math.random(5000, 6000)
|
||||
local type = Config.Consumables[itemName].type or ""
|
||||
local stress = Config.Consumables[itemName].stress or 0
|
||||
local heal = Config.Consumables[itemName].heal or 0
|
||||
local armor = Config.Consumables[itemName].armor or 0
|
||||
local RewardItem = Consumables[itemName].rewards or nil
|
||||
local time = Consumables[itemName].time or math.random(5000, 6000)
|
||||
local type = Consumables[itemName].type or ""
|
||||
local stress = Consumables[itemName].stress or 0
|
||||
local heal = Consumables[itemName].heal or 0
|
||||
local armor = Consumables[itemName].armor or 0
|
||||
local stats = Consumables[itemName].stats or nil
|
||||
local string = "Using "
|
||||
|
||||
local canRun = Consumables[itemName].canRun
|
||||
if emote.AnimationOptions.Prop then
|
||||
model = emote.AnimationOptions.Prop
|
||||
bone = GetPedBoneIndex(Player, emote.AnimationOptions.PropBone)
|
||||
@@ -59,7 +71,8 @@ RegisterNetEvent('jim-consumables:Consume', function(itemName)
|
||||
if Config.Debug then print("^5Debug^7: ^3Consume^7: ^2Event already started^7, ^1Cancelling^7.") end
|
||||
LocalPlayer.state:set("inv_busy", false, true)
|
||||
if Config.UseProgbar then
|
||||
TriggerEvent("progressbar:client:cancel")
|
||||
if Config.ProgressBar == "ox" then export.ox_lib:cancelProgress()
|
||||
else TriggerEvent("progressbar:client:cancel") end
|
||||
else
|
||||
triggerNotify(nil, "Stopped "..string, "error")
|
||||
end
|
||||
@@ -69,23 +82,25 @@ RegisterNetEvent('jim-consumables:Consume', function(itemName)
|
||||
--Emote Stuff
|
||||
if Config.Debug then print("^5Debug^7: ^3Consume^7: ^2Grabbing Emote Animation Options^7...") end
|
||||
local InVehicle = IsPedInAnyVehicle(Player, true)
|
||||
if Config.Debug then print("^5Debug^7: ^3Consume^7: ^Player is in a vehicle^7..."..json.encode(InVehicle).." ") end
|
||||
if Config.Debug then print("^5Debug^7: ^3Consume^7: ^2Checking if player is in a vehicle^7...") end
|
||||
if InVehicle == 1 then MovementType = 51
|
||||
if Config.Debug then print("^5Debug^7: ^3Consume^7: ^2Checking if player is in a vehicle^7 - ^6"..tostring(InVehicle).."^7") end
|
||||
if InVehicle == 1 then MovementType = 51
|
||||
elseif emote.AnimationOptions then
|
||||
if emote.AnimationOptions.EmoteMoving then MovementType = 51
|
||||
elseif emote.AnimationOptions.EmoteLoop then MovementType = 1
|
||||
elseif emote.AnimationOptions.EmoteStuck then MovementType = 50
|
||||
elseif emote.AnimationOptions.EmoteMoving == false then MovementType = 0
|
||||
end
|
||||
elseif emote.AnimationOptions.EmoteMoving == false then MovementType = 0 end
|
||||
end
|
||||
--Load and Start animation
|
||||
if Config.Debug then print("^5Debug^7: ^3Consume^7: ^2Playing Animation^7...") end
|
||||
loadAnimDict(animDict)
|
||||
TaskPlayAnim(Player, animDict, anim, 1.0, 1.0, -1, MovementType, 0, 0, 0, 0)
|
||||
if Config.Debug then print("^5Debug^7: ^3Consume^7: ^Player Movement Type is^7..."..json.encode(MovementType).." ") end
|
||||
if Config.Debug then print("^5Debug^7: ^3Consume^7: ^2Player Movement Type^7 - ^6"..json.encode(MovementType).." ^7") end
|
||||
if Config.UseProgbar then
|
||||
QBCore.Functions.Progressbar('jimmy_consume_', string..QBCore.Shared.Items[itemName].label.."..", time, false, false, {disableMovement = false, disableCarMovement = false, disableMouse = false, disableCombat = true,}, {}, {}, {}, function() consuming = false end, function() end, itemName)
|
||||
if Config.ProgressBar == "ox" then
|
||||
CreateThread(function() if exports.ox_lib:progressBar({ duration = time, label = string..QBCore.Shared.Items[itemName].label.."..", useWhileDead = false, canCancel = false,}) then consuming = false else end end)
|
||||
else
|
||||
CreateThread(function() QBCore.Functions.Progressbar('jimmy_consume_', string..QBCore.Shared.Items[itemName].label.."..", time, false, false, {disableMovement = false, disableCarMovement = false, disableMouse = false, disableCombat = true,}, {}, {}, {}, function() consuming = false end, function() end, itemName) end)
|
||||
end
|
||||
else
|
||||
triggerNotify(nil, string..QBCore.Shared.Items[itemName].label.."..", "success")
|
||||
end
|
||||
@@ -112,20 +127,21 @@ RegisterNetEvent('jim-consumables:Consume', function(itemName)
|
||||
end)
|
||||
while consuming do
|
||||
if time <= 0 then consuming = false end
|
||||
if not Config.Consumables[itemName].canRun then
|
||||
if not canRun then
|
||||
if IsControlJustPressed(0, 21) then
|
||||
consuming = false
|
||||
cancelled = true
|
||||
LocalPlayer.state:set("inv_busy", false, true)
|
||||
if Config.UseProgbar then
|
||||
TriggerEvent("progressbar:client:cancel")
|
||||
if Config.ProgressBar == "ox" then export.ox_lib:cancelProgress()
|
||||
else TriggerEvent("progressbar:client:cancel") end
|
||||
else
|
||||
triggerNotify(nil, "Cancelled "..string, "error")
|
||||
end
|
||||
end
|
||||
end
|
||||
Wait(10)
|
||||
time -= 10
|
||||
Wait(9)
|
||||
time -= 11
|
||||
end
|
||||
StopEntityAnim(Player, anim, animDict, 1.0)
|
||||
unloadAnimDict(animDict)
|
||||
@@ -136,7 +152,7 @@ RegisterNetEvent('jim-consumables:Consume', function(itemName)
|
||||
-- Reward Item calculations
|
||||
CreateThread(function()
|
||||
if RewardItem then
|
||||
for i = 1, Config.Consumables[itemName].amounttogive do
|
||||
for i = 1, Consumables[itemName].amounttogive do
|
||||
local rarity = math.random(1, countTable(Config.Rarity)) -- rarity calculation
|
||||
while true do
|
||||
local item = math.random(1, countTable(RewardItem)) -- random item in the list to pick
|
||||
@@ -151,15 +167,11 @@ RegisterNetEvent('jim-consumables:Consume', function(itemName)
|
||||
end
|
||||
end
|
||||
end)
|
||||
local hunger = 0
|
||||
local thirst = 0
|
||||
if Config.Consumables[itemName].stats then
|
||||
if Config.Consumables[itemName].stats.hunger then hunger = Config.Consumables[itemName].stats.hunger end
|
||||
TriggerServerEvent("jim-consumables:server:addHunger", QBCore.Functions.GetPlayerData().metadata["hunger"] + hunger)
|
||||
if Config.Consumables[itemName].stats.thirst then thirst = Config.Consumables[itemName].stats.thirst end
|
||||
TriggerServerEvent("jim-consumables:server:addThirst", QBCore.Functions.GetPlayerData().metadata["thirst"] + thirst)
|
||||
if stats then
|
||||
if stats.hunger then TriggerServerEvent("jim-consumables:server:addNeed", QBCore.Functions.GetPlayerData().metadata["hunger"] + stats.hunger, "hunger") end
|
||||
if stats.thirst then TriggerServerEvent("jim-consumables:server:addNeed", QBCore.Functions.GetPlayerData().metadata["thirst"] + stats.thirst, "thirst") end
|
||||
end
|
||||
if Config.Debug then print("^5Debug^7: ^2Hunger^7: [^6"..hunger.."^7] ^2Thrist^7: [^6"..thirst.."^7]" ) end
|
||||
if Config.Debug then print("^5Debug^7: ^2Hunger^7: [^6"..(stats.hunger or 0).."^7] ^2Thrist^7: [^6"..(stats.thirst or 0).."^7]" ) end
|
||||
if stress and stress ~= 0 then
|
||||
if Config.Debug then print("^5Debug^7: ^3Consume^7: ^2Reliving ^6"..stress.." ^2stress^7.") end
|
||||
TriggerServerEvent('hud:server:RelieveStress', stress)
|
||||
@@ -182,8 +194,7 @@ RegisterNetEvent('jim-consumables:Consume', function(itemName)
|
||||
CreateThread(function() AlienEffect() end) -- Used as overdosing/too drunk effect
|
||||
end
|
||||
end
|
||||
stats = Config.Consumables[itemName].stats or nil
|
||||
if Config.Consumables[itemName].stats then
|
||||
if stats then
|
||||
if stats.screen then -- Screen effect activation
|
||||
if stats.screen == "turbo" then CreateThread(function() TurboEffect() end) end
|
||||
if stats.screen == "focus" then CreateThread(function() FocusEffect() end) end
|
||||
|
||||
73
config.lua
73
config.lua
@@ -6,12 +6,13 @@ print("^2Jim^7-^2Consumables ^7v^41^7.^45 ^7- ^2Consumables Script by ^1Jimathy^
|
||||
|
||||
Config = {
|
||||
Debug = false,
|
||||
|
||||
Inv = "qb", -- set to "ox" if using ox_ivnentory
|
||||
|
||||
Notify = "qb",
|
||||
|
||||
Core = "qb-core",
|
||||
|
||||
Inv = "qb", -- set to "ox" if using ox_inventory
|
||||
Notify = "qb", -- set to "ox" if using ox_lib
|
||||
|
||||
UseProgbar = false,
|
||||
ProgressBar = "qb", -- set to "ox" if using ox_lib
|
||||
|
||||
Consumables = {
|
||||
-- Default QB food and drink item override
|
||||
@@ -84,48 +85,30 @@ Config = {
|
||||
["drink"] = {"mp_player_intdrink", "loop_bottle", "Drink", AnimationOptions =
|
||||
{ Prop = "prop_ld_flow_bottle", PropBone = 18905, PropPlacement = {0.12, 0.008, 0.03, 240.0, -60.0},
|
||||
EmoteMoving = true, EmoteLoop = true, }},
|
||||
["whiskeyb"] = {"mp_player_intdrink", "loop_bottle", "(Don't Use) Whiskey Bottle", AnimationOptions =
|
||||
{ Prop = "prop_cs_whiskey_bottle", PropBone = 60309, PropPlacement = {0.0, 0.0, 0.0, 0.0, 0.0},
|
||||
EmoteMoving = true, EmoteLoop = true }},
|
||||
["rumb"] = {"mp_player_intdrink", "loop_bottle", "(Don't Use) Rum Bottle", AnimationOptions =
|
||||
{ Prop = "prop_rum_bottle", PropBone = 18905, PropPlacement = {0.03, -0.18, 0.10, 240.0, -60.0},
|
||||
EmoteMoving = true, EmoteLoop = true }},
|
||||
["icream"] = {"mp_player_intdrink", "loop_bottle", "Irish Cream Bottle", AnimationOptions =
|
||||
{ Prop = "prop_bottle_brandy", PropBone = 18905, PropPlacement = {0.00, -0.26, 0.10, 240.0, -60.0},
|
||||
EmoteMoving = true, EmoteLoop = true }},
|
||||
["ginb"] = {"mp_player_intdrink", "loop_bottle", "(Don't Use) Gin Bottle", AnimationOptions =
|
||||
{ Prop = "prop_tequila_bottle", PropBone = 18905, PropPlacement = {0.00, -0.26, 0.10, 240.0, -60.0},
|
||||
EmoteMoving = true, EmoteLoop = true }},
|
||||
["coffee"] = {"amb@world_human_drinking@coffee@male@idle_a", "idle_c", "Coffee", AnimationOptions =
|
||||
{ Prop = 'p_amb_coffeecup_01', PropBone = 28422, PropPlacement = {0.0,0.0,0.0,0.0,0.0,0.0},
|
||||
EmoteLoop = true, EmoteMoving = true }},
|
||||
["burger"] = { "mp_player_inteat@burger", "mp_player_int_eat_burger", "Burger", AnimationOptions =
|
||||
{ Prop = 'prop_cs_burger_01', PropBone = 18905, PropPlacement = {0.13,0.05,0.02,-50.0,16.0,60.0},
|
||||
EmoteMoving = true }},
|
||||
["beer"] = {"amb@world_human_drinking@beer@male@idle_a", "idle_c", "Beer", AnimationOptions =
|
||||
{ Prop = 'prop_amb_beer_bottle', PropBone = 28422, PropPlacement = {0.0,0.0,0.06,0.0,15.0,0.0},
|
||||
EmoteLoop = true, EmoteMoving = true }},
|
||||
["egobar"] = {"mp_player_inteat@burger", "mp_player_int_eat_burger","Ego Bar", AnimationOptions =
|
||||
{ Prop = 'prop_choc_ego', PropBone = 60309, PropPlacement ={0.0,0.0,0.0,0.0,0.0,0.0},
|
||||
EmoteMoving = true }},
|
||||
["sandwich"] = {"mp_player_inteat@burger", "mp_player_int_eat_burger", "Sandwich", AnimationOptions =
|
||||
{ Prop = 'prop_sandwich_01', PropBone = 18905, PropPlacement = {0.13,0.05,0.02,-50.0,16.0,60.0},
|
||||
EmoteMoving = true }},
|
||||
["smoke3"] = { "amb@world_human_aa_smoke@male@idle_a", "idle_b", "Smoke 3", AnimationOptions =
|
||||
{ Prop = 'prop_cs_ciggy_01', PropBone = 28422, PropPlacement = {0.0,0.0,0.0,0.0,0.0,0.0},
|
||||
EmoteLoop = true, EmoteMoving = true }},
|
||||
["whiskey"] = { "amb@world_human_drinking@coffee@male@idle_a", "idle_c", "Whiskey", AnimationOptions =
|
||||
{ Prop = 'prop_drink_whisky', PropBone = 28422, PropPlacement = {0.01,-0.01,-0.06,0.0,0.0,0.0},
|
||||
EmoteLoop = true, EmoteMoving = true } },
|
||||
["vodkab"] = {"mp_player_intdrink", "loop_bottle", "(Don't Use) Vodka Bottle", AnimationOptions =
|
||||
{ Prop = 'prop_vodka_bottle', PropBone = 18905, PropPlacement = {0.00, -0.26, 0.10, 240.0, -60.0},
|
||||
EmoteMoving = true, EmoteLoop = true }},
|
||||
["crisps"] = {"amb@world_human_drinking@coffee@male@idle_a", "idle_c", "Chrisps", AnimationOptions =
|
||||
{ Prop = 'v_ret_ml_chips2', PropBone = 28422, PropPlacement = {0.01, -0.05, -0.1, 0.0, 0.0, 90.0},
|
||||
EmoteLoop = true, EmoteMoving = true, }},
|
||||
["beer1"] = {"mp_player_intdrink", "loop_bottle", "Dusche", AnimationOptions =
|
||||
{ Prop = "prop_beerdusche", PropBone = 18905, PropPlacement = {0.04, -0.14, 0.10, 240.0, -60.0},
|
||||
EmoteMoving = true, EmoteLoop = true, }},
|
||||
["beer2"] = {"mp_player_intdrink", "loop_bottle", "Logger", AnimationOptions =
|
||||
{ Prop = "prop_beer_logopen", PropBone = 18905, PropPlacement = {0.03, -0.18, 0.10, 240.0, -60.0},
|
||||
EmoteMoving = true, EmoteLoop = true, }},
|
||||
["beer3"] = {"mp_player_intdrink", "loop_bottle", "AM Beer", AnimationOptions =
|
||||
{ Prop = "prop_beer_amopen", PropBone = 18905, PropPlacement = {0.03, -0.18, 0.10, 240.0, -60.0},
|
||||
EmoteMoving = true, EmoteLoop = true, }},
|
||||
["beer4"] = {"mp_player_intdrink", "loop_bottle", "Pisswasser1", AnimationOptions =
|
||||
{ Prop = "prop_beer_pissh", PropBone = 18905, PropPlacement = {0.03, -0.18, 0.10, 240.0, -60.0},
|
||||
EmoteMoving = true, EmoteLoop = true, }},
|
||||
["beer5"] = {"mp_player_intdrink", "loop_bottle", "Pisswasser2", AnimationOptions =
|
||||
{ Prop = "prop_amb_beer_bottle", PropBone = 18905, PropPlacement = {0.12, 0.008, 0.03, 240.0, -60.0},
|
||||
EmoteMoving = true, EmoteLoop = true, }},
|
||||
["beer6"] = {"mp_player_intdrink", "loop_bottle", "Pisswasser3", AnimationOptions =
|
||||
{ Prop = "prop_cs_beer_bot_02", PropBone = 18905, PropPlacement = {0.12, 0.008, 0.03, 240.0, -60.0},
|
||||
EmoteMoving = true, EmoteLoop = true, }},
|
||||
["ecola"] = {"mp_player_intdrink", "loop_bottle", "E-cola", AnimationOptions =
|
||||
{ Prop = "prop_ecola_can", PropBone = 18905, PropPlacement = {0.12, 0.008, 0.03, 240.0, -60.0},
|
||||
EmoteMoving = true, EmoteLoop = true, }},
|
||||
["sprunk"] = {"mp_player_intdrink", "loop_bottle", "Sprunk", AnimationOptions =
|
||||
{ Prop = "v_res_tt_can03", PropBone = 18905, PropPlacement = {0.12, 0.008, 0.03, 240.0, -60.0},
|
||||
EmoteMoving = true, EmoteLoop = true, }},
|
||||
--Drugs
|
||||
["coke"] = { "switch@trevor@trev_smoking_meth", "trev_smoking_meth_loop", "Coke", AnimationOptions =
|
||||
{ EmoteLoop = true, EmoteMoving = true, }},
|
||||
@@ -144,4 +127,4 @@ Config = {
|
||||
{ Prop = 'prop_amb_ciggy_01', PropBone = 47419, PropPlacement = {0.015, -0.009, 0.003, 55.0, 0.0, 110.0},
|
||||
EmoteMoving = true, EmoteDuration = 2600 }},
|
||||
},
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,6 @@
|
||||
name "Jim-Consumables"
|
||||
author "Jimathy"
|
||||
version "v1.5"
|
||||
version "1.5"
|
||||
description "Consumable Script By Jimathy"
|
||||
fx_version "cerulean"
|
||||
game "gta5"
|
||||
|
||||
@@ -1,4 +1,7 @@
|
||||
local QBCore = exports['qb-core']:GetCoreObject()
|
||||
local QBCore = exports[Config.Core]:GetCoreObject()
|
||||
|
||||
local Consumables = Config.Consumables
|
||||
local Emotes = Config.Emotes
|
||||
|
||||
for k, v in pairs(Config.Consumables) do
|
||||
QBCore.Functions.CreateUseableItem(k, function(source, item) TriggerClientEvent('jim-consumables:Consume', source, item.name) end)
|
||||
@@ -41,37 +44,27 @@ RegisterNetEvent('jim-consumables:server:toggleItem', function(give, item, amoun
|
||||
end
|
||||
end)
|
||||
|
||||
RegisterNetEvent('jim-consumables:server:addThirst', function(amount)
|
||||
local Player = QBCore.Functions.GetPlayer(source)
|
||||
if not Player then return end
|
||||
Player.Functions.SetMetaData('thirst', amount)
|
||||
TriggerClientEvent('hud:client:UpdateNeeds', source, Player.PlayerData.metadata.hunger, amount)
|
||||
end)
|
||||
|
||||
RegisterNetEvent('jim-consumables:server:addHunger', function(amount)
|
||||
local Player = QBCore.Functions.GetPlayer(source)
|
||||
if not Player then return end
|
||||
Player.Functions.SetMetaData('hunger', amount)
|
||||
TriggerClientEvent('hud:client:UpdateNeeds', source, amount, Player.PlayerData.metadata.thirst)
|
||||
RegisterNetEvent('jim-consumables:server:addNeed', function(amount, type)
|
||||
local Player = QBCore.Functions.GetPlayer(source) if not Player then return end
|
||||
if type == "thirst" then
|
||||
Player.Functions.SetMetaData('thirst', amount)
|
||||
TriggerClientEvent('hud:client:UpdateNeeds', source, Player.PlayerData.metadata.hunger, amount)
|
||||
elseif type == "hunger" then
|
||||
Player.Functions.SetMetaData('hunger', amount)
|
||||
TriggerClientEvent('hud:client:UpdateNeeds', source, amount, Player.PlayerData.metadata.thirst)
|
||||
end
|
||||
end)
|
||||
|
||||
if Config.Inv == "ox" then
|
||||
function HasItem(src, items, amount)
|
||||
local count = exports.ox_inventory:Search(src, 'count', items)
|
||||
if count >= amount then
|
||||
if Config.Debug then print("^5Debug^7: ^3HasItem^7: ^5FOUND^7 x^3"..count.."^7 ^3"..tostring(items)) end
|
||||
return true
|
||||
else
|
||||
if Config.Debug then print("^5Debug^7: ^3HasItem^7: ^2Items ^1NOT FOUND^7") end
|
||||
return false
|
||||
end
|
||||
if exports.ox_inventory:Search(src, 'count', items) >= (amount or 1) then if Config.Debug then print("^5Debug^7: ^3HasItem^7: ^5FOUND^7 x^3"..count.."^7 ^3"..tostring(items)) end return true
|
||||
else if Config.Debug then print("^5Debug^7: ^3HasItem^7: ^2Items ^1NOT FOUND^7") end return false end
|
||||
end
|
||||
else
|
||||
function HasItem(source, items, amount)
|
||||
local amount = amount or 1
|
||||
local amount, count = amount or 1, 0
|
||||
local Player = QBCore.Functions.GetPlayer(source)
|
||||
if not Player then return false end
|
||||
local count = 0
|
||||
if Config.Debug then print("^5Debug^7: ^3HasItem^7: ^2Checking if player has required item^7 '^3"..tostring(items).."^7'") end
|
||||
for _, itemData in pairs(Player.PlayerData.items) do
|
||||
if itemData and (itemData.name == items) then
|
||||
@@ -79,30 +72,43 @@ else
|
||||
count += itemData.amount
|
||||
end
|
||||
end
|
||||
if count >= amount then
|
||||
if Config.Debug then print("^5Debug^7: ^3HasItem^7: ^2Items ^5FOUND^7 x^3"..count.."^7") end
|
||||
return true
|
||||
end
|
||||
if Config.Debug then print("^5Debug^7: ^3HasItem^7: ^2Items ^1NOT FOUND^7") end
|
||||
return false
|
||||
if count >= amount then if Config.Debug then print("^5Debug^7: ^3HasItem^7: ^2Items ^5FOUND^7 x^3"..count.."^7") end return true end
|
||||
if Config.Debug then print("^5Debug^7: ^3HasItem^7: ^2Items ^1NOT FOUND^7") end return false
|
||||
end
|
||||
end
|
||||
|
||||
--Export Import System--
|
||||
RegisterNetEvent("jim-consumables:getSync", function() local src = source TriggerClientEvent("jim-consumables:syncItems", source, Config.Consumables, Config.Emotes) end)
|
||||
local function importEmote(emoteName, eInfo)
|
||||
if Config.Debug then print("^5Debug^7: ^2Importing Item ^7'^6"..emoteName.."^7'") end
|
||||
Config.Emotes[emoteName] = eInfo
|
||||
TriggerClientEvent("jim-consumables:syncItems", -1, nil, Config.Emotes)
|
||||
end
|
||||
QBCore.Functions.CreateCallback('jim-consumables:server:syncConsumables', function(source, cb) cb(Consumables) end)
|
||||
QBCore.Functions.CreateCallback('jim-consumables:server:syncEmotes', function(source, cb) cb(Emotes) end)
|
||||
|
||||
local function importConsumable(itemName, conInfo)
|
||||
if Config.Debug then print("^5Debug^7: ^2Importing Item ^7'^6"..itemName.."^7'") end
|
||||
if not QBCore.Shared.Items[itemName] then print("^1Debug^7: ^2Item check ^7- '^1"..k.."^7' ^2not found in the shared lua^7") end
|
||||
Config.Consumables[itemName] = conInfo
|
||||
QBCore.Functions.CreateUseableItem(itemName, function(source, item) TriggerClientEvent('jim-consumables:Consume', source, itemName) end)
|
||||
TriggerClientEvent("jim-consumables:syncItems", -1, Config.Consumables, nil)
|
||||
end
|
||||
RegisterNetEvent('jim-consumables:server:syncAddItem', function(itemName, data)
|
||||
if not Consumables[itemName] then
|
||||
QBCore.Functions.CreateUseableItem(itemName, function(source, item) TriggerClientEvent('jim-consumables:Consume', source, itemName) end)
|
||||
if Config.Debug then print("^5Debug^7: ^2Adding new ^3Item^7: '^6"..itemName.."^7'") end
|
||||
Consumables[itemName] = data
|
||||
TriggerClientEvent("jim-consumables:client:syncConsumables", -1, Consumables)
|
||||
end
|
||||
end)
|
||||
|
||||
exports("importEmote", importEmote)
|
||||
exports("importConsumable", importConsumable)
|
||||
RegisterNetEvent('jim-consumables:server:syncAddEmote', function(emoteName, data)
|
||||
if not Emotes[emoteName] then
|
||||
if Config.Debug then print("^5Debug^7: ^2Adding new ^3Emote^7: '^6"..emoteName.."^7'") end
|
||||
Emotes[emoteName] = data
|
||||
TriggerClientEvent("jim-consumables:client:syncEmotes", -1, Emotes)
|
||||
end
|
||||
end)
|
||||
|
||||
RegisterNetEvent("jim-consumables:server:syncConsumables", function() TriggerClientEvent('jim-consumables:client:syncConsumables', -1, Consumables) end)
|
||||
RegisterNetEvent("jim-consumables:server:syncEmotes", function() TriggerClientEvent('jim-consumables:client:syncEmotes', -1, Emotes) end)
|
||||
|
||||
local function CheckVersion()
|
||||
PerformHttpRequest('https://raw.githubusercontent.com/jimathy/jim-consumables/master/version.txt', function(err, newestVersion, headers)
|
||||
local currentVersion = GetResourceMetadata(GetCurrentResourceName(), 'version')
|
||||
if not newestVersion then print("Currently unable to run a version check.") return end
|
||||
local advice = "^1You are currently running an outdated version^7, ^1please update^7"
|
||||
if newestVersion:gsub("%s+", "") == currentVersion:gsub("%s+", "") then advice = '^6You are running the latest version.^7'
|
||||
else print("^3Version Check^7: ^2Current^7: "..currentVersion.." ^2Latest^7: "..newestVersion) end
|
||||
print(advice)
|
||||
end)
|
||||
end
|
||||
CheckVersion()
|
||||
@@ -1,5 +1,5 @@
|
||||
local QBCore = exports['qb-core']:GetCoreObject()
|
||||
RegisterNetEvent('QBCore:Client:UpdateObject', function() QBCore = exports['qb-core']:GetCoreObject() end)
|
||||
local QBCore = exports[Config.Core]:GetCoreObject()
|
||||
RegisterNetEvent('QBCore:Client:UpdateObject', function() QBCore = exports[Config.Core]:GetCoreObject() end)
|
||||
|
||||
local time = 1000
|
||||
function loadModel(model) if not HasModelLoaded(model) then
|
||||
@@ -20,7 +20,6 @@ function unloadPtfxDict(dict) if Config.Debug then print("^5Debug^7: ^2Removing
|
||||
function destroyProp(entity)
|
||||
if Config.Debug then print("^5Debug^7: ^2Destroying Prop^7: '^6"..entity.."^7'") end
|
||||
SetEntityAsMissionEntity(entity) Wait(5)
|
||||
--DetachEntity(entity, true, true) Wait(5)
|
||||
DeleteObject(entity)
|
||||
end
|
||||
|
||||
@@ -28,13 +27,13 @@ function makeProp(data, freeze, synced)
|
||||
loadModel(data.prop)
|
||||
local prop = CreateObject(data.prop, 0.0, 0.0, 0.0, synced or false, synced or false, false)
|
||||
SetEntityHeading(prop, data.coords.w+180.0)
|
||||
--FreezeEntityPosition(prop, freeze or false)
|
||||
SetEntityCompletelyDisableCollision(prop, true, false)
|
||||
DisableCamCollisionForEntity(prop)
|
||||
DisableCamCollisionForObject(prop)
|
||||
if Config.Debug then print("^5Debug^7: ^6Prop ^2Created ^7: '^6"..prop.."^7'") end
|
||||
return prop
|
||||
end
|
||||
|
||||
function triggerNotify(title, message, type, src)
|
||||
if Config.Notify == "okok" then
|
||||
if not src then exports['okokNotify']:Alert(title, message, 6000, type)
|
||||
@@ -64,13 +63,8 @@ function toggleItem(give, item, amount) TriggerServerEvent("jim-consumables:serv
|
||||
if Config.Inv == "ox" then
|
||||
function HasItem(items, amount)
|
||||
local count = exports.ox_inventory:Search('count', items)
|
||||
if count >= amount then
|
||||
if Config.Debug then print("^5Debug^7: ^3HasItem^7: ^5FOUND^7 ^3"..count.."^7/^3"..amount.." "..tostring(items)) end
|
||||
return true
|
||||
else
|
||||
if Config.Debug then print("^5Debug^7: ^3HasItem^7: ^2"..tostring(items).." ^1NOT FOUND^7") end
|
||||
return false
|
||||
end
|
||||
if count >= amount then if Config.Debug then print("^5Debug^7: ^3HasItem^7: ^5FOUND^7 ^3"..count.."^7/^3"..amount.." "..tostring(items)) end return true
|
||||
else if Config.Debug then print("^5Debug^7: ^3HasItem^7: ^2"..tostring(items).." ^1NOT FOUND^7") end return false end
|
||||
end
|
||||
else
|
||||
function HasItem(items, amount)
|
||||
@@ -281,4 +275,4 @@ function StopEffects() -- Used to clear up any effects stuck on screen
|
||||
AnimpostfxStop('RaceTurbo')
|
||||
AnimpostfxStop('FocusIn')
|
||||
AnimpostfxStop('Rampage')
|
||||
end
|
||||
end
|
||||
1
version.txt
Normal file
1
version.txt
Normal file
@@ -0,0 +1 @@
|
||||
1.5
|
||||
Reference in New Issue
Block a user