mirror of
https://github.com/jimathy/jim-consumables.git
synced 2026-08-16 22:16:02 +01:00
Rework calculations and fix alcohol/drug effects
This fixes calculation errors and implements support for jim_bridge built in synchronized alcohol/drug effects Separates "drug control" `canOD` variable too
This commit is contained in:
@@ -63,7 +63,7 @@ RegisterNetEvent(getScript()..':Consume', function(itemName)
|
|||||||
|
|
||||||
if requiredItem then
|
if requiredItem then
|
||||||
if not hasItem(requiredItem, 1) then
|
if not hasItem(requiredItem, 1) then
|
||||||
triggerNotify(nil, "You need a "..Items[requiredItem].label, "error")
|
triggerNotify(nil, "You need a "..getItemLabel(requiredItem), "error")
|
||||||
return
|
return
|
||||||
else
|
else
|
||||||
-- if requiredItem == "lighter" then breakTool({ item = "lighter", damage = math.random(0, 1) }) end
|
-- if requiredItem == "lighter" then breakTool({ item = "lighter", damage = math.random(0, 1) }) end
|
||||||
@@ -210,7 +210,7 @@ RegisterNetEvent(getScript()..':Consume', function(itemName)
|
|||||||
CreateThread(function()
|
CreateThread(function()
|
||||||
if progressBar({
|
if progressBar({
|
||||||
time = time,
|
time = time,
|
||||||
label = string..Items[itemName].label.."..",
|
label = string..getItemLabel(itemName).."..",
|
||||||
dead = false,
|
dead = false,
|
||||||
disableMovement = false,
|
disableMovement = false,
|
||||||
disableCombat = true,
|
disableCombat = true,
|
||||||
@@ -222,7 +222,7 @@ RegisterNetEvent(getScript()..':Consume', function(itemName)
|
|||||||
end
|
end
|
||||||
end)
|
end)
|
||||||
else
|
else
|
||||||
triggerNotify(nil, string..Items[itemName].label.."..", "success")
|
triggerNotify(nil, string..getItemLabel(itemName).."..", "success")
|
||||||
end
|
end
|
||||||
|
|
||||||
consuming = true
|
consuming = true
|
||||||
@@ -296,19 +296,6 @@ RegisterNetEvent(getScript()..':Consume', function(itemName)
|
|||||||
if not cancelled then
|
if not cancelled then
|
||||||
hideText()
|
hideText()
|
||||||
|
|
||||||
if needStats then
|
|
||||||
if needStats.hunger > 0 then
|
|
||||||
needStats.hunger = needStats.hunger > 100 and 100 or needStats.hunger
|
|
||||||
end
|
|
||||||
|
|
||||||
if needStats.thirst > 0 then
|
|
||||||
needStats.thirst = needStats.thirst > 100 and 100 or needStats.thirst
|
|
||||||
end
|
|
||||||
|
|
||||||
if needStats.stress > 0 then
|
|
||||||
needStats.stress = needStats.stress > 100 and 100 or needStats.stress
|
|
||||||
end
|
|
||||||
end
|
|
||||||
TriggerServerEvent(getScript()..":server:finishConsume", needStats)
|
TriggerServerEvent(getScript()..":server:finishConsume", needStats)
|
||||||
|
|
||||||
if heal and heal ~= 0 then
|
if heal and heal ~= 0 then
|
||||||
@@ -320,15 +307,41 @@ RegisterNetEvent(getScript()..':Consume', function(itemName)
|
|||||||
TriggerServerEvent('hospital:server:SetArmor', (GetPedArmour(Player) + armor)) SetPedArmour(Player, (GetPedArmour(Player) + armor))
|
TriggerServerEvent('hospital:server:SetArmor', (GetPedArmour(Player) + armor)) SetPedArmour(Player, (GetPedArmour(Player) + armor))
|
||||||
end
|
end
|
||||||
if type == "alcohol" then
|
if type == "alcohol" then
|
||||||
alcoholCount += 1
|
if checkExportExists("jim_bridge", "addAlcoholCount") then
|
||||||
|
exports.jim_bridge:addAlcoholCount(1, stats.canOD)
|
||||||
|
else
|
||||||
|
alcoholCount = alcoholCount + 1
|
||||||
debugPrint("^5Debug^7: ^3Consume^7: ^2Current ^4alcoholCount^7: ^6"..alcoholCount)
|
debugPrint("^5Debug^7: ^3Consume^7: ^2Current ^4alcoholCount^7: ^6"..alcoholCount)
|
||||||
if alcoholCount > 1 and alcoholCount < 4 then
|
if alcoholCount > 1 and alcoholCount <= 4 then
|
||||||
TriggerEvent("evidence:client:SetStatus", "alcohol", 200)
|
TriggerEvent("evidence:client:SetStatus", "alcohol", 200)
|
||||||
elseif alcoholCount >= 4 then
|
elseif alcoholCount >= 4 then
|
||||||
TriggerEvent("evidence:client:SetStatus", "heavyalcohol", 200)
|
TriggerEvent("evidence:client:SetStatus", "heavyalcohol", 200)
|
||||||
CreateThread(function()
|
CreateThread(function()
|
||||||
AlienEffect()
|
AlienEffect()
|
||||||
end) -- Used as overdosing/too drunk effect
|
end)
|
||||||
|
end
|
||||||
|
|
||||||
|
if stats.canOD and alcoholCount >= 5 then
|
||||||
|
SetEntityHealth(Player, GetEntityHealth(Player) - math.random(5, 10))
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
if type == "drug" then
|
||||||
|
if checkExportExists("jim_bridge", "addDrugCount") then
|
||||||
|
exports.jim_bridge:addDrugCount(1, stats.canOD or false)
|
||||||
|
else
|
||||||
|
drugCount = drugCount + 1
|
||||||
|
debugPrint("^5Debug^7: ^3Consume^7: ^2Current ^4drugCount^7: ^6"..drugCount)
|
||||||
|
if drugCount > 3 and drugCount < 7 then
|
||||||
|
|
||||||
|
elseif drugCount >= 7 then
|
||||||
|
CreateThread(function()
|
||||||
|
AlienEffect()
|
||||||
|
end)
|
||||||
|
end
|
||||||
|
if stats.canOD and drugCount >= 4 then
|
||||||
|
SetEntityHealth(Player, GetEntityHealth(Player) - math.random(5, 10))
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
if stats then
|
if stats then
|
||||||
@@ -350,14 +363,8 @@ RegisterNetEvent(getScript()..':Consume', function(itemName)
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
if stats.canOD then
|
if stats.canOD then
|
||||||
drugCount += 1
|
if drugCount >= 4 or alcoholCount >= 5 then
|
||||||
debugPrint("^5Debug^7: ^3Consume^7: ^2Current ^4drugCount^7: ^6"..drugCount)
|
SetEntityHealth(Player, GetEntityHealth(Player) - math.random(5, 10))
|
||||||
if drugCount >= 4 then
|
|
||||||
debugPrint("^5Debug^7: ^3Consume^7: ^2Current ^4drugCount^7: ^6"..drugCount.."^7 - ^2 removing health")
|
|
||||||
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
|
||||||
end
|
end
|
||||||
if stats.effect then
|
if stats.effect then
|
||||||
|
|||||||
@@ -15,8 +15,23 @@ function GenerateRandomValues(data)
|
|||||||
transData[k] = v
|
transData[k] = v
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
if transData.hunger > 0 then
|
||||||
|
transData.hunger = transData.hunger > 100 and 100 or transData.hunger
|
||||||
|
end
|
||||||
|
|
||||||
|
if transData.thirst > 0 then
|
||||||
|
transData.thirst = transData.thirst > 100 and 100 or transData.thirst
|
||||||
|
end
|
||||||
|
|
||||||
|
if transData.stress > 0 then
|
||||||
|
transData.stress = transData.stress > 100 and 100 or transData.stress
|
||||||
|
end
|
||||||
return transData["time"],
|
return transData["time"],
|
||||||
transData["heal"],
|
transData["heal"],
|
||||||
transData["armor"],
|
transData["armor"],
|
||||||
{ hunger = transData["hunger"], thirst = transData["thirst"], stress = transData["stress"] }
|
{
|
||||||
|
hunger = transData["hunger"],
|
||||||
|
thirst = transData["thirst"],
|
||||||
|
stress = transData["stress"]
|
||||||
|
}
|
||||||
end
|
end
|
||||||
Reference in New Issue
Block a user