mirror of
https://github.com/jimathy/jim-consumables.git
synced 2026-08-17 14:36:03 +01:00
Compare commits
6 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
ce137d9089 | ||
|
|
d7a8a20491 | ||
|
|
38d0b04e71 | ||
|
|
762240b500 | ||
|
|
0a0f60468a | ||
|
|
9b189d89f5 |
@@ -63,7 +63,7 @@ RegisterNetEvent(getScript()..':Consume', function(itemName)
|
||||
|
||||
if requiredItem 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
|
||||
else
|
||||
-- if requiredItem == "lighter" then breakTool({ item = "lighter", damage = math.random(0, 1) }) end
|
||||
@@ -137,14 +137,15 @@ RegisterNetEvent(getScript()..':Consume', function(itemName)
|
||||
local canRun = consumable.canRun
|
||||
local stats = consumable.stats
|
||||
|
||||
local time, stress, heal, armor, needStats = GenerateRandomValues({
|
||||
local time, heal, armor, needStats = GenerateRandomValues({
|
||||
time = consumable.time or { 5000, 6000 },
|
||||
stress = consumable.stress or 0,
|
||||
heal = consumable.heal or 0,
|
||||
armor = consumable.armor or 0,
|
||||
hunger = consumable.stats and consumable.stats.hunger or 0,
|
||||
thirst = consumable.stats and consumable.stats.thirst or 0,
|
||||
stress = consumable.stress or 0,
|
||||
})
|
||||
|
||||
if emote.AnimationOptions.Prop then
|
||||
model = emote.AnimationOptions.Prop
|
||||
bone = GetPedBoneIndex(Player, emote.AnimationOptions.PropBone)
|
||||
@@ -209,7 +210,7 @@ RegisterNetEvent(getScript()..':Consume', function(itemName)
|
||||
CreateThread(function()
|
||||
if progressBar({
|
||||
time = time,
|
||||
label = string..Items[itemName].label.."..",
|
||||
label = string..getItemLabel(itemName).."..",
|
||||
dead = false,
|
||||
disableMovement = false,
|
||||
disableCombat = true,
|
||||
@@ -221,7 +222,7 @@ RegisterNetEvent(getScript()..':Consume', function(itemName)
|
||||
end
|
||||
end)
|
||||
else
|
||||
triggerNotify(nil, string..Items[itemName].label.."..", "success")
|
||||
triggerNotify(nil, string..getItemLabel(itemName).."..", "success")
|
||||
end
|
||||
|
||||
consuming = true
|
||||
@@ -263,7 +264,7 @@ RegisterNetEvent(getScript()..':Consume', function(itemName)
|
||||
"Type: "..(type or ""),
|
||||
"Hunger: "..(needStats.hunger or 0).."%",
|
||||
"Thirst: "..(needStats.thirst or 0).."%",
|
||||
"Stress: "..(stress or 0).."%",
|
||||
"Stress: "..(needStats.stress or 0).."%",
|
||||
"Heal: "..(heal or 0).."%",
|
||||
"Armour: "..(armor or 0).."%",
|
||||
}, nil, nil)
|
||||
@@ -294,25 +295,9 @@ RegisterNetEvent(getScript()..':Consume', function(itemName)
|
||||
|
||||
if not cancelled then
|
||||
hideText()
|
||||
local needTypes = { }
|
||||
|
||||
if needStats then
|
||||
TriggerServerEvent(getScript()..":server:finishConsume", needStats)
|
||||
|
||||
--jsonPrint(needStats)
|
||||
if needStats.hunger > 0 then
|
||||
needTypes.hunger = needTypes.hunger > 100 and 100 or needTypes.hunger
|
||||
end
|
||||
|
||||
if needStats.thirst > 0 then
|
||||
needTypes.thirst = needTypes.thirst > 100 and 100 or needTypes.thirst
|
||||
end
|
||||
end
|
||||
TriggerServerEvent(getScript()..":server:finishConsume", needTypes)
|
||||
|
||||
if stress and stress ~= 0 then
|
||||
debugPrint("^5Debug^7: ^3Consume^7: ^2Relieving ^6"..stress.." ^2stress^7.")
|
||||
needTypes.stress = stress
|
||||
end
|
||||
if heal and heal ~= 0 then
|
||||
debugPrint("^5Debug^7: ^3Consume^7: ^2Healing player by^7: ^6"..heal)
|
||||
SetEntityHealth(Player, GetEntityHealth(Player) + heal)
|
||||
@@ -322,15 +307,41 @@ RegisterNetEvent(getScript()..':Consume', function(itemName)
|
||||
TriggerServerEvent('hospital:server:SetArmor', (GetPedArmour(Player) + armor)) SetPedArmour(Player, (GetPedArmour(Player) + armor))
|
||||
end
|
||||
if type == "alcohol" then
|
||||
alcoholCount += 1
|
||||
debugPrint("^5Debug^7: ^3Consume^7: ^2Current ^4alcoholCount^7: ^6"..alcoholCount)
|
||||
if alcoholCount > 1 and alcoholCount < 4 then
|
||||
TriggerEvent("evidence:client:SetStatus", "alcohol", 200)
|
||||
elseif alcoholCount >= 4 then
|
||||
TriggerEvent("evidence:client:SetStatus", "heavyalcohol", 200)
|
||||
CreateThread(function()
|
||||
AlienEffect()
|
||||
end) -- Used as overdosing/too drunk effect
|
||||
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)
|
||||
if alcoholCount > 1 and alcoholCount <= 4 then
|
||||
TriggerEvent("evidence:client:SetStatus", "alcohol", 200)
|
||||
elseif alcoholCount >= 4 then
|
||||
TriggerEvent("evidence:client:SetStatus", "heavyalcohol", 200)
|
||||
CreateThread(function()
|
||||
AlienEffect()
|
||||
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
|
||||
if stats then
|
||||
@@ -352,14 +363,8 @@ RegisterNetEvent(getScript()..':Consume', function(itemName)
|
||||
end
|
||||
end
|
||||
if stats.canOD then
|
||||
drugCount += 1
|
||||
debugPrint("^5Debug^7: ^3Consume^7: ^2Current ^4drugCount^7: ^6"..drugCount)
|
||||
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
|
||||
if drugCount >= 4 or alcoholCount >= 5 then
|
||||
SetEntityHealth(Player, GetEntityHealth(Player) - math.random(5, 10))
|
||||
end
|
||||
end
|
||||
if stats.effect then
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
name "Jim-Consumables"
|
||||
author "Jimathy"
|
||||
version "2.0.07"
|
||||
version "2.0.09"
|
||||
description "Consumables Script"
|
||||
fx_version "cerulean"
|
||||
game "gta5"
|
||||
|
||||
@@ -120,10 +120,8 @@ RegisterNetEvent(getScript()..":server:finishConsume", function(needTypes)
|
||||
removeItem(isConsuming[src].item, 1, src)
|
||||
if isConsuming[src].rewardItem then
|
||||
debugPrint("^5Debug^7: ^2Giving player ^3"..src.." ^2reward items^7")
|
||||
for i = 1, #isConsuming[src].rewardItem do
|
||||
local item = isConsuming[src].rewardItem[i]
|
||||
addItem(item.item, item.amount, nil, src)
|
||||
end
|
||||
local item = isConsuming[src].rewardItem
|
||||
addItem(item.item, item.amount, nil, src)
|
||||
end
|
||||
if isConsuming[src].returnItem then
|
||||
debugPrint("^5Debug^7: ^2Giving player ^3"..src.." ^2return item^7")
|
||||
@@ -133,11 +131,9 @@ RegisterNetEvent(getScript()..":server:finishConsume", function(needTypes)
|
||||
end
|
||||
end
|
||||
if isConsuming[src].packItem then
|
||||
for i = 1, #isConsuming[src].packItem do
|
||||
debugPrint("^5Debug^7: ^2Giving player ^3"..src.." ^2Pack items^7")
|
||||
local item = isConsuming[src].packItem[i]
|
||||
addItem(item.item, item.amount, nil, src)
|
||||
end
|
||||
local item = isConsuming[src].packItem
|
||||
addItem(item.item, item.amount, nil, src)
|
||||
end
|
||||
|
||||
-- Needs
|
||||
|
||||
@@ -15,9 +15,25 @@ function GenerateRandomValues(data)
|
||||
transData[k] = v
|
||||
end
|
||||
end
|
||||
return transData["time"],
|
||||
transData["stress"],
|
||||
transData["heal"],
|
||||
transData["armor"],
|
||||
{ hunger = transData["hunger"], thirst = transData["thirst"] }
|
||||
|
||||
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"],
|
||||
transData["heal"],
|
||||
transData["armor"],
|
||||
{
|
||||
hunger = transData["hunger"] or 0,
|
||||
thirst = transData["thirst"] or 0,
|
||||
stress = transData["stress"] or 0
|
||||
}
|
||||
end
|
||||
@@ -1,6 +1,6 @@
|
||||
2.0.07
|
||||
2.0.09
|
||||
|
||||
- Add support for multi-framework stress events (fixes ESX stress)
|
||||
- Fix double calculation of hunger and thirst
|
||||
- Fix possible issue with nil needTypes tables being sent
|
||||
- Fix packitems and return items not giving any items
|
||||
|
||||
https://github.com/jimathy/jim-consumables/releases/latest
|
||||
Reference in New Issue
Block a user