mirror of
https://github.com/jimathy/jim_bridge.git
synced 2026-08-17 05:56:02 +01:00
Compare commits
8 Commits
c040390d1f
...
v2.1.06
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
2404fff002 | ||
|
|
03ca409bf3 | ||
|
|
9a78b057dd | ||
|
|
45f390c177 | ||
|
|
803c612cbb | ||
|
|
63bcb86ac1 | ||
|
|
0bc3c0f9b4 | ||
|
|
672dd7684b |
@@ -1,6 +1,6 @@
|
|||||||
name "Jim_Bridge"
|
name "Jim_Bridge"
|
||||||
author "Jimathy"
|
author "Jimathy"
|
||||||
version "2.1.05"
|
version "2.1.06"
|
||||||
description "Framework Bridge By Jimathy"
|
description "Framework Bridge By Jimathy"
|
||||||
fx_version "cerulean"
|
fx_version "cerulean"
|
||||||
rdr3_warning 'I acknowledge that this is a prerelease build of RedM, and I am aware my resources *will* become incompatible once RedM ships.'
|
rdr3_warning 'I acknowledge that this is a prerelease build of RedM, and I am aware my resources *will* become incompatible once RedM ships.'
|
||||||
|
|||||||
@@ -7,14 +7,22 @@ AuthEvent = nil
|
|||||||
currentToken = nil
|
currentToken = nil
|
||||||
if isServer() then
|
if isServer() then
|
||||||
|
|
||||||
|
local excludeRes = {
|
||||||
|
[Exports.QBExport] = true,
|
||||||
|
[Exports.ESXExport] = true,
|
||||||
|
[Exports.VorpExport] = true,
|
||||||
|
}
|
||||||
|
|
||||||
local AuthEvent = getScript()..":"..keyGen()..keyGen()..keyGen()..keyGen()..":"..keyGen()..keyGen()..keyGen()..keyGen()
|
local AuthEvent = getScript()..":"..keyGen()..keyGen()..keyGen()..keyGen()..":"..keyGen()..keyGen()..keyGen()..keyGen()
|
||||||
validTokens = validTokens or {}
|
validTokens = validTokens or {}
|
||||||
|
|
||||||
createCallback(AuthEvent, function(source)
|
createCallback(AuthEvent, function(source)
|
||||||
local src = source
|
local src = source
|
||||||
local token = keyGen()..keyGen()..keyGen()..keyGen() -- Use a secure random generator here
|
local token = keyGen()..keyGen()..keyGen()..keyGen() -- Use a secure random generator here
|
||||||
--debugPrint(GetInvokingResource())
|
local invokingRes = GetInvokingResource()
|
||||||
if GetInvokingResource() and GetInvokingResource() ~= getScript() and GetInvokingResource() ~= Exports.QBExport and GetInvokingResource() ~= Exports.VorpExport then
|
|
||||||
|
debugPrint(invokingRes)
|
||||||
|
if invokingRes and invokingRes ~= getScript() and not excludeRes[invokingRes] then
|
||||||
debugPrint("^1Error^7: ^1Possible exploit^7, ^1vital function was called from an external resource^7")
|
debugPrint("^1Error^7: ^1Possible exploit^7, ^1vital function was called from an external resource^7")
|
||||||
return ""
|
return ""
|
||||||
end
|
end
|
||||||
@@ -47,9 +55,9 @@ if isServer() then
|
|||||||
|
|
||||||
createCallback(getScript()..":callback:GetAuthEvent", function(source)
|
createCallback(getScript()..":callback:GetAuthEvent", function(source)
|
||||||
local src = source
|
local src = source
|
||||||
--debugPrint(GetInvokingResource())
|
local invokingRes = GetInvokingResource()
|
||||||
|
|
||||||
if GetInvokingResource() and GetInvokingResource() ~= getScript() and GetInvokingResource() ~= Exports.QBExport and GetInvokingResource() ~= Exports.VorpExport then
|
if invokingRes and invokingRes ~= getScript() and not excludeRes[invokingRes] then
|
||||||
debugPrint("^1Error^7: ^1Possible exploit^7, ^1vital callback was called from an external resource^7")
|
debugPrint("^1Error^7: ^1Possible exploit^7, ^1vital callback was called from an external resource^7")
|
||||||
return ""
|
return ""
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -7,7 +7,10 @@ function AlienEffect()
|
|||||||
Wait(math.random(5000, 8000))
|
Wait(math.random(5000, 8000))
|
||||||
local Ped = PlayerPedId()
|
local Ped = PlayerPedId()
|
||||||
local animDict = "MOVE_M@DRUNK@VERYDRUNK"
|
local animDict = "MOVE_M@DRUNK@VERYDRUNK"
|
||||||
loadAnimDict(animDict)
|
RequestAnimSet(animDict)
|
||||||
|
while not HasAnimSetLoaded(animDict) do
|
||||||
|
Wait(100)
|
||||||
|
end
|
||||||
SetPedCanRagdoll(Ped, true)
|
SetPedCanRagdoll(Ped, true)
|
||||||
ShakeGameplayCam('DRUNK_SHAKE', 2.80)
|
ShakeGameplayCam('DRUNK_SHAKE', 2.80)
|
||||||
SetTimecycleModifier("Drunk")
|
SetTimecycleModifier("Drunk")
|
||||||
|
|||||||
@@ -1304,14 +1304,26 @@ function hasItem(items, amount, src)
|
|||||||
|
|
||||||
-- Fallback to default hasItem function
|
-- Fallback to default hasItem function
|
||||||
if not hasTable or not next(hasTable) then
|
if not hasTable or not next(hasTable) then
|
||||||
for item, amt in pairs(items) do
|
if isStarted(ESXExport) then
|
||||||
local count = 0
|
for item, amt in pairs(items) do
|
||||||
for _, itemData in pairs(grabInv) do
|
local count = 0
|
||||||
if itemData and itemData.name == item then
|
for itemName, amount in pairs(grabInv) do
|
||||||
count += (itemData.amount or itemData.count or 1)
|
if itemName and itemName == item then
|
||||||
|
count += (amount or 1)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
hasTable[item] = { hasItem = count >= amt, count = count }
|
||||||
|
end
|
||||||
|
else
|
||||||
|
for item, amt in pairs(items) do
|
||||||
|
local count = 0
|
||||||
|
for _, itemData in pairs(grabInv) do
|
||||||
|
if itemData and itemData.name == item then
|
||||||
|
count += (itemData.amount or itemData.count or 1)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
hasTable[item] = { hasItem = count >= amt, count = count }
|
||||||
end
|
end
|
||||||
hasTable[item] = { hasItem = count >= amt, count = count }
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -1338,10 +1350,12 @@ end
|
|||||||
--- ```
|
--- ```
|
||||||
function getPlayerInv(src)
|
function getPlayerInv(src)
|
||||||
local grabInv = nil
|
local grabInv = nil
|
||||||
|
local foundInv = ""
|
||||||
|
|
||||||
for i = 1, #InvFunc do
|
for i = 1, #InvFunc do
|
||||||
local inv = InvFunc[i]
|
local inv = InvFunc[i]
|
||||||
if isStarted(inv.invName) then
|
if isStarted(inv.invName) then
|
||||||
|
foundInv = inv.invName
|
||||||
grabInv = inv.getPlayerInv(src)
|
grabInv = inv.getPlayerInv(src)
|
||||||
break
|
break
|
||||||
end
|
end
|
||||||
@@ -1360,10 +1374,10 @@ function getPlayerInv(src)
|
|||||||
local xPlayer = ESX.GetPlayerFromId(src)
|
local xPlayer = ESX.GetPlayerFromId(src)
|
||||||
grabInv = xPlayer and xPlayer.getInventory() or {}
|
grabInv = xPlayer and xPlayer.getInventory() or {}
|
||||||
else
|
else
|
||||||
local xPlayer = ESX.GetPlayerData()
|
grabInv = triggerCallback(getScript()..":GetESXInv")
|
||||||
grabInv = xPlayer and xPlayer.inventory or {}
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
--jsonPrint(grabInv)
|
||||||
end
|
end
|
||||||
|
|
||||||
if grabInv == nil then
|
if grabInv == nil then
|
||||||
@@ -1372,6 +1386,15 @@ function getPlayerInv(src)
|
|||||||
return grabInv, foundInv
|
return grabInv, foundInv
|
||||||
end
|
end
|
||||||
|
|
||||||
|
if isServer() then
|
||||||
|
createCallback(getScript()..":GetESXInv", function(source)
|
||||||
|
local src = source
|
||||||
|
local xPlayer = ESX.GetPlayerFromId(src)
|
||||||
|
local inv = xPlayer.getInventory()
|
||||||
|
return xPlayer.getInventory(src)
|
||||||
|
end)
|
||||||
|
end
|
||||||
|
|
||||||
function isInventoryOpen()
|
function isInventoryOpen()
|
||||||
|
|
||||||
return IsNuiFocused()
|
return IsNuiFocused()
|
||||||
@@ -1556,14 +1579,21 @@ end
|
|||||||
|
|
||||||
|
|
||||||
RegisterNetEvent(getScript()..":server:toggleItem", function(give, item, amount, newsrc, info, slot, token)
|
RegisterNetEvent(getScript()..":server:toggleItem", function(give, item, amount, newsrc, info, slot, token)
|
||||||
|
local excludeRes = {
|
||||||
|
[QBExport] = true,
|
||||||
|
[ESXExport] = true,
|
||||||
|
[VorpExport] = true,
|
||||||
|
}
|
||||||
|
local invokingRes = GetInvokingResource()
|
||||||
|
|
||||||
--debugPrint(GetInvokingResource())
|
--debugPrint(GetInvokingResource())
|
||||||
if GetInvokingResource() and GetInvokingResource() ~= getScript() and GetInvokingResource() ~= "qb-core" then
|
if invokingRes and invokingRes ~= getScript() and not excludeRes[invokingRes] then
|
||||||
debugPrint("^1Error^7: ^1Possible exploit^7, ^1vital function was called from an external resource^7")
|
debugPrint("^1Error^7: ^1Possible exploit^7, ^1vital function was called from an external resource^7")
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
if not Items[item] then
|
if not doesItemExist(item) then
|
||||||
print("^6Bridge^7: ^1Error^7 - ^2Tried to "..(tostring(give) == "true" and "add" or "remove").." '^3"..item.."^7' but it doesn't exist")
|
print("^1Error^7 - ^2Tried to "..(tostring(give) == "true" and "add" or "remove").." '^3"..item.."^7' but it doesn't exist")
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -1957,8 +1987,14 @@ function getCurrentInvWeight(src)
|
|||||||
-- fallback function
|
-- fallback function
|
||||||
if weight == 0 then
|
if weight == 0 then
|
||||||
local itemcheck = getPlayerInv(src)
|
local itemcheck = getPlayerInv(src)
|
||||||
for _, v in pairs(itemcheck) do
|
if isStarted(ESXExport) then
|
||||||
weight += ((v.weight * v.amount) or 0)
|
for _, amount in pairs(itemcheck) do
|
||||||
|
weight += (amount or 0)
|
||||||
|
end
|
||||||
|
else
|
||||||
|
for _, v in pairs(itemcheck) do
|
||||||
|
weight += ((v.weight * (v.amount or v.count)) or 0)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
return weight
|
return weight
|
||||||
@@ -2356,6 +2392,8 @@ function stashRemoveItem(stashItems, stashName, items)
|
|||||||
return
|
return
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
-- Fallback to core functions
|
||||||
if isStarted(QBExport) then
|
if isStarted(QBExport) then
|
||||||
local stashItems = getStash(stashName[1])
|
local stashItems = getStash(stashName[1])
|
||||||
for k, v in pairs(items) do
|
for k, v in pairs(items) do
|
||||||
@@ -2382,6 +2420,10 @@ function stashRemoveItem(stashItems, stashName, items)
|
|||||||
end
|
end
|
||||||
RegisterNetEvent(getScript()..":server:stashRemoveItem", stashRemoveItem)
|
RegisterNetEvent(getScript()..":server:stashRemoveItem", stashRemoveItem)
|
||||||
|
|
||||||
|
function stashAddItem(stashItems, stashName, items)
|
||||||
|
-- wip
|
||||||
|
end
|
||||||
|
|
||||||
-------------------------------------------------------------
|
-------------------------------------------------------------
|
||||||
-- Stash Item Availability Check
|
-- Stash Item Availability Check
|
||||||
-------------------------------------------------------------
|
-------------------------------------------------------------
|
||||||
|
|||||||
@@ -32,7 +32,7 @@ local hungerThirstFunc = {
|
|||||||
setStress =
|
setStress =
|
||||||
function(src, stress)
|
function(src, stress)
|
||||||
local Player = Core.Functions.GetPlayer(src)
|
local Player = Core.Functions.GetPlayer(src)
|
||||||
local newStress = Player.PlayerData.metadata.stress + stress
|
local newStress = Player.PlayerData.metadata.stress - stress
|
||||||
newStress = (newStress >= 100.0 and 100.0)or (newStress <= 0 and 0) or newStress
|
newStress = (newStress >= 100.0 and 100.0)or (newStress <= 0 and 0) or newStress
|
||||||
Player.Functions.SetMetaData('stress', newStress)
|
Player.Functions.SetMetaData('stress', newStress)
|
||||||
TriggerClientEvent('hud:client:UpdateStress', src, newStress)
|
TriggerClientEvent('hud:client:UpdateStress', src, newStress)
|
||||||
@@ -59,7 +59,7 @@ local hungerThirstFunc = {
|
|||||||
setStress =
|
setStress =
|
||||||
function(src, stress)
|
function(src, stress)
|
||||||
local Player = Core.Functions.GetPlayer(src)
|
local Player = Core.Functions.GetPlayer(src)
|
||||||
local newStress = Player.PlayerData.metadata.stress + stress
|
local newStress = Player.PlayerData.metadata.stress - stress
|
||||||
newStress = (newStress >= 100.0 and 100.0)or (newStress <= 0 and 0) or newStress
|
newStress = (newStress >= 100.0 and 100.0)or (newStress <= 0 and 0) or newStress
|
||||||
Player.Functions.SetMetaData('stress', newStress)
|
Player.Functions.SetMetaData('stress', newStress)
|
||||||
TriggerClientEvent('hud:client:UpdateStress', src, newStress)
|
TriggerClientEvent('hud:client:UpdateStress', src, newStress)
|
||||||
@@ -86,7 +86,7 @@ local hungerThirstFunc = {
|
|||||||
setStress =
|
setStress =
|
||||||
function(src, stress)
|
function(src, stress)
|
||||||
local Player = Core.Functions.GetPlayer(src)
|
local Player = Core.Functions.GetPlayer(src)
|
||||||
local newStress = Player.PlayerData.metadata.stress + stress
|
local newStress = Player.PlayerData.metadata.stress - stress
|
||||||
newStress = (newStress >= 100.0 and 100.0) or (newStress <= 0 and 0) or newStress
|
newStress = (newStress >= 100.0 and 100.0) or (newStress <= 0 and 0) or newStress
|
||||||
Player.Functions.SetMetaData('stress', newStress)
|
Player.Functions.SetMetaData('stress', newStress)
|
||||||
TriggerClientEvent('hud:client:UpdateStress', src, newStress)
|
TriggerClientEvent('hud:client:UpdateStress', src, newStress)
|
||||||
@@ -187,10 +187,10 @@ end)
|
|||||||
--- Server event handler for setting player needs (thirst or hunger).
|
--- Server event handler for setting player needs (thirst or hunger).
|
||||||
---
|
---
|
||||||
--- @event
|
--- @event
|
||||||
--- @param type string "thirst" or "hunger".
|
--- @param needType string "thirst" or "hunger".
|
||||||
--- @param amount number New value to set.
|
--- @param amount number New value to set.
|
||||||
RegisterNetEvent(getScript()..":server:setNeed", function(needType, amount)
|
RegisterNetEvent(getScript()..":server:setNeed", function(needType, amount)
|
||||||
print("^1Deprecated function ':server:setNeed' called, please update your scripts^7")
|
print("^1Deprecated function ':server:setNeed' called, please update the scripts that use it^7")
|
||||||
-- local src = source
|
-- local src = source
|
||||||
-- if needType == "thirst" then
|
-- if needType == "thirst" then
|
||||||
-- setThirst(src, amount)
|
-- setThirst(src, amount)
|
||||||
|
|||||||
289
ui_modules/alcohol.lua
Normal file
289
ui_modules/alcohol.lua
Normal file
@@ -0,0 +1,289 @@
|
|||||||
|
local alcoholCount = 0
|
||||||
|
local drugCount = 0
|
||||||
|
local purgeTimer = 300000
|
||||||
|
|
||||||
|
local minDrugCount = 3
|
||||||
|
local maxDrugCount = 7
|
||||||
|
|
||||||
|
local minAlcoholCount = 2
|
||||||
|
local midAlcoholCount = 4
|
||||||
|
local maxAlcoholCount = 7
|
||||||
|
|
||||||
|
local alcoholEffectData = {
|
||||||
|
levels = {
|
||||||
|
["min"] = {
|
||||||
|
effect = "DrugsMichaelAliensFightIn",
|
||||||
|
movement = "move_m@drunk@slightlydrunk",
|
||||||
|
camShake = 0.5,
|
||||||
|
canStumble = false,
|
||||||
|
},
|
||||||
|
["mid"] = {
|
||||||
|
effect = "DrugsMichaelAliensFightIn",
|
||||||
|
movement = "move_m@drunk@moderatedrunk",
|
||||||
|
canRagdoll = true,
|
||||||
|
camShake = 0.5,
|
||||||
|
canStumble = true,
|
||||||
|
stumbleChance = 0.8,
|
||||||
|
drunkDriving = true,
|
||||||
|
},
|
||||||
|
["max"] = {
|
||||||
|
effect = "DrugsMichaelAliensFightIn",
|
||||||
|
movement = "move_m@drunk@verydrunk",
|
||||||
|
canRagdoll = true,
|
||||||
|
camShake = 2.8,
|
||||||
|
canStumble = true,
|
||||||
|
stumbleChance = 0.6,
|
||||||
|
drunkDriving = true,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
local drugEffectData = {
|
||||||
|
levels = {
|
||||||
|
["min"] = {
|
||||||
|
--effect = "SwitchHUDTrevorIn",
|
||||||
|
--movement = "move_m@drunk@slightlydrunk",
|
||||||
|
},
|
||||||
|
["max"] = {
|
||||||
|
effect = "SwitchHUDTrevorIn",
|
||||||
|
movement = "move_m@drunk@slightlydrunk",
|
||||||
|
camShake = 0.2,
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
-- Alcohol Thread
|
||||||
|
function addAlocholCount(count, canOD)
|
||||||
|
alcoholCount = alcoholCount + count
|
||||||
|
--print("Alcohol count increased, current amount:", alcoholCount)
|
||||||
|
CreateThread(function()
|
||||||
|
runAlcoholThread()
|
||||||
|
end)
|
||||||
|
if alcoholCount >= maxAlcoholCount then
|
||||||
|
-- max
|
||||||
|
startAlcoholEffect(alcoholEffectData.levels["max"], "max")
|
||||||
|
if canOD then
|
||||||
|
SetEntityHealth(PlayerPedId(), GetEntityHealth(PlayerPedId()) - math.random(10, 15))
|
||||||
|
end
|
||||||
|
elseif alcoholCount < maxAlcoholCount and alcoholCount >= midAlcoholCount then
|
||||||
|
-- mid
|
||||||
|
startAlcoholEffect(alcoholEffectData.levels["mid"], "mid")
|
||||||
|
TriggerEvent("evidence:client:SetStatus", "heavyalcohol", 200)
|
||||||
|
if canOD then
|
||||||
|
SetEntityHealth(PlayerPedId(), GetEntityHealth(PlayerPedId()) - math.random(5, 10))
|
||||||
|
end
|
||||||
|
elseif alcoholCount >= 1 then
|
||||||
|
-- min
|
||||||
|
TriggerEvent("evidence:client:SetStatus", "alcohol", 200)
|
||||||
|
startAlcoholEffect(alcoholEffectData.levels["min"], "min")
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
function getAlcoholCount()
|
||||||
|
return alcoholCount
|
||||||
|
end
|
||||||
|
|
||||||
|
function removeAlcoholCount(count)
|
||||||
|
alcoholCount = alcoholCount - count
|
||||||
|
if alcoholCount < minAlcoholCount then
|
||||||
|
clearCurrentAlcoholEffect()
|
||||||
|
end
|
||||||
|
--print("Alcohol count decreased, current amount:", alcoholCount)
|
||||||
|
end
|
||||||
|
|
||||||
|
local alcoholThreadRun = false
|
||||||
|
function runAlcoholThread()
|
||||||
|
if alcoholThreadRun == true then
|
||||||
|
return
|
||||||
|
else
|
||||||
|
alcoholThreadRun = true
|
||||||
|
end
|
||||||
|
--print("Alcohol Thread triggered")
|
||||||
|
while alcoholCount > 0 do
|
||||||
|
Wait(purgeTimer)
|
||||||
|
removeAlcoholCount(1)
|
||||||
|
if alcoholCount <= 0 then
|
||||||
|
clearCurrentAlcoholEffect()
|
||||||
|
alcoholThreadRun = false
|
||||||
|
break
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
exports("getAlcoholCount",getAlcoholCount)
|
||||||
|
exports("addAlocholCount", addAlocholCount)
|
||||||
|
exports("removeAlcoholCount", removeAlcoholCount)
|
||||||
|
|
||||||
|
|
||||||
|
-- EFFECT Management
|
||||||
|
|
||||||
|
local currentAlcoholEffect = ""
|
||||||
|
local alcoholEffect = ""
|
||||||
|
|
||||||
|
function clearCurrentAlcoholEffect()
|
||||||
|
local Ped = PlayerPedId()
|
||||||
|
if alcoholEffect ~= "" then
|
||||||
|
AnimpostfxStop(alcoholEffect)
|
||||||
|
ResetPedMovementClipset(Ped, 0.0)
|
||||||
|
ClearTimecycleModifier()
|
||||||
|
ResetScenarioTypesEnabled()
|
||||||
|
SetPedIsDrunk(Ped, false)
|
||||||
|
SetPedMotionBlur(Ped, false)
|
||||||
|
end
|
||||||
|
currentAlcoholEffect = ""
|
||||||
|
alcoholEffect = ""
|
||||||
|
end
|
||||||
|
|
||||||
|
function startAlcoholEffect(data, level)
|
||||||
|
local Ped = PlayerPedId()
|
||||||
|
if currentAlcoholEffect == level then
|
||||||
|
return
|
||||||
|
else
|
||||||
|
clearCurrentAlcoholEffect()
|
||||||
|
currentAlcoholEffect = level
|
||||||
|
end
|
||||||
|
|
||||||
|
-- Start effect using sent data
|
||||||
|
if alcoholEffect ~= data.effect then
|
||||||
|
alcoholEffect = data.effect
|
||||||
|
AnimpostfxPlay(data.effect, 0, true)
|
||||||
|
if data.movement then
|
||||||
|
RequestAnimSet(data.movement)
|
||||||
|
while not HasAnimSetLoaded(data.movement) do
|
||||||
|
Wait(100)
|
||||||
|
end
|
||||||
|
SetPedMovementClipset(Ped, data.movement, 3.0)
|
||||||
|
end
|
||||||
|
SetPedCanRagdoll(Ped, true)
|
||||||
|
if data.camShake then
|
||||||
|
ShakeGameplayCam("DRUNK_SHAKE", data.camShake)
|
||||||
|
end
|
||||||
|
SetTimecycleModifier("Drunk")
|
||||||
|
SetPedMotionBlur(Ped, true)
|
||||||
|
SetPedIsDrunk(Ped, true)
|
||||||
|
|
||||||
|
if data.drivingEffect or data.canStumble then
|
||||||
|
|
||||||
|
CreateThread(function()
|
||||||
|
local effectCheck = level
|
||||||
|
local lastStumbleTime = GetGameTimer() + 1200
|
||||||
|
local lastDriveTime = GetGameTimer() + 6000
|
||||||
|
while effectCheck == currentAlcoholEffect do
|
||||||
|
if data.camStumble and GetGameTimer() > lastStumbleTime and math.random() > (data.stumbleChance or 0.8) then
|
||||||
|
lastStumbleTime = GetGameTimer() + 1200
|
||||||
|
SetPedToRagdoll(Ped, 5000, 5000, 0, true, true, false)
|
||||||
|
end
|
||||||
|
if data.driving and GetGameTimer() > lastDriveTime then
|
||||||
|
local inVeh, veh, seat = GetSeatPedIsIn()
|
||||||
|
if inVeh then
|
||||||
|
lastDriveTime = GetGameTimer() + 6000
|
||||||
|
if seat == -1 then
|
||||||
|
if math.random() < 0.62 then
|
||||||
|
StartVehicleHorn(veh, 1000, "NORMAL", false)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
Wait(1000)
|
||||||
|
end
|
||||||
|
--print("Effect loop broken")
|
||||||
|
end)
|
||||||
|
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
-- Helper
|
||||||
|
function GetSeatPedIsIn()
|
||||||
|
local inVeh, veh, seat = false, 0, 0
|
||||||
|
local veh = GetVehiclePedIsIn(PlayerPedId(), false)
|
||||||
|
if veh ~= 0 then
|
||||||
|
if GetPedInVehicleSeat(veh, -1) == PlayerPedId() then
|
||||||
|
inVeh = true
|
||||||
|
seat = -1
|
||||||
|
end
|
||||||
|
end
|
||||||
|
return inVeh, veh, seat
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
-- Drug thread
|
||||||
|
function addDrugCount(count, canOD)
|
||||||
|
drugCount = drugCount + count
|
||||||
|
--print("Drug count increased, current amount:", drugCount)
|
||||||
|
if drugCount >= minDrugCount and drugCount <= maxDrugCount then
|
||||||
|
startDrugEffect(drugEffectData.levels["min"], "min")
|
||||||
|
elseif drugCount > maxDrugCount then
|
||||||
|
if canOD then
|
||||||
|
SetEntityHealth(PlayerPedId(), GetEntityHealth(PlayerPedId()) - math.random(10, 15))
|
||||||
|
end
|
||||||
|
startDrugEffect(drugEffectData.levels["max"], "max")
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
function getDrugCount()
|
||||||
|
return drugCount
|
||||||
|
end
|
||||||
|
|
||||||
|
function removeDrugCount(count)
|
||||||
|
--print("Drug count decreased, current amount:", drugCount)
|
||||||
|
drugCount = drugCount - count
|
||||||
|
end
|
||||||
|
|
||||||
|
local drugThreadRun = false
|
||||||
|
function runDrugThread()
|
||||||
|
if drugThreadRun == true then
|
||||||
|
return
|
||||||
|
else
|
||||||
|
drugThreadRun = true
|
||||||
|
end
|
||||||
|
--print("Drug Thread triggered")
|
||||||
|
while drugCount > 0 do
|
||||||
|
Wait(purgeTimer)
|
||||||
|
removeDrugCount(1)
|
||||||
|
if drugCount <= 0 then
|
||||||
|
drugThreadRun = false
|
||||||
|
break
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
exports("getDrugCount", getDrugCount)
|
||||||
|
exports("addDrugCount", addDrugCount)
|
||||||
|
exports("removeDrugCount", removeDrugCount)
|
||||||
|
|
||||||
|
|
||||||
|
-- EFFECT Management
|
||||||
|
|
||||||
|
local currentDrugEffect = ""
|
||||||
|
local drugEffect = ""
|
||||||
|
function startDrugEffect(data, level)
|
||||||
|
local Ped = PlayerPedId()
|
||||||
|
if currentDrugEffect == level then
|
||||||
|
return
|
||||||
|
else
|
||||||
|
clearCurrentAlcoholEffect()
|
||||||
|
currentDrugEffect = level
|
||||||
|
end
|
||||||
|
|
||||||
|
-- Start effect using sent data
|
||||||
|
if drugEffect ~= data.effect then
|
||||||
|
drugEffect = data.effect
|
||||||
|
AnimpostfxPlay(data.effect, 0, true)
|
||||||
|
if data.movement then
|
||||||
|
RequestAnimSet(data.movement)
|
||||||
|
while not HasAnimSetLoaded(data.movement) do
|
||||||
|
Wait(100)
|
||||||
|
end
|
||||||
|
SetPedMovementClipset(Ped, data.movement, 3.0)
|
||||||
|
end
|
||||||
|
SetPedCanRagdoll(Ped, true)
|
||||||
|
if data.camShake then
|
||||||
|
ShakeGameplayCam("DRUNK_SHAKE", data.camShake)
|
||||||
|
end
|
||||||
|
SetTimecycleModifier("Drunk")
|
||||||
|
SetPedMotionBlur(Ped, true)
|
||||||
|
SetPedIsDrunk(Ped, true)
|
||||||
|
end
|
||||||
|
end
|
||||||
@@ -1,7 +1,8 @@
|
|||||||
2.1.05
|
2.1.06
|
||||||
|
|
||||||
- Fix "true/false" print from built-in gta progressbars
|
- Fix stress calculations adding instead of taking away
|
||||||
- Revert Crafting system to previous style (I was too quick to do this)
|
- Add basic support for fallback functions for inventory management (esx isn't very well supported currently)
|
||||||
- Fix singleprogress multiplying crafting recipes
|
- Create ui_modules/alcohol.lua to handle alcohol and drug effects between scripts
|
||||||
|
- Fix AnimSet loading for "AlienEffect()"
|
||||||
|
|
||||||
https://github.com/jimathy/jim_bridge/releases/latest
|
https://github.com/jimathy/jim_bridge/releases/latest
|
||||||
Reference in New Issue
Block a user