mirror of
https://github.com/jimathy/jim-consumables.git
synced 2026-08-16 22:16:02 +01:00
@@ -1,6 +1,5 @@
|
|||||||
local QBCore = exports['qb-core']:GetCoreObject()
|
local QBCore = exports['qb-core']:GetCoreObject()
|
||||||
|
|
||||||
PlayerJob = {}
|
|
||||||
local alcoholCount = 0
|
local alcoholCount = 0
|
||||||
local drugCount = 0
|
local drugCount = 0
|
||||||
|
|
||||||
@@ -8,6 +7,9 @@ local drugCount = 0
|
|||||||
for k in pairs(Config.Emotes) do
|
for k in pairs(Config.Emotes) do
|
||||||
if Config.Emotes[k].AnimationOptions.Prop then
|
if Config.Emotes[k].AnimationOptions.Prop then
|
||||||
Config.Emotes[k].AnimationOptions.Prop = GetHashKey(Config.Emotes[k].AnimationOptions.Prop)
|
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
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -21,12 +23,17 @@ RegisterNetEvent('jim-consumables:Consume', function(itemName)
|
|||||||
local emote = Config.Emotes[Config.Consumables[itemName].emote]
|
local emote = Config.Emotes[Config.Consumables[itemName].emote]
|
||||||
local animDict = tostring(emote[1])
|
local animDict = tostring(emote[1])
|
||||||
local anim = tostring(emote[2])
|
local anim = tostring(emote[2])
|
||||||
local model, bone, drugeffect, stress
|
local model, model2, bone, bone2, drugeffect, stress
|
||||||
local P1, P2, P3, P4, P5, P6 = table.unpack({0.0, 0.0, 0.0, 0.0, 0.0, 0.0})
|
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
|
||||||
if emote.AnimationOptions.Prop then
|
if emote.AnimationOptions.Prop then
|
||||||
model = emote.AnimationOptions.Prop
|
model = emote.AnimationOptions.Prop
|
||||||
bone = GetPedBoneIndex(PlayerPedId(), emote.AnimationOptions.PropBone)
|
bone = GetPedBoneIndex(PlayerPedId(), emote.AnimationOptions.PropBone)
|
||||||
P1, P2, P3, P4, P5, P6 = table.unpack(emote.AnimationOptions.PropPlacement)
|
P1, P2, P3, P4, P5, P6 = table.unpack(emote.AnimationOptions.PropPlacement)
|
||||||
|
if emote.AnimationOptions.SecondProp then
|
||||||
|
model2 = emote.AnimationOptions.SecondProp
|
||||||
|
bone2 = GetPedBoneIndex(PlayerPedId(), emote.AnimationOptions.SecondPropBone)
|
||||||
|
P7, P8, P9, P10, P11, P12 = table.unpack(emote.AnimationOptions.SecondPropPlacement)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
local time = Config.Consumables[itemName].time or math.random(5000, 6000)
|
local time = Config.Consumables[itemName].time or math.random(5000, 6000)
|
||||||
local type = Config.Consumables[itemName].type or "food"
|
local type = Config.Consumables[itemName].type or "food"
|
||||||
@@ -76,14 +83,19 @@ RegisterNetEvent('jim-consumables:Consume', function(itemName)
|
|||||||
consuming = true
|
consuming = true
|
||||||
CreateThread(function()
|
CreateThread(function()
|
||||||
--Prop Spawning
|
--Prop Spawning
|
||||||
if model then
|
if model and IsModelValid(model) == 1 then
|
||||||
if Config.Debug then print("^5Debug^7: ^3Consume^7: ^2Spawning consumable prop^7.") end
|
if Config.Debug then print("^5Debug^7: ^3PropSpawn^7: ^2Spawning consumable prop^7.") end
|
||||||
local attachProp = makeProp({ prop = model, coords = vector4(0.0,0.0,0.0,0.0)}, 1, 1)
|
attachProp = makeProp({ prop = model, coords = vector4(0.0,0.0,0.0,0.0)}, 1, 1)
|
||||||
AttachEntityToEntity(attachProp, PlayerPedId(), bone, P1, P2, P3, P4, P5, P6, true, true, false, true, 1, true)
|
AttachEntityToEntity(attachProp, PlayerPedId(), bone, P1, P2, P3, P4, P5, P6, true, true, false, true, 1, true)
|
||||||
while consuming do Wait(100) end
|
if model2 and IsModelValid(model2) == 1 then
|
||||||
destroyProp(attachProp)
|
attachProp2 = makeProp({ prop = model2, coords = vector4(0.0,0.0,0.0,0.0)}, 1, 1)
|
||||||
end
|
AttachEntityToEntity(attachProp2, PlayerPedId(), bone2, P7, P8, P9, P10, P11, P12, true, true, false, true, 1, true)
|
||||||
end)
|
else print("^5Debug^7: ^3Consume^7: ^2Second prop model isn't valid/found^7.") end
|
||||||
|
while consuming do Wait(50) end
|
||||||
|
if DoesEntityExist(attachProp) then destroyProp(attachProp) attachProp = nil end
|
||||||
|
if DoesEntityExist(attachProp2) then destroyProp(attachProp2) attackProp = nil end
|
||||||
|
else print("^5Debug^7: ^3PropSpawnstop^7: ^2Prop model isn't valid/found^7.") end
|
||||||
|
end)
|
||||||
while consuming do
|
while consuming do
|
||||||
if time <= 0 then consuming = false end
|
if time <= 0 then consuming = false end
|
||||||
if not Config.Consumables[itemName].canRun then
|
if not Config.Consumables[itemName].canRun then
|
||||||
@@ -100,7 +112,7 @@ RegisterNetEvent('jim-consumables:Consume', function(itemName)
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
Wait(10)
|
Wait(10)
|
||||||
time = time - 10
|
time -= 10
|
||||||
end
|
end
|
||||||
StopEntityAnim(PlayerPedId(), anim, animDict, 1.0)
|
StopEntityAnim(PlayerPedId(), anim, animDict, 1.0)
|
||||||
unloadAnimDict(animDict)
|
unloadAnimDict(animDict)
|
||||||
@@ -153,7 +165,7 @@ RegisterNetEvent('jim-consumables:Consume', function(itemName)
|
|||||||
end
|
end
|
||||||
if stats.canOD then
|
if stats.canOD then
|
||||||
if Config.Debug then print("^5Debug^7: ^3Consume^7: ^2Current ^4drugCount^7: ^6"..(drugCount + 1)) end
|
if Config.Debug then print("^5Debug^7: ^3Consume^7: ^2Current ^4drugCount^7: ^6"..(drugCount + 1)) end
|
||||||
drugCount = drugCount + 1
|
drugCount += 1
|
||||||
if drugCount >= 4 then
|
if drugCount >= 4 then
|
||||||
if Config.Debug then print("^5Debug^7: ^3Consume^7: ^2Current ^4drugCount^7: ^6"..drugCount.."^7 - ^2 removing health") end
|
if Config.Debug then print("^5Debug^7: ^3Consume^7: ^2Current ^4drugCount^7: ^6"..drugCount.."^7 - ^2 removing health") end
|
||||||
SetEntityHealth(PlayerPedId(), GetEntityHealth(PlayerPedId()) - math.random(10,15))
|
SetEntityHealth(PlayerPedId(), GetEntityHealth(PlayerPedId()) - math.random(10,15))
|
||||||
@@ -194,13 +206,13 @@ CreateThread(function()
|
|||||||
Wait(10)
|
Wait(10)
|
||||||
if alcoholCount > 0 then
|
if alcoholCount > 0 then
|
||||||
Wait(1000 * 60 * 15)
|
Wait(1000 * 60 * 15)
|
||||||
alcoholCount = alcoholCount - 1
|
alcoholCount -= 1
|
||||||
else
|
else
|
||||||
Wait(1000)
|
Wait(1000)
|
||||||
end
|
end
|
||||||
if drugCount > 0 then
|
if drugCount > 0 then
|
||||||
Wait(1000 * 60 * 15)
|
Wait(1000 * 60 * 15)
|
||||||
drugCount = drugCount - 1
|
drugCount -= 1
|
||||||
else
|
else
|
||||||
Wait(1000)
|
Wait(1000)
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -1,10 +1,11 @@
|
|||||||
name "Jim-Consumables"
|
name "Jim-Consumables"
|
||||||
author "Jimathy"
|
author "Jimathy"
|
||||||
version "v1.3.1"
|
version "v1.3.2"
|
||||||
description "Consumable Script By Jimathy"
|
description "Consumable Script By Jimathy"
|
||||||
fx_version "cerulean"
|
fx_version "cerulean"
|
||||||
game "gta5"
|
game "gta5"
|
||||||
|
lua54 'yes'
|
||||||
|
|
||||||
shared_scripts { 'config.lua', 'shared/*.lua' }
|
shared_scripts { 'config.lua', 'shared/*.lua' }
|
||||||
client_scripts { 'client/*.lua', }
|
client_scripts { 'client/*.lua', }
|
||||||
server_scripts { 'server/*.lua' }
|
server_scripts { 'server/*.lua' }
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ local time = 1000
|
|||||||
function loadModel(model) if not HasModelLoaded(model) then
|
function loadModel(model) if not HasModelLoaded(model) then
|
||||||
if Config.Debug then print("^5Debug^7: ^2Loading Model^7: '^6"..model.."^7'") end
|
if Config.Debug then print("^5Debug^7: ^2Loading Model^7: '^6"..model.."^7'") end
|
||||||
while not HasModelLoaded(model) do
|
while not HasModelLoaded(model) do
|
||||||
if time > 0 then time = time - 1 RequestModel(model)
|
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
|
else time = 1000 print("^5Debug^7: ^3LoadModel^7: ^2Timed out loading model ^7'^6"..model.."^7'") break
|
||||||
end
|
end
|
||||||
Wait(10)
|
Wait(10)
|
||||||
@@ -51,7 +51,7 @@ function triggerNotify(title, message, type, src)
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
function countTable(table) local i = 0 for keys in pairs(table) do i = i + 1 end return i 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 toggleItem(give, item, amount) TriggerServerEvent("jim-consumables:server:toggleItem", give, item, amount) end
|
||||||
|
|
||||||
@@ -198,7 +198,7 @@ function HealEffect(data)
|
|||||||
local count = (data[1] / 1000)
|
local count = (data[1] / 1000)
|
||||||
while count > 0 do
|
while count > 0 do
|
||||||
Wait(1000)
|
Wait(1000)
|
||||||
count = count - 1
|
count -= 1
|
||||||
SetEntityHealth(PlayerPedId(), GetEntityHealth(PlayerPedId()) + data[2])
|
SetEntityHealth(PlayerPedId(), GetEntityHealth(PlayerPedId()) + data[2])
|
||||||
end
|
end
|
||||||
healEffect = false
|
healEffect = false
|
||||||
@@ -215,7 +215,7 @@ function StaminaEffect(data)
|
|||||||
while startStamina > 0 do
|
while startStamina > 0 do
|
||||||
Wait(1000)
|
Wait(1000)
|
||||||
if math.random(5, 100) < 10 then RestorePlayerStamina(PlayerId(), data[2]) end
|
if math.random(5, 100) < 10 then RestorePlayerStamina(PlayerId(), data[2]) end
|
||||||
startStamina = startStamina - 1
|
startStamina -= 1
|
||||||
if math.random(5, 100) < 51 then end
|
if math.random(5, 100) < 51 then end
|
||||||
end
|
end
|
||||||
startStamina = 0
|
startStamina = 0
|
||||||
@@ -244,4 +244,4 @@ function StopEffects() -- Used to clear up any effects stuck on screen
|
|||||||
AnimpostfxStop('RaceTurbo')
|
AnimpostfxStop('RaceTurbo')
|
||||||
AnimpostfxStop('FocusIn')
|
AnimpostfxStop('FocusIn')
|
||||||
AnimpostfxStop('Rampage')
|
AnimpostfxStop('Rampage')
|
||||||
end
|
end
|
||||||
|
|||||||
Reference in New Issue
Block a user