mirror of
https://github.com/jimathy/jim-consumables.git
synced 2026-08-16 22:16:02 +01:00
v1.3 Shared file, optimize, fix client item event
This commit is contained in:
@@ -7,6 +7,14 @@ 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.
|
||||
|
||||
# Installation
|
||||
|
||||
```
|
||||
Please stop asking to how add a progressbar...PLEASE
|
||||
|
||||
This script was designed to not need one, because of how it cancels all the player animations instantly
|
||||
|
||||
You can manage without a progressbar.
|
||||
```
|
||||
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.
|
||||
|
||||
@@ -4,13 +4,6 @@ PlayerJob = {}
|
||||
local alcoholCount = 0
|
||||
local drugCount = 0
|
||||
|
||||
local time = 40
|
||||
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 = time - 1 RequestModel(model) else time = 40 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 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
|
||||
function unloadAnimDict(dict) if Config.Debug then print("^5Debug^7: ^2Removing Anim Dictionary^7: '^6"..dict.."^7'") end RemoveAnimDict(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
|
||||
|
||||
--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
|
||||
@@ -18,184 +11,12 @@ for k in pairs(Config.Emotes) do
|
||||
end
|
||||
end
|
||||
|
||||
--Screen Effects
|
||||
local alienEffect = false
|
||||
function AlienEffect()
|
||||
if alienEffect then return end
|
||||
alienEffect = true
|
||||
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 end
|
||||
weedEffect = true
|
||||
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 end
|
||||
if Config.Debug then print("^5Debug^7: ^3TrevorEffect^7() ^2activated") end
|
||||
trevorEffect = true
|
||||
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 end
|
||||
if Config.Debug then print("^5Debug^7: ^3TurboEffect^7() ^2activated") end
|
||||
turboEffect = true
|
||||
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 end
|
||||
if Config.Debug then print("^5Debug^7: ^3RampageEffect^7() ^2activated") end
|
||||
rampageEffect = true
|
||||
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 end
|
||||
if Config.Debug then print("^5Debug^7: ^3FocusEffect^7() ^2activated") end
|
||||
focusEffect = true
|
||||
AnimpostfxPlay('FocusIn', 0, true)
|
||||
Wait(30000)
|
||||
Wait(1000)
|
||||
AnimpostfxStop('FocusIn')
|
||||
focusEffect = false
|
||||
if Config.Debug then print("^5Debug^7: ^3FocusEffect^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 = 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 = 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()
|
||||
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)
|
||||
AnimpostfxStop("DrugsMichaelAliensFightIn")
|
||||
AnimpostfxStop("DrugsMichaelAliensFight")
|
||||
AnimpostfxStop("DrugsMichaelAliensFightOut")
|
||||
AnimpostfxStop("DrugsTrevorClownsFight")
|
||||
AnimpostfxStop("DrugsTrevorClownsFightIn")
|
||||
AnimpostfxStop("DrugsTrevorClownsFightOut")
|
||||
AnimpostfxStop('RaceTurbo')
|
||||
AnimpostfxStop('FocusIn')
|
||||
AnimpostfxStop('Rampage')
|
||||
end
|
||||
|
||||
local consuming = false
|
||||
local cancelled = false
|
||||
|
||||
RegisterNetEvent('jim-consumables:Consume', function(itemName)
|
||||
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)
|
||||
LocalPlayer.state:set("inv_busy", true, true) TriggerEvent('inventory:client:busy:status', true) TriggerEvent('canUseInventoryAndHotbar:toggle', true)
|
||||
local Player = PlayerPedId()
|
||||
local emote = Config.Emotes[Config.Consumables[itemName].emote]
|
||||
local animDict = tostring(emote[1])
|
||||
@@ -220,7 +41,7 @@ RegisterNetEvent('jim-consumables:Consume', function(itemName)
|
||||
cancelled = true
|
||||
if Config.Debug then print("^5Debug^7: ^3Consume^7: ^2Event already started^7, ^1Cancelling^7.") end
|
||||
LocalPlayer.state:set("inv_busy", false, true)
|
||||
TriggerEvent("QBCore:Notify", "Stopped "..string, "error")
|
||||
triggerNotify(nil, "Stopped "..string, "error")
|
||||
consuming = not consuming
|
||||
return
|
||||
end
|
||||
@@ -246,15 +67,14 @@ RegisterNetEvent('jim-consumables:Consume', function(itemName)
|
||||
loadAnimDict(animDict)
|
||||
TaskPlayAnim(PlayerPedId(), animDict, anim, 1.0, 1.0, -1, MovementType, 0, 0, 0, 0)
|
||||
|
||||
TriggerEvent("QBCore:Notify", string..QBCore.Shared.Items[itemName].label.."..", "success", (time + 1000))
|
||||
triggerNotify(nil, string..QBCore.Shared.Items[itemName].label.."..", "success")
|
||||
consuming = true
|
||||
|
||||
CreateThread(function()
|
||||
--Prop Spawning
|
||||
if model then
|
||||
if Config.Debug then print("^5Debug^7: ^3Consume^7: ^2Spawning consumable prop^7.") end
|
||||
loadModel(model)
|
||||
local attachProp = CreateObject(model, 1.0, 1.0, 1.0, 1, 1, 0)
|
||||
local 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)
|
||||
while consuming do Wait(100) end
|
||||
destroyProp(attachProp)
|
||||
@@ -276,8 +96,8 @@ RegisterNetEvent('jim-consumables:Consume', function(itemName)
|
||||
unloadAnimDict(animDict)
|
||||
|
||||
if not cancelled then
|
||||
TriggerServerEvent("QBCore:Server:RemoveItem", itemName, 1)
|
||||
TriggerEvent("inventory:client:ItemBox", QBCore.Shared.Items[itemName], "remove", 1)
|
||||
|
||||
toggleItem(false, 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
|
||||
@@ -367,8 +187,8 @@ RegisterNetEvent('jim-consumables:Consume', function(itemName)
|
||||
cancelled = false
|
||||
consuming = false
|
||||
|
||||
if Config.Debug then print("^5Debug^7: ^3Consume^7: ^2Finished, unlocking inventory^7..") end
|
||||
LocalPlayer.state:set("inv_busy", false, true)
|
||||
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', false)
|
||||
end)
|
||||
|
||||
CreateThread(function()
|
||||
@@ -378,20 +198,15 @@ CreateThread(function()
|
||||
Wait(1000 * 60 * 15)
|
||||
alcoholCount = alcoholCount - 1
|
||||
else
|
||||
Wait(2000)
|
||||
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)
|
||||
Wait(1000)
|
||||
end
|
||||
end
|
||||
end
|
||||
end)
|
||||
|
||||
AddEventHandler('onResourceStop', function(r) if r ~= GetCurrentResourceName() then return end
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
print("^2Jim^7-^2Consumables v^41^7.^42 ^7- ^2Consumables Script by ^1Jimathy^7")
|
||||
print("^2Jim^7-^2Consumables v^41^7.^43 ^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.
|
||||
|
||||
-- https://discord.gg/xKgQZ6wZvS
|
||||
|
||||
Config = {
|
||||
Debug = false,
|
||||
Debug = true,
|
||||
Consumables = {
|
||||
-- Default QB food and drink item override
|
||||
|
||||
@@ -27,7 +27,8 @@ Config = {
|
||||
-- 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", 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 } }, },]]
|
||||
["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", 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 } },
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
name "Jim-Consumables"
|
||||
author "Jimathy"
|
||||
version "v1.2"
|
||||
version "v1.3"
|
||||
description "Consumable Script By Jimathy"
|
||||
fx_version "cerulean"
|
||||
game "gta5"
|
||||
|
||||
client_scripts { 'client/*.lua', }
|
||||
server_scripts { 'server/*.lua' }
|
||||
shared_scripts { 'config.lua', }
|
||||
shared_scripts { 'config.lua', 'shared/*.lua' }
|
||||
@@ -1,9 +1,21 @@
|
||||
local QBCore = exports['qb-core']:GetCoreObject()
|
||||
|
||||
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)
|
||||
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
|
||||
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:toggleItem', function(give, item, amount)
|
||||
local src = source
|
||||
if give == 0 or give == false then
|
||||
if QBCore.Functions.GetPlayer(src).Functions.RemoveItem(item, amount or 1) then
|
||||
TriggerClientEvent('inventory:client:ItemBox', src, QBCore.Shared.Items[item], "remove", amount or 1)
|
||||
end
|
||||
else
|
||||
if QBCore.Functions.GetPlayer(src).Functions.AddItem(item, amount or 1) then
|
||||
TriggerClientEvent('inventory:client:ItemBox', src, QBCore.Shared.Items[item], "add", amount or 1)
|
||||
end
|
||||
end
|
||||
end)
|
||||
end)
|
||||
228
shared/shared.lua
Normal file
228
shared/shared.lua
Normal file
@@ -0,0 +1,228 @@
|
||||
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 = 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, data.coords.x, data.coords.y, data.coords.z-1.03, synced or false, synced or false, 0)
|
||||
SetEntityHeading(prop, data.coords.w+180.0)
|
||||
FreezeEntityPosition(prop, freeze or 0)
|
||||
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 = i + 1 end return i end
|
||||
|
||||
function toggleItem(give, item, amount) TriggerServerEvent("jim-consumables:server:toggleItem", give, item, amount) end
|
||||
|
||||
--Screen Effects
|
||||
local alienEffect = false
|
||||
function AlienEffect()
|
||||
if alienEffect then return end
|
||||
alienEffect = true
|
||||
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 end
|
||||
weedEffect = true
|
||||
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 end
|
||||
if Config.Debug then print("^5Debug^7: ^3TrevorEffect^7() ^2activated") end
|
||||
trevorEffect = true
|
||||
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 end
|
||||
if Config.Debug then print("^5Debug^7: ^3TurboEffect^7() ^2activated") end
|
||||
turboEffect = true
|
||||
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 end
|
||||
if Config.Debug then print("^5Debug^7: ^3RampageEffect^7() ^2activated") end
|
||||
rampageEffect = true
|
||||
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 end
|
||||
if Config.Debug then print("^5Debug^7: ^3FocusEffect^7() ^2activated") end
|
||||
focusEffect = true
|
||||
AnimpostfxPlay('FocusIn', 0, true)
|
||||
Wait(30000)
|
||||
Wait(1000)
|
||||
AnimpostfxStop('FocusIn')
|
||||
focusEffect = false
|
||||
if Config.Debug then print("^5Debug^7: ^3FocusEffect^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 = 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 = 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()
|
||||
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)
|
||||
AnimpostfxStop("DrugsMichaelAliensFightIn")
|
||||
AnimpostfxStop("DrugsMichaelAliensFight")
|
||||
AnimpostfxStop("DrugsMichaelAliensFightOut")
|
||||
AnimpostfxStop("DrugsTrevorClownsFight")
|
||||
AnimpostfxStop("DrugsTrevorClownsFightIn")
|
||||
AnimpostfxStop("DrugsTrevorClownsFightOut")
|
||||
AnimpostfxStop('RaceTurbo')
|
||||
AnimpostfxStop('FocusIn')
|
||||
AnimpostfxStop('Rampage')
|
||||
end
|
||||
Reference in New Issue
Block a user