51 Commits

Author SHA1 Message Date
Jim Shield
d263b1d156 v1.5 2023-02-19 21:47:06 +00:00
Jim Shield
7d8aa1bbc6 Fix version number print 2023-02-19 21:46:48 +00:00
Jim Shield
3330724d4e Fixes and support for RewardItems 2023-02-19 21:40:26 +00:00
Jim Shield
3e2eef8a38 Add options for RewardItem variables 2023-02-19 21:39:16 +00:00
Jim Shield
b1730d24f1 Remove duplicate remove event causing kicks 2023-02-17 09:43:59 +00:00
Jim Shield
632fd1de5b Merge pull request #8 from jimathy/v1.4
v1.4 Update
2023-02-14 15:17:04 +00:00
Jim Shield
d0fa6b750b Update README.md 2023-02-14 15:14:53 +00:00
Jim Shield
52816242fa Revert "v1.4 beta update info"
This reverts commit c25cb643bc.
2023-02-14 15:14:17 +00:00
Jim Shield
4e38c81645 Revert "Fix snippet formatting"
This reverts commit 7996100dad.
2023-02-14 15:14:13 +00:00
Jim Shield
7a6762ee08 Revert "Update item example snippet"
This reverts commit 6ba9febb0a.
2023-02-14 15:14:07 +00:00
Jim Shield
6ba9febb0a Update item example snippet 2023-02-14 15:10:13 +00:00
Jim Shield
7996100dad Fix snippet formatting 2023-02-14 15:08:18 +00:00
Jim Shield
c25cb643bc v1.4 beta update info 2023-02-14 15:07:46 +00:00
Jim Shield
a4901972b9 Update README.md 2023-02-14 14:56:50 +00:00
Jim Shield
b56cce8951 v1.4 2023-02-14 14:55:32 +00:00
Jim Shield
4648083127 Add HasItem() exploit protection 2023-02-14 14:53:48 +00:00
Jim Shield
e263aa3255 Add HasItem() exploit protection 2023-02-14 14:52:57 +00:00
Jim Shield
6654b9a3f5 Add HasItem() exploit protection 2023-02-14 14:52:10 +00:00
Jim Shield
ad185183f7 Add support for exports itemSyncing 2023-02-14 14:40:09 +00:00
Jim Shield
dbed114e05 Add support for returnItem and export item syncing 2023-02-14 14:38:57 +00:00
Jim Shield
3ffa295ca1 Add support for "return" items on item usage 2023-02-14 14:38:08 +00:00
Jim Shield
18c6401581 Merge pull request #7 from regalonefour/patch-1
security enhancement
2022-12-17 15:22:38 +00:00
regalonefour
118219c9aa Update server.lua 2022-12-15 22:30:42 -05:00
Jim Shield
b2c7c34e15 Try to fix props affecting vehicles 2022-10-12 12:21:12 +01:00
Jim Shield
cba9a574bf Remove collisions to stop conflict with vehicles 2022-10-07 17:42:48 +01:00
Jim Shield
41136ce949 Fixes to 2nd model loading 2022-09-18 14:48:59 +01:00
Jim Shield
18d903abcc Merge pull request #4 from ARSSANTO/patch-1
progress bar fix unloading props
2022-09-17 19:13:42 +01:00
Atikur Rahaman Santo
909dd3ad19 progressbar fix unloading props 2022-09-17 23:31:22 +06:00
Jim Shield
cec8165556 Merge pull request #3 from ARSSANTO/main
2nd prop and lua54 support
2022-09-17 16:52:40 +01:00
Jim Shield
4bdcc11d51 Update shared.lua 2022-09-17 16:50:06 +01:00
Jim Shield
68b17642a6 Version Bump 2022-09-17 16:49:15 +01:00
Jim Shield
5d084c3046 Tidy + upgrade 2022-09-17 16:48:42 +01:00
Atikur Rahaman Santo
bc585cd9a5 2nd prop and lua54 support 2022-09-17 05:04:13 +06:00
Jim Shield
1f9e16acf1 qs-inventory fix 2022-09-04 18:38:20 +01:00
Jim Shield
9fcc91e2bc ps progressbar support 2022-08-30 22:45:59 +01:00
Jim Shield
00332d0ca3 Progressbar Support
a little updates
2022-08-30 21:57:57 +01:00
Atikur Rahaman Santo
a2d2355757 Merge branch 'main' into conflict-resolve 2022-08-31 02:45:36 +06:00
Atikur Rahaman Santo
de68263240 marge with main 2022-08-31 02:43:43 +06:00
Jim Shield
931ba14933 more buff time fixes 2022-08-29 15:25:21 +01:00
Jim Shield
50f5dab7cb remove useless variable 2022-08-29 10:29:55 +01:00
Jim Shield
f1cf454687 buff time fix + notify fixes + New effects 2022-08-29 10:26:48 +01:00
Atikur Rahaman Santo
da27eb3f89 anothe mistake fix 2022-08-26 21:54:37 +06:00
Atikur Rahaman Santo
35bf894213 a little wait before cancel progbar 2022-08-26 06:19:38 +06:00
Atikur Rahaman Santo
a0c83c0e1f feat: Notify config progressbar config & canrun while consume in config 2022-08-26 06:10:20 +06:00
Jim Shield
a6f6492d5b debug mode. 2022-08-24 09:25:05 +01:00
Jim Shield
7da98b53e1 v1.3 Shared file, optimize, fix client item event 2022-08-24 09:23:43 +01:00
Jim Shield
1036f1dc21 Trying to get better overriding of item control 2022-08-15 10:06:30 +01:00
Jim Shield
59540d95b6 v1.2 - ps-buffs support / screen effect changes 2022-07-21 17:23:47 +01:00
Jim Shield
b15836d42e Version Bump 1.1 - Optimizations, Tidy, Fixes 2022-07-20 15:51:38 +01:00
Jim Shield
d17334e6fe More specific model removal 2022-07-20 13:43:17 +01:00
Jim Shield
61de2ece5a lock inventory until done or cancelled 2022-07-14 15:25:20 +01:00
6 changed files with 679 additions and 506 deletions

View File

@@ -6,7 +6,29 @@ This script is designed as a replacement/override for food and drink consumables
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.
## 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.
But because of the export system being used, Jim-Consumables **NEEDS** to start before any scripts that use it.
And small example snippet for this imports the item and the emote, then syncs it to players
```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
# 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.
It already takes control of default qbcore food and drink, but you would probably want to add more.
@@ -14,14 +36,56 @@ It already takes control of default qbcore food and drink, but you would probabl
To add an item, you only need to add a new item table in the Config.Consumables like this:
```lua
["heartstopper"] = {
emote = "burger", -- Select an emote from below, it has to be in here
stress = math.random(1,2), -- Amount of stress relief, can be 0
heal = 0, -- Set amount to heal by after consuming
armor = 5, -- Amount of armor to add
type = "food", -- Type: "alcohol" / "drink" / "food"
effect = { effect = "healdouble", }, -- The status effect given by the item, "heal" / "healdouble" / "stamina"
stats = { hunger = math.random(10,20), }, -- The stats of the item, if not found in the items.lua
emote = "burger", -- Select an emote from below, it has to be in here
time = math.random(5000, 6000), -- Amount of time it takes to consume the item
stress = math.random(1, 2), -- Amount of stress relief, can be 0
heal = 0, -- Set amount to heal by after consuming
armor = 5, -- Amount of armor to add
type = "food", -- Type: "alcohol" / "drink" / "food"
returnItem = { -- Item that will be given when the item is used
item = "plastic", -- eg. Plastic bottles can give "plastic"
amount = 1,
},
stats = {
screen = "rampage", -- The screen effect to be played when after consuming the item
effect = "heal", -- The status effect given by the item, "heal" / "stamina"
time = 10000, -- How long the effect should last (if not added it will default to 10000)
amount = 2, -- How much the value is changed by per second
hunger = math.random(10,20), -- The hunger/thirst stats of the item, if not found in the items.lua
thirst = math.random(10,20), -- The hunger/thirst stats of the item, if not found in the items.lua
},
},
```
Consuming an item can also manually activate screen effects
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
The example above uses `rampage` as this is what the effect is named after, you can use it for any item you think best
```lua
--The current list of screen effects are:
"turbo"
"focus"
"rampage"
"weed"
"trevor"
"nightvision"
"thermal"
```
## PS-Buffs Support
This scripts can be expanded with ps-buffs (https://github.com/Project-Sloth/ps-buffs)
If this script is enabled it will automatically try to use their system to apply buffs:
```lua
--The extra buffs that can be set include:
"heal" -- Health recovery buff
"stamina" -- Stamina recovery buff
"swimming" -- Swimming speed buff
"stress" -- Stress recovery buff
"armor" -- Armour recovery buff
"hacking" -- Hacking effect
"intelligence" -- Intelligence effect
"luck" -- Luck effect
"strength" -- Strength effect
```
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.

View File

@@ -1,352 +1,246 @@
local QBCore = exports['qb-core']:GetCoreObject()
PlayerJob = {}
local onDuty = false
local alcoholCount = 0
local drugCount = 0
local function loadAnimDict(dict) while (not HasAnimDictLoaded(dict)) do RequestAnimDict(dict) Wait(5) end end
--Alcohol Effects
function AlienEffect()
StartScreenEffect("DrugsMichaelAliensFightIn", 3.0, 0)
Wait(math.random(5000, 8000))
local ped = PlayerPedId()
RequestAnimSet("MOVE_M@DRUNK@VERYDRUNK")
while not HasAnimSetLoaded("MOVE_M@DRUNK@VERYDRUNK") do
Citizen.Wait(0)
end
SetPedCanRagdoll( ped, true )
ShakeGameplayCam('DRUNK_SHAKE', 2.80)
SetTimecycleModifier("Drunk")
SetPedMovementClipset(ped, "MOVE_M@DRUNK@VERYDRUNK", true)
SetPedMotionBlur(ped, true)
SetPedIsDrunk(ped, true)
Wait(1500)
SetPedToRagdoll(ped, 5000, 1000, 1, false, false, false )
Wait(13500)
SetPedToRagdoll(ped, 5000, 1000, 1, false, false, false )
Wait(120500)
ClearTimecycleModifier()
ResetScenarioTypesEnabled()
ResetPedMovementClipset(ped, 0)
SetPedIsDrunk(ped, false)
SetPedMotionBlur(ped, false)
AnimpostfxStopAll()
ShakeGameplayCam('DRUNK_SHAKE', 0.0)
StartScreenEffect("DrugsMichaelAliensFight", 3.0, 0)
Wait(math.random(45000, 60000))
StartScreenEffect("DrugsMichaelAliensFightOut", 3.0, 0)
StopScreenEffect("DrugsMichaelAliensFightIn")
StopScreenEffect("DrugsMichaelAliensFight")
StopScreenEffect("DrugsMichaelAliensFightOut")
end
--Weed Effects
function WeedEffect()
StartScreenEffect("DrugsMichaelAliensFightIn", 3.0, 0)
Wait(math.random(3000, 20000))
StartScreenEffect("DrugsMichaelAliensFight", 3.0, 0)
Wait(math.random(15000, 20000))
StartScreenEffect("DrugsMichaelAliensFightOut", 3.0, 0)
StopScreenEffect("DrugsMichaelAliensFightIn")
StopScreenEffect("DrugsMichaelAliensFight")
StopScreenEffect("DrugsMichaelAliensFightOut")
end
--Other Effects
function TrevorEffect()
StartScreenEffect("DrugsTrevorClownsFightIn", 3.0, 0)
Wait(3000)
StartScreenEffect("DrugsTrevorClownsFight", 3.0, 0)
Wait(30000)
StartScreenEffect("DrugsTrevorClownsFightOut", 3.0, 0)
StopScreenEffect("DrugsTrevorClownsFight")
StopScreenEffect("DrugsTrevorClownsFightIn")
StopScreenEffect("DrugsTrevorClownsFightOut")
end
function HealEffectDouble()
if not healing then healing = true else return end
local count = 9
while count > 0 do
Wait(1000)
count = count - 1
SetEntityHealth(PlayerPedId(), GetEntityHealth(PlayerPedId()) + 6)
end
healing = false
end
function HealEffect()
if not healing then healing = true else return end
local count = 4
while count > 0 do
Wait(1000)
count = count - 1
SetEntityHealth(PlayerPedId(), GetEntityHealth(PlayerPedId()) + 6)
end
healing = false
end
function StaminaEffect()
local startStamina = 8
SetRunSprintMultiplierForPlayer(PlayerId(), 1.49)
while startStamina > 0 do
Wait(1000)
if math.random(5, 100) < 10 then RestorePlayerStamina(PlayerId(), 1.0) end
startStamina = startStamina - 1
if math.random(5, 100) < 51 then end
end
startStamina = 0
SetRunSprintMultiplierForPlayer(PlayerId(), 1.0)
end
--[[function EcstasyEffect()
local startStamina = 30
SetFlash(0, 0, 500, 7000, 500)
while startStamina > 0 do
Wait(1000)
startStamina = startStamina - 1
RestorePlayerStamina(PlayerId(), 1.0)
if math.random(1, 100) < 51 then
SetFlash(0, 0, 500, 7000, 500)
ShakeGameplayCam('SMALL_EXPLOSION_SHAKE', 0.08)
--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)
end
end
if IsPedRunning(PlayerPedId()) then
SetPedToRagdoll(PlayerPedId(), math.random(1000, 3000), math.random(1000, 3000), 3, 0, 0, 0)
end
startStamina = 0
end
function CrackBaggyEffect()
local startStamina = 8
local ped = PlayerPedId()
--AlienEffect()
SetRunSprintMultiplierForPlayer(PlayerId(), 1.3)
while startStamina > 0 do
Wait(1000)
if math.random(1, 100) < 10 then
RestorePlayerStamina(PlayerId(), 1.0)
end
startStamina = startStamina - 1
if math.random(1, 100) < 60 and IsPedRunning(ped) then
SetPedToRagdoll(ped, math.random(1000, 2000), math.random(1000, 2000), 3, 0, 0, 0)
end
if math.random(1, 100) < 51 then
--AlienEffect()
end
end
if IsPedRunning(ped) then
SetPedToRagdoll(ped, math.random(1000, 3000), math.random(1000, 3000), 3, 0, 0, 0)
end
startStamina = 0
SetRunSprintMultiplierForPlayer(PlayerId(), 1.0)
end
function CokeBaggyEffect()
local startStamina = 20
local ped = PlayerPedId()
--AlienEffect()
SetRunSprintMultiplierForPlayer(PlayerId(), 1.1)
while startStamina > 0 do
Wait(1000)
if math.random(1, 100) < 20 then
RestorePlayerStamina(PlayerId(), 1.0)
end
startStamina = startStamina - 1
if math.random(1, 100) < 10 and IsPedRunning(ped) then
SetPedToRagdoll(ped, math.random(1000, 3000), math.random(1000, 3000), 3, 0, 0, 0)
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, 0, 0, 0)
end
startStamina = 0
SetRunSprintMultiplierForPlayer(PlayerId(), 1.0)
end]]
local consuming = false
local cancelled = false
RegisterNetEvent('jim-consumables:Consume', function(itemName)
local time = math.random(5000, 6000) -- How long it takes to consume something
local Player = PlayerPedId()
local emote = Config.Emotes[Config.Consumables[itemName].emote]
local animDict = tostring(emote[1])
local anim = tostring(emote[2])
local model, bone, drugeffect, stress = nil
local P1, P2, P3, P4, P5, P6 = table.unpack({0.0, 0.0, 0.0, 0.0, 0.0, 0.0})
if emote.AnimationOptions.Prop then
model = tostring(emote.AnimationOptions.Prop)
bone = GetPedBoneIndex(PlayerPedId(), emote.AnimationOptions.PropBone)
P1, P2, P3, P4, P5, P6 = table.unpack(emote.AnimationOptions.PropPlacement)
end
local type = Config.Consumables[itemName].type
local stress = Config.Consumables[itemName].stress
local heal = Config.Consumables[itemName].heal
local armor = Config.Consumables[itemName].armor
if type == "drink" or type == "alcohol" then string = "Drinking " end
if type == "food" then string = "Eating " end
if type == "drug" then string = "Using " 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
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 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 string = "Using "
if emote.AnimationOptions.Prop then
model = emote.AnimationOptions.Prop
bone = GetPedBoneIndex(Player, emote.AnimationOptions.PropBone)
P1, P2, P3, P4, P5, P6 = table.unpack(emote.AnimationOptions.PropPlacement)
if emote.AnimationOptions.SecondProp then
model2 = emote.AnimationOptions.SecondProp
bone2 = GetPedBoneIndex(Player, emote.AnimationOptions.SecondPropBone)
P7, P8, P9, P10, P11, P12 = table.unpack(emote.AnimationOptions.SecondPropPlacement)
end
end
if type == "drink" or type == "alcohol" then string = "Drinking "
elseif type == "food" then string = "Eating "
else string = "Using " end
if consuming then
cancelled = true
TriggerEvent("QBCore:Notify", "Stopped "..string, "error")
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")
else
triggerNotify(nil, "Stopped "..string, "error")
end
consuming = not consuming
return
end
--Emote Stuff
if Config.Debug then print("^5Debug^7: ^3Consume^7: ^2Grabbing Emote Animation Options^7...") end
if emote.AnimationOptions then
if emote.AnimationOptions.EmoteLoop then MovementType = 1
if emote.AnimationOptions.EmoteMoving then MovementType = 51
end
elseif emote.AnimationOptions.EmoteMoving then MovementType = 51
elseif emote.AnimationOptions.EmoteMoving == false then MovementType = 0
elseif emote.AnimationOptions.EmoteStuck then MovementType = 50
end
elseif emote.AnimationOptions.EmoteStuck then MovementType = 50 end
else MovementType = 0 end
InVehicle = IsPedInAnyVehicle(PlayerPedId(), true)
if Config.Debug then print("^5Debug^7: ^3Consume^7: ^2Checking if player is in a vehicle^7...") end
local InVehicle = IsPedInAnyVehicle(Player, true)
if InVehicle == 1 then MovementType = 51 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)
--Prop Spawning
if model then
RequestModel(GetHashKey(model))
while not HasModelLoaded(GetHashKey(model)) do Citizen.Wait(1) end
local attachProp = CreateObject(GetHashKey(model), 1.0, 1.0, 1.0, 1, 1, 0)
AttachEntityToEntity(attachProp, PlayerPedId(), bone, P1, P2, P3, P4, P5, P6, true, true, false, true, 1, true)
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)
else
triggerNotify(nil, string..QBCore.Shared.Items[itemName].label.."..", "success")
end
TriggerEvent("QBCore:Notify", string..QBCore.Shared.Items[itemName].label.."..", "success", (time + 1000))
consuming = true
CreateThread(function()
--Prop Spawning
if model then
if IsModelValid(model) == 1 then
if Config.Debug then print("^5Debug^7: ^3PropSpawn^7: ^2Spawning consumable prop^7.") end
attachProp = makeProp({ prop = model, coords = vector4(0.0,0.0,0.0,0.0)}, 1, 1)
AttachEntityToEntity(attachProp, Player, bone, P1, P2, P3, P4, P5, P6, true, true, false, true, 1, true)
if model2 then
if IsModelValid(model2) == 1 then
attachProp2 = makeProp({ prop = model2, coords = vector4(0.0,0.0,0.0,0.0)}, 1, 1)
AttachEntityToEntity(attachProp2, Player, bone2, P7, P8, P9, P10, P11, P12, true, true, false, true, 1, true)
else print("^5Debug^7: ^3PropSpawn^7: ^2Second prop model isn't valid/found^7.") end
end
while consuming do Wait(50) end
if DoesEntityExist(attachProp) then destroyProp(attachProp) attachProp = nil end
if DoesEntityExist(attachProp2) then destroyProp(attachProp2) attachProp2 = nil end
else print("^5Debug^7: ^3PropSpawn^7: ^2Prop model isn't valid/found^7.") end
end
end)
while consuming do
if time <= 0 then consuming = false end
if IsControlJustPressed(0, 21) then
consuming = false
cancelled = true
end
Wait(10)
time = time - 10
end
StopEntityAnim(Player, anim, animDict, 1.0)
DeleteEntity(attachProp)
if not cancelled then
TriggerEvent("inventory:client:ItemBox", QBCore.Shared.Items[itemName], "remove", 1)
TriggerServerEvent("QBCore:Server:RemoveItem", itemName, 1)
if QBCore.Shared.Items[itemName].thirst then
TriggerServerEvent("QBCore:Server:SetMetaData", "thirst", QBCore.Functions.GetPlayerData().metadata["thirst"] + QBCore.Shared.Items[itemName].thirst) end
if QBCore.Shared.Items[itemName].hunger then
TriggerServerEvent("QBCore:Server:SetMetaData", "hunger", QBCore.Functions.GetPlayerData().metadata["hunger"] + QBCore.Shared.Items[itemName].hunger) end
if not QBCore.Shared.Items[itemName].thirst and not QBCore.Shared.Items[itemName].hunger then
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("QBCore:Server:SetMetaData", "hunger", QBCore.Functions.GetPlayerData().metadata["hunger"] + hunger)
if Config.Consumables[itemName].stats.thirst then thirst = Config.Consumables[itemName].stats.thirst end
TriggerServerEvent("QBCore:Server:SetMetaData", "thirst", QBCore.Functions.GetPlayerData().metadata["thirst"] + thirst)
if not Config.Consumables[itemName].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")
else
triggerNotify(nil, "Cancelled "..string, "error")
end
end
end
if stress then TriggerServerEvent('hud:server:RelieveStress', stress) end
if heal then SetEntityHealth(Player, GetEntityHealth(Player) + heal) end
if armor then TriggerServerEvent('hospital:server:SetArmor', (GetPedArmour(Player) + armor)) SetPedArmour(Player, (GetPedArmour(Player) + armor)) end
end
Wait(10)
time -= 10
end
StopEntityAnim(Player, anim, animDict, 1.0)
unloadAnimDict(animDict)
if not cancelled then
toggleItem(false, itemName, 1)
if returnItem ~= nil then toggleItem(true, returnItem.item, returnItem.amount) end
-- Reward Item calculations
CreateThread(function()
if RewardItem then
for i = 1, Config.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
if RewardItem[item].rarity >= rarity then
toggleItem(true, RewardItem[item].item, math.random(1, RewardItem[item].max))
if Config.Debug then print("^5Debug^7: ^2Given reward prize^7: '^6"..RewardItem[item].item.."^7'") end
break
end
Wait(100)
end
Wait(1500)
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)
end
if Config.Debug then print("^5Debug^7: ^2Hunger^7: [^6"..hunger.."^7] ^2Thrist^7: [^6"..thirst.."^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)
end
if heal and heal ~= 0 then
if Config.Debug then print("^5Debug^7: ^3Consume^7: ^2Healing player by^7: ^6"..heal) end
SetEntityHealth(Player, GetEntityHealth(Player) + heal)
end
if armor and armor ~= 0 then
if Config.Debug then print("^5Debug^7: ^3Consume^7: ^2Adding ^6"..armor.." ^2armour^7.") end
TriggerServerEvent('hospital:server:SetArmor', (GetPedArmour(Player) + armor)) SetPedArmour(Player, (GetPedArmour(Player) + armor))
end
if type == "alcohol" then
if Config.Debug then print("^5Debug^7: ^3Consume^7: ^2Current ^4alcoholCount^7: ^6"..(alcoholCount + 1)) end
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)
AlienEffect()
end
CreateThread(function() AlienEffect() end) -- Used as overdosing/too drunk effect
end
end
effect = Config.Consumables[itemName].effect
if effect ~= nil then
if effect.canOD then
drugCount = drugCount + 1
stats = Config.Consumables[itemName].stats or nil
if Config.Consumables[itemName].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
if stats.screen == "rampage" then CreateThread(function() RampageEffect() end) end
if stats.screen == "weed" then CreateThread(function() WeedEffect() end) end
if stats.screen == "trevor" then CreateThread(function() TrevorEffect() end) end
if stats.screen == "nightvision" then CreateThread(function() NightVisionEffect() end) end
if stats.screen == "thermal" then CreateThread(function() ThermalEffect() end) end
end
if stats.canOD then
if Config.Debug then print("^5Debug^7: ^3Consume^7: ^2Current ^4drugCount^7: ^6"..(drugCount + 1)) end
drugCount += 1
if drugCount >= 4 then
SetEntityHealth(PlayerPedId(), GetEntityHealth(PlayerPedId()) - math.random(10,15))
if drugCount >= 6 then
AlienEffect()
if Config.Debug then print("^5Debug^7: ^3Consume^7: ^2Current ^4drugCount^7: ^6"..drugCount.."^7 - ^2 removing health") end
SetEntityHealth(PlayerPedId(), GetEntityHealth(Player) - math.random(10,15))
if drugCount >= 7 then
CreateThread(function() AlienEffect() end) -- If too many drugs, if not dead will make you stumble
end
end
end
if effect.effect == "weed" then
if drugCount >= 2 then
TrevorEffect()
end
end
if effect.effect == "heal" then
HealEffect()
end
if effect.effect == "healdouble" then
HealEffect()
end
if effect.effect == "stamina" then
StaminaEffect()
if drugCount >= 4 then
TrevorEffect()
end
end
if effect.widepupils then
TriggerEvent("evidence:client:SetStatus", "widepupils", 200)
--EcstasyEffect()
if stats.effect == "heal" then
if GetResourceState("ps-buffs") == "started" then
if Config.Debug then print("^5Debug^7: ^3Consume^7: ^4PS^7-^4Buffs ^2found^7, ^2hooking in to get buffs and applying ^6Health Buff ^2for ^6"..stats.time.."^7ms") end
exports["ps-buffs"]:AddHealthBuff((tonumber(stats.time) or 10000), (stats.amount or 6))
else CreateThread(function() HealEffect({(tonumber(stats.time) or 10000), (stats.amount or 6)}) end) end
end
if stats.effect == "stamina" then
if GetResourceState("ps-buffs") == "started" then
if Config.Debug then print("^5Debug^7: ^3Consume^7: ^4PS^7-^4Buffs ^2found^7, ^2hooking in to get buffs and applying ^6Stamina Buff ^2for ^6"..stats.time.."^7ms") end
exports["ps-buffs"]:StaminaBuffEffect((tonumber(stats.time) or 10000), (stats.amount or 6))
else CreateThread(function() StaminaEffect({(tonumber(stats.time) or 10000), (stats.amount or 6)}) end) end
end
if GetResourceState("ps-buffs") == "started" then --PS-BUFFS ONLY
--if Config.Debug then if stats.effect then print("^5Debug^7: ^3Consume^7: ^4PS^7-^4Buffs ^2found^7, ^2hooking in to get buffs and applying ^6"..stats.effect.." Buff ^2for ^6"..(stats.time or "nil").."^7ms") end end
if stats.effect == "armor" then exports["ps-buffs"]:AddArmorBuff((tonumber(stats.time) or 10000), (stats.amount or 6)) end
if stats.effect == "stress" then exports["ps-buffs"]:AddStressBuff((tonumber(stats.time) or 10000), (stats.amount or 6)) end
if stats.effect == "swimming" then exports["ps-buffs"]:SwimmingBuffEffect((tonumber(stats.time) or 10000), (stats.amount or 6)) end
if stats.effect == "hacking" then exports["ps-buffs"]:AddBuff("hacking", (tonumber(stats.time) or 10000)) end
if stats.effect == "intelligence" then exports["ps-buffs"]:AddBuff("intelligence", (tonumber(stats.time) or 10000)) end
if stats.effect == "luck" then exports["ps-buffs"]:AddBuff("luck", (tonumber(stats.time) or 10000)) end
if stats.effect == "strength" then exports["ps-buffs"]:AddBuff("strength", (tonumber(stats.time) or 10000)) end
end
if stats.widepupils then TriggerEvent("evidence:client:SetStatus", "widepupils", 200) end
end
end
cancelled = false
consuming = false
for k, v in pairs(GetGamePool('CObject')) do
if IsEntityAttachedToEntity(PlayerPedId(), v) then
DeleteObject(v)
DetachEntity(v, 0, 0)
SetEntityAsMissionEntity(v, true, true)
Wait(100)
DeleteEntity(v)
end
end
if Config.Debug then print("^5Debug^7: ^3Consume^7: ^2Finished, unlocking inventory^7...") end
LocalPlayer.state:set("inv_busy", false, true) TriggerEvent('inventory:client:busy:status', false) TriggerEvent('canUseInventoryAndHotbar:toggle', true)
end)
CreateThread(function()
while true do
Wait(10)
if alcoholCount > 0 then
Wait(1000 * 60 * 15)
alcoholCount = alcoholCount - 1
else
Wait(2000)
end
if alcoholCount > 0 then Wait(1000 * 60 * 15) alcoholCount -= 1 else Wait(1000) end
if drugCount > 0 then Wait(1000 * 60 * 15) drugCount -= 1 else Wait(1000) end
end
end)
CreateThread(function()
while true do
Wait(10)
if drugCount > 0 then
Wait(1000 * 60 * 15)
drugCount = drugCount - 1
else
Wait(2000)
end
end
AddEventHandler('onResourceStop', function(r) if r ~= GetCurrentResourceName() then return end
StopEffects()
end)

View File

@@ -1,4 +1,4 @@
print("Jim-Consumables v1.0 - Consumables Script by Jimathy")
print("^2Jim^7-^2Consumables ^7v^41^7.^45 ^7- ^2Consumables Script by ^1Jimathy^7")
-- If you need support I now have a discord available, it helps me keep track of issues and give better support.
@@ -6,50 +6,77 @@ print("Jim-Consumables v1.0 - Consumables Script by Jimathy")
Config = {
Debug = false,
Notify = "qb",
UseProgbar = false,
Consumables = {
-- Default QB food and drink item override
["vodka"] = { emote = "vodkab", stress = math.random(2, 4), heal = 0, armor = 0, type = "alcohol", stats = { thirst = math.random(10,20), }},
["beer"] = { emote = "beer", stress = math.random(2, 4), heal = 0, armor = 0, type = "alcohol", stats = { thirst = math.random(10,20), }},
["whiskey"] = { emote = "whiskey", stress = math.random(2, 4), heal = 0, armor = 0, type = "alcohol", stats = { thirst = math.random(10,20), }},
["sandwich"] = { emote = "sandwich", stress = math.random(2, 4), heal = 0, armor = 0, type = "food", stats = { hunger = math.random(10,20), }},
["twerks_candy"] = { emote = "egobar", stress = math.random(2, 4), heal = 0, armor = 0, type = "food", stats = { hunger = math.random(10,20), }},
["snikkel_candy"] = { emote = "egobar", stress = math.random(2, 4), heal = 0, armor = 0, type = "food", stats = { hunger = math.random(10,20), }},
["tosti"] = { emote = "sandwich", stress = math.random(2, 4), heal = 0, armor = 0, type = "food", stats = { hunger = math.random(10,20), }},
--Effects can be applied here, like stamina on coffee for example
["vodka"] = { emote = "vodkab", canRun = false, time = math.random(5000, 6000), stress = 0, heal = 0, armor = 0, type = "alcohol", stats = { effect = "stress", time = 5000, amount = 2, thirst = math.random(10,20), canOD = true }},
["beer"] = { emote = "beer", canRun = false, time = math.random(5000, 6000), stress = math.random(2, 4), heal = 0, armor = 0, type = "alcohol", stats = { thirst = math.random(10,20), canOD = true }},
["whiskey"] = { emote = "whiskey", canRun = false, time = math.random(5000, 6000), stress = math.random(2, 4), heal = 0, armor = 0, type = "alcohol", stats = { thirst = math.random(10,20), canOD = true }},
["coffee"] = { emote = "coffee", stress = math.random(2, 4), heal = 0, armor = 0, type = "drink", stats = { thirst = math.random(10,20), }},
["water_bottle"] = { emote = "drink", stress = math.random(2, 4), heal = 0, armor = 0, type = "drink", stats = { thirst = math.random(10,20), }},
["kurkakola"] = { emote = "ecola", stress = math.random(2, 4), heal = 0, armor = 0, type = "drink", stats = { thirst = math.random(10,20), }},
["sandwich"] = { emote = "sandwich", canRun = false, time = math.random(5000, 6000), stress = math.random(2, 4), heal = 0, armor = 0, type = "food", stats = { hunger = math.random(10,20), }},
["twerks_candy"] = { emote = "egobar", canRun = true, time = math.random(5000, 6000), stress = math.random(2, 4), heal = 0, armor = 0, type = "food", stats = { hunger = math.random(10,20), }},
["snikkel_candy"] = { emote = "egobar", canRun = true, time = math.random(5000, 6000), stress = math.random(2, 4), heal = 0, armor = 0, type = "food", stats = { hunger = math.random(10,20), }},
["tosti"] = { emote = "sandwich", canRun = false, time = math.random(5000, 6000), stress = math.random(2, 4), heal = 0, armor = 0, type = "food", stats = { hunger = math.random(10,20), }},
["coffee"] = { emote = "coffee", canRun = false, time = math.random(5000, 6000), stress = math.random(2, 4), heal = 0, armor = 0, type = "drink", stats = { effect = "stamina", time = 10000, thirst = math.random(10,20), }},
["water_bottle"] = { emote = "drink", canRun = false, time = math.random(5000, 6000), stress = math.random(2, 4), heal = 0, armor = 0, type = "drink", stats = { thirst = math.random(10,20), }},
["kurkakola"] = { emote = "ecola", canRun = false, time = math.random(5000, 6000), stress = math.random(2, 4), heal = 0, armor = 0, type = "drink", stats = { thirst = math.random(10,20), }},
----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
--[[----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
-- Items that effect status changes, like bleeding can cause problems as they are all handled in their own scripts
--[[--Testing these but they may be best left handled by default scripts
["ifaks"] = { emote = "oxy", stress = math.random(12, 24), heal = 10, armor = 0, type = "drug", },
["bandage"] = { emote = "oxy", stress = 0, heal = 10, armor = 0, type = "drug", },
-- Testing these but they may be best left handled by default scripts
["ifaks"] = { emote = "oxy", time = math.random(5000, 6000), stress = math.random(12, 24), heal = 10, armor = 0, type = "drug", stats = { effect = "heal", amount = 6, widepupils = false, canOD = false } },
["bandage"] = { emote = "oxy", time = math.random(5000, 6000), stress = 0, heal = 10, armor = 0, type = "drug", stats = { effect = "heal", amount = 3, widepupils = false, canOD = false } }, },
]]
--Testing effects & armor with small functionality to drugs - This may be another one left to default scripts
["joint"] = { emote = "smoke3", stress = math.random(12, 24), heal = 0, armor = 10, type = "drug", effect = { effect = "weed", widepupils = false, canOD = false } },
["joint"] = { emote = "smoke3", time = math.random(5000, 6000), stress = math.random(12, 24), heal = 0, armor = 10, type = "drug", stats = { screen = "weed", effect = "armor", widepupils = false, canOD = false } },
["cokebaggy"] = { emote = "coke", stress = math.random(12, 24), heal = 0, armor = 10, type = "drug", effect = { effect = "stamina", widepupils = false, canOD = true } },
--["crackbaggy"] = { emote = "coke", stress = math.random(12, 24), heal = 0, armor = 10, type = "drug", effect = { effect = "heal", widepupils = false, canOD = true } },
["xtcbaggy"] = { emote = "oxy", stress = math.random(12, 24), heal = 0, armor = 10, type = "drug", effect = { effect = "stamina", widepupils = true, canOD = true } },
["oxy"] = { emote = "oxy", stress = math.random(12, 24), heal = 0, armor = 10, type = "drug", effect = { effect = "heal", widepupils = false, canOD = false } },
["meth"] = { emote = "coke", stress = math.random(12, 24), heal = 0, armor = 10, type = "drug", effect = { effect = "stamina", widepupils = false, canOD = true } },]]
["cokebaggy"] = { emote = "coke", time = math.random(5000, 6000), stress = math.random(12, 24), heal = 0, armor = 0, type = "drug", stats = { screen = "focus", effect = "stamina", widepupils = false, canOD = true } },
--["crackbaggy"] = { emote = "coke", time = math.random(5000, 6000), stress = math.random(12, 24), heal = 0, armor = 0, type = "drug", stats = { effect = "heal", widepupils = false, canOD = true } },
["xtcbaggy"] = { emote = "oxy", time = math.random(5000, 6000), stress = math.random(12, 24), heal = 0, armor = 10, type = "drug", stats = { effect = "strength", widepupils = true, canOD = true } },
["oxy"] = { emote = "oxy", time = math.random(5000, 6000), stress = math.random(12, 24), heal = 0, armor = 0, type = "drug", stats = { effect = "heal", widepupils = false, canOD = false } },
["meth"] = { emote = "coke", time = math.random(5000, 6000), stress = math.random(12, 24), heal = 0, armor = 10, type = "drug", stats = { effect = "stamina", widepupils = false, canOD = true } },
----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
--[[
Example item
--["heartstopper"] = {
----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
--[[Example item
["heartstopper"] = {
emote = "burger", -- Select an emote from below, it has to be in here
time = math.random(5000, 6000), -- Amount of time it takes to consume the item
stress = math.random(1,2), -- Amount of stress relief, can be 0
heal = 0, -- Set amount to heal by after consuming
armor = 5, -- Amount of armor to add
type = "food", -- Type: "alcohol" / "drink" / "food"
effect = { effect = "healdouble", }, -- The status effect given by the item, "heal" / "healdouble" / "stamina"
stats = { hunger = math.random(10,20), }, -- The stats of the item, if not found in the items.lua
},
]]
stats = {
screen = "thermal", -- The screen effect to be played when after consuming the item "rampage" "turbo" "focus" "weed" "trevor" "nightvision" "thermal"
effect = "heal", -- The status effect given by the item, "heal" / "stamina"
-- This supports ps-buffs effects "armor" "stress" "swimming" "hacking" "intelligence" "luck" "strength"
time = 10000, -- How long the effect should last (if not added it will default to 10000)
amount = 6, -- How much the value is changed by per second
hunger = math.random(10, 20), -- The hunger/thirst stats of the item, if not found in the items.lua
thirst = math.random(10, 20), -- The hunger/thirst stats of the item, if not found in the items.lua
},
--Reward Items Variables
-- These can be the only thing in a consumable table and the item will still work
amounttogive = 3, -- Used for "RewardItems", tells the script how many to give
rewards = {
[1] = {
item = "plastic", -- prize item name
max = 10, -- max amount to give (this is put into math.random(1, max) )
rarity = 1, -- the rarity system, 1 being rarest, 4 being most common
},
},
},]]
},
Emotes = {
["drink"] = {"mp_player_intdrink", "loop_bottle", "Drink", AnimationOptions =
@@ -97,168 +124,5 @@ Config = {
["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, }},
--Jim-BeanMachine
["bmcoffee1"] = {"amb@world_human_drinking@coffee@male@idle_a", "idle_c", "Coffee2", AnimationOptions =
{ Prop = 'prop_fib_coffee', PropBone = 28422, PropPlacement = {0.0, 0.0, 0.0, 0.0, 0.0, 0.0},
EmoteLoop = true, EmoteMoving = true, }},
["bmcoffee2"] = {"amb@world_human_drinking@coffee@male@idle_a", "idle_c", "Coffee3", AnimationOptions =
{ Prop = 'ng_proc_coffee_01a', PropBone = 28422, PropPlacement = {0.0, 0.0, -0.06, 0.0, 0.0, 0.0},
EmoteLoop = true, EmoteMoving = true, }},
["bmcoffee3"] = {"amb@world_human_drinking@coffee@male@idle_a", "idle_c", "Coffee3", AnimationOptions =
{ Prop = 'v_club_vu_coffeecup', PropBone = 28422, PropPlacement = {0.0, 0.0, -0.06, 0.0, 0.0, 0.0},
EmoteLoop = true, EmoteMoving = true, }},
--Jim-PizzaThis
["redwine"] = {"mp_player_intdrink", "loop_bottle", "Red Wine Bottle", AnimationOptions =
{ Prop = "prop_wine_rose", PropBone = 18905, PropPlacement = {0.00, -0.26, 0.10, 240.0, -60.0},
EmoteMoving = true, EmoteLoop = true, }},
["whitewine"] = {"mp_player_intdrink", "loop_bottle", "White Wine Bottle", AnimationOptions =
{ Prop = "prop_wine_white", PropBone = 18905, PropPlacement = {0.00, -0.26, 0.10, 240.0, -60.0},
EmoteMoving = true, EmoteLoop = true, }},
["pizza"] = {"mp_player_inteat@burger", "mp_player_int_eat_burger_fp", "Pizza", AnimationOptions =
{ Prop = "v_res_tt_pizzaplate", PropBone = 18905, PropPlacement = {0.20, 0.038, 0.051, 15.0, 155.0},
EmoteMoving = true, EmoteLoop = true, }},
["bowl"] = {"amb@world_human_drinking@coffee@male@idle_a", "idle_c", "bowl", AnimationOptions =
{ Prop = "h4_prop_h4_coke_plasticbowl_01", PropBone = 28422, PropPlacement = {0.0, 0.0, 0.0, 0.0, 0.0, 0.0},
EmoteMoving = true, EmoteLoop = true, }},
["pineapple"] = {"mp_player_inteat@burger", "mp_player_int_eat_burger_fp", "Pizza", AnimationOptions =
{ Prop = "prop_pineapple", PropBone = 18905, PropPlacement = {0.10, 0.038, 0.03, 15.0, 50.0},
EmoteMoving = true, EmoteLoop = true, }},
["foodbowl"] = {"amb@world_human_drinking@coffee@male@idle_a", "idle_c", "bowl", AnimationOptions =
{ Prop = "prop_cs_bowl_01", PropBone = 28422, PropPlacement = {0.0, 0.0, 0.050, 0.0, 0.0, 0.0},
EmoteMoving = true, EmoteLoop = true, }},
--Jim-BurgerShot
["milk"] = {"mp_player_intdrink", "loop_bottle", "Milk", AnimationOptions =
{ Prop = "v_res_tt_milk", PropBone = 18905, PropPlacement = {0.10, 0.008, 0.07, 240.0, -60.0},
EmoteMoving = true, EmoteLoop = true, }},
["bscoke"] = {"mp_player_intdrink", "loop_bottle", "BS Coke", AnimationOptions =
{ Prop = "prop_food_bs_juice01", PropBone = 18905, PropPlacement = {0.04, -0.10, 0.10, 240.0, -60.0},
EmoteMoving = true, EmoteLoop = true, }},
["bscoffee"] = {"mp_player_intdrink", "loop_bottle", "BS Coffee", AnimationOptions =
{ Prop = "prop_food_bs_coffee", PropBone = 18905, PropPlacement = {0.08, -0.10, 0.10, 240.0, -60.0},
EmoteMoving = true, EmoteLoop = true, }},
["glass"] = {"amb@world_human_drinking@coffee@male@idle_a", "idle_c", "Tall Glass", AnimationOptions =
{ Prop = 'prop_wheat_grass_glass', PropBone = 28422, PropPlacement = {0.0, 0.0, -0.1, 0.0, 0.0, 0.0},
EmoteLoop = true, EmoteMoving = true, }},
["torpedo"] = {"mp_player_inteat@burger", "mp_player_int_eat_burger_fp", "Torpedo", AnimationOptions =
{ Prop = "prop_food_bs_burger2", PropBone = 18905, PropPlacement = {0.10, -0.07, 0.091, 15.0, 135.0},
EmoteMoving = true, EmoteLoop = true, }},
["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, }},
["donut2"] = {"mp_player_inteat@burger", "mp_player_int_eat_burger", "Donut2", AnimationOptions =
{ Prop = 'prop_donut_02', PropBone = 18905, PropPlacement = {0.13, 0.05, 0.02, -50.0, 100.0, 270.0},
EmoteMoving = true, EmoteLoop = true, }},
--Jim-CatCafe
["boba1"] = {"amb@world_human_drinking@coffee@male@idle_a", "idle_c", "Boba 1", AnimationOptions =
{ Prop = 'denis3d_catcafe_boobaA', PropBone = 28422, PropPlacement = {0.0, 0.0, -0.1, 0.0, 0.0, 0.0},
EmoteLoop = true, EmoteMoving = true, }},
["boba2"] = {"amb@world_human_drinking@coffee@male@idle_a", "idle_c", "Boba 2", AnimationOptions =
{ Prop = 'denis3d_catcafe_boobaB', PropBone = 28422, PropPlacement = {0.0, 0.0, -0.1, 0.0, 0.0, 0.0},
EmoteLoop = true, EmoteMoving = true, }},
["boba3"] = {"amb@world_human_drinking@coffee@male@idle_a", "idle_c", "Boba 3", AnimationOptions =
{ Prop = 'denis3d_catcafe_boobaC', PropBone = 28422, PropPlacement = {0.0, 0.0, -0.1, 0.0, 0.0, 0.0},
EmoteLoop = true, EmoteMoving = true, }},
["boba4"] = {"amb@world_human_drinking@coffee@male@idle_a", "idle_c", "Boba 4", AnimationOptions =
{ Prop = 'denis3d_catcafe_boobaD', PropBone = 28422, PropPlacement = {0.0, 0.0, -0.1, 0.0, 0.0, 0.0},
EmoteLoop = true, EmoteMoving = true, }},
["mochi"] = {"amb@world_human_drinking@coffee@male@idle_a", "idle_c", "Mochi", AnimationOptions =
{ Prop = 'denis3d_catcafe_plateD', PropBone = 28422, PropPlacement = {0.0, 0.0, 0.0, 0.0, 0.0, 0.0},
EmoteLoop = true, EmoteMoving = true, }},
--Jim-Tequilala
["whiskeyb"] = {"anim@amb@nightclub@mini@drinking@drinking_shots@ped_b@normal@", "glass_hold", "Whiskey Bottle", AnimationOptions =
{ Prop = "prop_cs_whiskey_bottle", PropBone = 60309, PropPlacement = {0.08, 0.0, 0.05, 240.0, -60.0},
EmoteMoving = true, EmoteLoop = true }},
["rumb"] = {"anim@amb@nightclub@mini@drinking@drinking_shots@ped_b@normal@", "glass_hold", "Rum Bottle", AnimationOptions =
{ Prop = "prop_rum_bottle", PropBone = 60309, PropPlacement = {-0.04, -0.18, 0.12, 240.0, -60.0},
EmoteMoving = true, EmoteLoop = true }},
["icream"] = {"anim@amb@nightclub@mini@drinking@drinking_shots@ped_b@normal@", "glass_hold", "Irish Cream Bottle", AnimationOptions =
{ Prop = "prop_bottle_brandy", PropBone = 60309, PropPlacement = {-0.04, -0.18, 0.12, 240.0, -60.0},
EmoteMoving = true, EmoteLoop = true }},
["ginb"] = {"anim@amb@nightclub@mini@drinking@drinking_shots@ped_b@normal@", "glass_hold", "Gin Bottle", AnimationOptions =
{ Prop = "prop_tequila_bottle", PropBone = 60309, PropPlacement = {-0.04, -0.18, 0.12, 240.0, -60.0},
EmoteMoving = true, EmoteLoop = true }},
["vodkab"] = {"anim@amb@nightclub@mini@drinking@drinking_shots@ped_b@normal@", "glass_hold", "Vodka Bottle", AnimationOptions =
{ Prop = 'prop_vodka_bottle', PropBone = 60309, PropPlacement = {-0.04, -0.18, 0.12, 240.0, -60.0},
EmoteMoving = true, EmoteLoop = true }},
["browncup"] = {"amb@world_human_drinking@coffee@male@idle_a", "idle_c", "Brown Cup", AnimationOptions =
{ Prop = 'v_serv_bs_mug', PropBone = 28422, PropPlacement = {0.03, -0.02, 0.0, 0.0, 0.0, 0.0},
EmoteLoop = true, EmoteMoving = true, }},
["crisps"] = {"amb@world_human_drinking@coffee@male@idle_a", "idle_c", "Crisps", 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, }},
["smoke2"] = {"amb@world_human_aa_smoke@male@idle_a", "idle_c", "Smoke 2", 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, }},
["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, }},
["smoke4"] = {"amb@world_human_smoking@female@idle_a", "idle_b", "Smoke 4", 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, }},
["bong"] = {"anim@safehouse@bong", "bong_stage3", "Bong", AnimationOptions =
{ Prop = 'hei_heist_sh_bong_01', PropBone = 18905, PropPlacement = {0.10,-0.25,0.0,95.0,190.0,180.0}, }},
["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, }},
["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, }},
["beer"] = {"amb@world_human_drinking@coffee@male@idle_a", "idle_c", "Beer", AnimationOptions =
{ Prop = 'prop_amb_beer_bottle', PropBone = 28422, PropPlacement = {0.0, 0.0, 0.0, 0.0, 0.0, 0.0},
EmoteLoop = true, EmoteMoving = true, }},
["cup"] = {"amb@world_human_drinking@coffee@male@idle_a", "idle_c", "Cup", AnimationOptions =
{ Prop = 'prop_plastic_cup_02', PropBone = 28422, PropPlacement = {0.0, 0.0, 0.0, 0.0, 0.0, 0.0},
EmoteLoop = true, EmoteMoving = true, }},
["donut"] = {"mp_player_inteat@burger", "mp_player_int_eat_burger", "Donut", AnimationOptions =
{ Prop = 'prop_amb_donut', PropBone = 18905, PropPlacement = {0.13, 0.05, 0.02, -50.0, 16.0, 60.0},
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, }},
["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, }},
["soda"] = {"amb@world_human_drinking@coffee@male@idle_a", "idle_c", "Soda", AnimationOptions =
{ Prop = 'prop_ecola_can', PropBone = 28422, PropPlacement = {0.0, 0.0, 0.0, 0.0, 0.0, 130.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, }},
["wine"] = {"anim@heists@humane_labs@finale@keycards", "ped_a_enter_loop", "Wine", AnimationOptions =
{ Prop = 'prop_drink_redwine', PropBone = 18905, PropPlacement = {0.10, -0.03, 0.03, -100.0, 0.0, -10.0},
EmoteMoving = true, EmoteLoop = true }},
["flute"] = {"anim@heists@humane_labs@finale@keycards", "ped_a_enter_loop", "Flute", AnimationOptions =
{ Prop = 'prop_champ_flute', PropBone = 18905, PropPlacement = {0.10, -0.03, 0.03, -100.0, 0.0, -10.0},
EmoteMoving = true, EmoteLoop = true }},
["champagne"] = {"anim@heists@humane_labs@finale@keycards", "ped_a_enter_loop", "Champagne", AnimationOptions =
{ Prop = 'prop_drink_champ', PropBone = 18905, PropPlacement = {0.10, -0.03, 0.03, -100.0, 0.0, -10.0},
EmoteMoving = true, EmoteLoop = true }},
["cigar"] = {"amb@world_human_smoking@male@male_a@enter", "enter", "Cigar", AnimationOptions =
{ Prop = 'prop_cigar_02', PropBone = 47419, PropPlacement = {0.010, 0.0, 0.0, 50.0, 0.0, -80.0},
EmoteMoving = true, EmoteDuration = 2600 }},
["cigar2"] = {"amb@world_human_smoking@male@male_a@enter", "enter", "Cigar 2", AnimationOptions =
{ Prop = 'prop_cigar_01', PropBone = 47419, PropPlacement = {0.010, 0.0, 0.0, 50.0, 0.0, -80.0},
EmoteMoving = true, EmoteDuration = 2600 }},
["joint"] = {"amb@world_human_smoking@male@male_a@enter", "enter", "Joint", AnimationOptions =
{ Prop = 'p_cs_joint_02', PropBone = 47419, PropPlacement = {0.015, -0.009, 0.003, 55.0, 0.0, 110.0},
EmoteMoving = true, EmoteDuration = 2600 }},
["cig"] = {"amb@world_human_smoking@male@male_a@enter", "enter", "Cig", AnimationOptions =
{ Prop = 'prop_amb_ciggy_01', PropBone = 47419, PropPlacement = {0.015, -0.009, 0.003, 55.0, 0.0, 110.0},
EmoteMoving = true, EmoteDuration = 2600 }},
["clean"] = {"timetable@floyd@clean_kitchen@base", "base", "Clean", AnimationOptions =
{ Prop = "prop_sponge_01", PropBone = 28422, PropPlacement = {0.0, 0.0, -0.01, 90.0, 0.0, 0.0},
EmoteLoop = true, EmoteMoving = true, }},
["clean2"] = {"amb@world_human_maid_clean@", "base", "Clean 2", AnimationOptions =
{ Prop = "prop_sponge_01", PropBone = 28422, PropPlacement = {0.0, 0.0, -0.01, 90.0, 0.0, 0.0},
EmoteLoop = true, EmoteMoving = true, }},
["coke"] = { "switch@trevor@trev_smoking_meth", "trev_smoking_meth_loop", "Coke", AnimationOptions =
{ EmoteLoop = true, EmoteMoving = true, }},
["oxy"] = { "mp_suicide", "pill", "Oxy", AnimationOptions =
{ EmoteLoop = true, EmoteMoving = true, }},
},
}
}

View File

@@ -1,10 +1,11 @@
name "Jim-Consumables"
author "Jimathy"
version "v1.0"
version "v1.5"
description "Consumable Script By Jimathy"
fx_version "cerulean"
game "gta5"
lua54 'yes'
shared_scripts { 'config.lua', 'shared/*.lua' }
client_scripts { 'client/*.lua', }
server_scripts { 'server/*.lua' }
shared_scripts { 'config.lua', }

View File

@@ -1,15 +1,97 @@
local QBCore = exports['qb-core']:GetCoreObject()
--Consumables
CreateThread(function()
for k,v in pairs(Config.Consumables) do
QBCore.Functions.CreateUseableItem(k, function(source, item)
TriggerClientEvent('jim-consumables:Consume', source, item.name)
end)
for k, v in pairs(Config.Consumables) do
QBCore.Functions.CreateUseableItem(k, function(source, item) TriggerClientEvent('jim-consumables:Consume', source, item.name) end)
if not QBCore.Shared.Items[k] then print("^1Debug^7: ^2Item check ^7- '^1"..k.."^7' ^2not found in the shared lua^7") end
if not Config.Emotes[v.emote] then print("^1Debug^7: ^2Emote check ^7- '^1"..k.."^7' ^2requested emote ^7'^6"..v.emote.."^7' - ^2not found in config^7.^2lua^7") end
end
RegisterNetEvent("jim-consumables:server:DupeWarn", function(item, newsrc)
local src = newsrc or source
local P = QBCore.Functions.GetPlayer(src)
print("^5DupeWarn: ^1"..P.PlayerData.charinfo.firstname.." "..P.PlayerData.charinfo.lastname.."^7(^1"..tostring(src).."^7) ^2Tried to remove item ^7('^3"..item.."^7')^2 but it wasn't there^7")
if not Config.Debug then DropPlayer(src, "Kicked for attempting to duplicate items") end
print("^5DupeWarn: ^1"..P.PlayerData.charinfo.firstname.." "..P.PlayerData.charinfo.lastname.."^7(^1"..tostring(src).."^7) ^2Dropped from server for item duplicating^7")
end)
RegisterNetEvent('jim-consumables:server:toggleItem', function(give, item, amount, newsrc)
local src = newsrc or source
local amount = amount or 1
local remamount = amount
if not give then
if HasItem(src, item, amount) then -- check if you still have the item
if QBCore.Functions.GetPlayer(src).Functions.GetItemByName(item).unique then -- If unique item, keep removing until gone
while remamount > 0 do
QBCore.Functions.GetPlayer(src).Functions.RemoveItem(item, 1)
remamount -= 1
end
TriggerClientEvent('inventory:client:ItemBox', src, QBCore.Shared.Items[item], "remove", amount) -- Show removal item box when all are removed
return
end
if QBCore.Functions.GetPlayer(src).Functions.RemoveItem(item, amount) then
if Config.Debug then print("^5Debug^7: ^1Removing ^2from Player^7(^2"..src.."^7) '^6"..QBCore.Shared.Items[item].label.."^7(^2x^6"..(amount or "1").."^7)'") end
TriggerClientEvent('inventory:client:ItemBox', src, QBCore.Shared.Items[item], "remove", amount)
end
else TriggerEvent("jim-consumables:server:DupeWarn", item, src) end -- if not boot the player
elseif give then
if QBCore.Functions.GetPlayer(src).Functions.AddItem(item, amount) then
if Config.Debug then print("^5Debug^7: ^4Giving ^2Player^7(^2"..src.."^7) '^6"..QBCore.Shared.Items[item].label.."^7(^2x^6"..(amount or "1").."^7)'") end
TriggerClientEvent('inventory:client:ItemBox', src, QBCore.Shared.Items[item], "add", amount)
end
end
for k,v in pairs(Config.Consumables) do
QBCore.Functions.CreateUseableItem(k, function(source, item) TriggerClientEvent('jim-consumables:Consume', source, item.name) end)
if not QBCore.Shared.Items[k] then print("Item check - '"..k.."' not found in the shared lua") end
if not Config.Emotes[v.emote] then print("Emote check - '"..k.."' requested emote '"..v.emote.."' - not found in config.lua") 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)
end)
function HasItem(source, items, amount)
local amount = amount or 1
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
if Config.Debug then print("^5Debug^7: ^3HasItem^7: ^2Item^7: '^3"..tostring(items).."^7' ^2Slot^7: ^3"..itemData.slot.." ^7x(^3"..tostring(itemData.amount).."^7)") end
count += itemData.amount
end
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
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
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
exports("importEmote", importEmote)
exports("importConsumable", importConsumable)

268
shared/shared.lua Normal file
View File

@@ -0,0 +1,268 @@
local QBCore = exports['qb-core']:GetCoreObject()
RegisterNetEvent('QBCore:Client:UpdateObject', function() QBCore = exports['qb-core']:GetCoreObject() end)
local time = 1000
function loadModel(model) if not HasModelLoaded(model) then
if Config.Debug then print("^5Debug^7: ^2Loading Model^7: '^6"..model.."^7'") end
while not HasModelLoaded(model) do
if time > 0 then time -= 1 RequestModel(model)
else time = 1000 print("^5Debug^7: ^3LoadModel^7: ^2Timed out loading model ^7'^6"..model.."^7'") break
end
Wait(10)
end
end end
function unloadModel(model) if Config.Debug then print("^5Debug^7: ^2Removing Model^7: '^6"..model.."^7'") end SetModelAsNoLongerNeeded(model) end
function loadAnimDict(dict) if not HasAnimDictLoaded(dict) then if Config.Debug then print("^5Debug^7: ^2Loading Anim Dictionary^7: '^6"..dict.."^7'") end while not HasAnimDictLoaded(dict) do RequestAnimDict(dict) Wait(5) end end end
function unloadAnimDict(dict) if Config.Debug then print("^5Debug^7: ^2Removing Anim Dictionary^7: '^6"..dict.."^7'") end RemoveAnimDict(dict) end
function loadPtfxDict(dict) if not HasNamedPtfxAssetLoaded(dict) then if Config.Debug then print("^5Debug^7: ^2Loading Ptfx Dictionary^7: '^6"..dict.."^7'") end while not HasNamedPtfxAssetLoaded(dict) do RequestNamedPtfxAsset(dict) Wait(5) end end end
function unloadPtfxDict(dict) if Config.Debug then print("^5Debug^7: ^2Removing Ptfx Dictionary^7: '^6"..dict.."^7'") end RemoveNamedPtfxAsset(dict) end
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
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)
else TriggerClientEvent('okokNotify:Alert', src, title, message, 6000, type) end
elseif Config.Notify == "qb" then
if not src then TriggerEvent("QBCore:Notify", message, type)
else TriggerClientEvent("QBCore:Notify", src, message, type) end
elseif Config.Notify == "t" then
if not src then exports['t-notify']:Custom({title = title, style = type, message = message, sound = true})
else TriggerClientEvent('t-notify:client:Custom', src, { style = type, duration = 6000, title = title, message = message, sound = true, custom = true}) end
elseif Config.Notify == "infinity" then
if not src then TriggerEvent('infinity-notify:sendNotify', message, type)
else TriggerClientEvent('infinity-notify:sendNotify', src, message, type) end
elseif Config.Notify == "rr" then
if not src then exports.rr_uilib:Notify({msg = message, type = type, style = "dark", duration = 6000, position = "top-right", })
else TriggerClientEvent("rr_uilib:Notify", src, {msg = message, type = type, style = "dark", duration = 6000, position = "top-right", }) end
end
end
function countTable(table) local i = 0 for keys in pairs(table) do i += 1 end return i end
function toggleItem(give, item, amount) TriggerServerEvent("jim-consumables:server:toggleItem", give, item, amount) end
function HasItem(items, amount)
local amount = amount or 1
local count = 0
for _, itemData in pairs(QBCore.Functions.GetPlayerData().items) do
if itemData and (itemData.name == items) then
if Config.Debug then print("^5Debug^7: ^3HasItem^7: ^2Item^7: '^3"..tostring(items).."^7' ^2Slot^7: ^3"..itemData.slot.." ^7x(^3"..tostring(itemData.amount).."^7)") end
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
else
if Config.Debug then print("^5Debug^7: ^3HasItem^7: ^2Items ^1NOT FOUND^7") end
return false
end
end
--Screen Effects
local alienEffect = false
function AlienEffect()
if alienEffect then return else alienEffect = true end
if Config.Debug then print("^5Debug^7: ^3AlienEffect^7() ^2activated") end
AnimpostfxPlay("DrugsMichaelAliensFightIn", 3.0, 0)
Wait(math.random(5000, 8000))
local Ped = PlayerPedId()
local animDict = "MOVE_M@DRUNK@VERYDRUNK"
loadAnimDict(animDict)
SetPedCanRagdoll(Ped, true)
ShakeGameplayCam('DRUNK_SHAKE', 2.80)
SetTimecycleModifier("Drunk")
SetPedMovementClipset(Ped, animDict, 1)
SetPedMotionBlur(Ped, true)
SetPedIsDrunk(Ped, true)
Wait(1500)
SetPedToRagdoll(Ped, 5000, 1000, 1, 0, 0, 0)
Wait(13500)
SetPedToRagdoll(Ped, 5000, 1000, 1, 0, 0, 0)
Wait(120500)
ClearTimecycleModifier()
ResetScenarioTypesEnabled()
ResetPedMovementClipset(Ped, 0)
SetPedIsDrunk(Ped, false)
SetPedMotionBlur(Ped, false)
AnimpostfxStopAll()
ShakeGameplayCam('DRUNK_SHAKE', 0.0)
AnimpostfxPlay("DrugsMichaelAliensFight", 3.0, 0)
Wait(math.random(45000, 60000))
AnimpostfxPlay("DrugsMichaelAliensFightOut", 3.0, 0)
AnimpostfxStop("DrugsMichaelAliensFightIn")
AnimpostfxStop("DrugsMichaelAliensFight")
AnimpostfxStop("DrugsMichaelAliensFightOut")
alienEffect = false
if Config.Debug then print("^5Debug^7: ^3AlienEffect^7() ^2stopped") end
end
local weedEffect = false
function WeedEffect()
if weedEffect then return else weedEffect = true end
if Config.Debug then print("^5Debug^7: ^3WeedEffect^7() ^2activated") end
AnimpostfxPlay("DrugsMichaelAliensFightIn", 3.0, 0)
Wait(math.random(3000, 20000))
AnimpostfxPlay("DrugsMichaelAliensFight", 3.0, 0)
Wait(math.random(15000, 20000))
AnimpostfxPlay("DrugsMichaelAliensFightOut", 3.0, 0)
AnimpostfxStop("DrugsMichaelAliensFightIn")
AnimpostfxStop("DrugsMichaelAliensFight")
AnimpostfxStop("DrugsMichaelAliensFightOut")
weedEffect = false
if Config.Debug then print("^5Debug^7: ^3WeedEffect^7() ^2stopped") end
end
local trevorEffect = false
function TrevorEffect()
if trevorEffect then return else trevorEffect = true end
if Config.Debug then print("^5Debug^7: ^3TrevorEffect^7() ^2activated") end
AnimpostfxPlay("DrugsTrevorClownsFightIn", 3.0, 0)
Wait(3000)
AnimpostfxPlay("DrugsTrevorClownsFight", 3.0, 0)
Wait(30000)
AnimpostfxPlay("DrugsTrevorClownsFightOut", 3.0, 0)
AnimpostfxStop("DrugsTrevorClownsFight")
AnimpostfxStop("DrugsTrevorClownsFightIn")
AnimpostfxStop("DrugsTrevorClownsFightOut")
trevorEffect = false
if Config.Debug then print("^5Debug^7: ^3TrevorEffect^7() ^2stopped") end
end
local turboEffect = false
function TurboEffect()
if turboEffect then return else turboEffect = true end
if Config.Debug then print("^5Debug^7: ^3TurboEffect^7() ^2activated") end
AnimpostfxPlay('RaceTurbo', 0, true)
SetTimecycleModifier('rply_motionblur')
ShakeGameplayCam('SKY_DIVING_SHAKE', 0.25)
Wait(30000)
StopGameplayCamShaking(true)
SetTransitionTimecycleModifier('default', 0.35)
Wait(1000)
ClearTimecycleModifier()
AnimpostfxStop('RaceTurbo')
turboEffect = false
if Config.Debug then print("^5Debug^7: ^3TurboEffect^7() ^2stopped") end
end
local rampageEffect = false
function RampageEffect()
if rampageEffect then return else rampageEffect = true end
if Config.Debug then print("^5Debug^7: ^3RampageEffect^7() ^2activated") end
AnimpostfxPlay('Rampage', 0, true)
SetTimecycleModifier('rply_motionblur')
ShakeGameplayCam('SKY_DIVING_SHAKE', 0.25)
Wait(30000)
StopGameplayCamShaking(true)
SetTransitionTimecycleModifier('default', 0.35)
Wait(1000)
ClearTimecycleModifier()
AnimpostfxStop('Rampage')
rampageEffect = false
if Config.Debug then print("^5Debug^7: ^3RampageEffect^7() ^2stopped") end
end
local focusEffect = false
function FocusEffect()
if focusEffect then return else focusEffect = true end
if Config.Debug then print("^5Debug^7: ^3FocusEffect^7() ^2activated") end
Wait(1000)
AnimpostfxPlay('FocusIn', 0, true)
Wait(30000)
AnimpostfxStop('FocusIn')
focusEffect = false
if Config.Debug then print("^5Debug^7: ^3FocusEffect^7() ^2stopped") end
end
local NightVisionEffect = false
function NightVisionEffect()
if NightVisionEffect then return else NightVisionEffect = true end
if Config.Debug then print("^5Debug^7: ^3NightVisionEffect^7() ^2activated") end
SetNightvision(true)
Wait(math.random(3000, 4000)) -- FEEL FREE TO CHANGE THIS
SetNightvision(false)
SetSeethrough(false)
NightVisionEffect = false
if Config.Debug then print("^5Debug^7: ^3NightVisionEffect^7() ^2stopped") end
end
local thermalEffect = false
function ThermalEffect()
if thermalEffect then return else thermalEffect = true end
if Config.Debug then print("^5Debug^7: ^3ThermalEffect^7() ^2activated") end
SetNightvision(true)
SetSeethrough(true)
Wait(math.random(2000, 3000)) -- FEEL FREE TO CHANGE THIS
SetNightvision(false)
SetSeethrough(false)
thermalEffect = false
if Config.Debug then print("^5Debug^7: ^3ThermalEffect^7() ^2stopped") end
end
--Built-in Buff effects
local healEffect = false
function HealEffect(data)
if healEffect then return end
if Config.Debug then print("^5Debug^7: ^3HealEffect^7() ^2activated") end
healEffect = true
local count = (data[1] / 1000)
while count > 0 do
Wait(1000)
count -= 1
SetEntityHealth(PlayerPedId(), GetEntityHealth(PlayerPedId()) + data[2])
end
healEffect = false
if Config.Debug then print("^5Debug^7: ^3HealEffect^7() ^2stopped") end
end
local staminaEffect = false
function StaminaEffect(data)
if staminaEffect then return end
if Config.Debug then print("^5Debug^7: ^3StaminaEffect^7() ^2activated") end
staminaEffect = true
local startStamina = (data[1] / 1000)
SetRunSprintMultiplierForPlayer(PlayerId(), 1.49)
while startStamina > 0 do
Wait(1000)
if math.random(5, 100) < 10 then RestorePlayerStamina(PlayerId(), data[2]) end
startStamina -= 1
if math.random(5, 100) < 51 then end
end
startStamina = 0
SetRunSprintMultiplierForPlayer(PlayerId(), 1.0)
staminaEffect = false
if Config.Debug then print("^5Debug^7: ^3StaminaEffect^7() ^2stopped") end
end
function StopEffects() -- Used to clear up any effects stuck on screen
if Config.Debug then print("^5Debug^7: ^2All screen effects stopped") end
ShakeGameplayCam('DRUNK_SHAKE', 0.0)
SetPedToRagdoll(PlayerPedId(), 5000, 1000, 1, 0, 0, 0)
ClearTimecycleModifier()
ResetScenarioTypesEnabled()
ResetPedMovementClipset(PlayerPedId(), 0)
SetPedIsDrunk(PlayerPedId(), false)
SetPedMotionBlur(PlayerPedId(), false)
SetNightvision(false)
SetSeethrough(false)
AnimpostfxStop("DrugsMichaelAliensFightIn")
AnimpostfxStop("DrugsMichaelAliensFight")
AnimpostfxStop("DrugsMichaelAliensFightOut")
AnimpostfxStop("DrugsTrevorClownsFight")
AnimpostfxStop("DrugsTrevorClownsFightIn")
AnimpostfxStop("DrugsTrevorClownsFightOut")
AnimpostfxStop('RaceTurbo')
AnimpostfxStop('FocusIn')
AnimpostfxStop('Rampage')
end