10 Commits

Author SHA1 Message Date
Jim Shield
ce137d9089 Version Bump
`2.0.08` - `2.0.09`
2025-10-12 00:10:28 +01:00
Jim Shield
d7a8a20491 Make GenerateRandomValues() return 0
Its possible if no health, thirst or stress was set, it may sent back an empty table, which would then break the finish consume function in the server
2025-10-10 01:57:01 +01:00
Jim Shield
38d0b04e71 Fix pack and return items not being given 2025-10-06 12:56:14 +01:00
Jim Shield
762240b500 Version Bump
`2.0.07` - `2.0.08`
2025-10-06 02:29:07 +01:00
Jim Shield
0a0f60468a 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
2025-10-06 02:28:03 +01:00
Jim Shield
9b189d89f5 fix needStats calculcation
My mad on this one, got `needTypes` and `needStats` confused, so made it just one table and included stress in it
2025-10-04 01:12:19 +01:00
Jim Shield
62db9f6900 Version Bump
`2.0.06` - `2.0.07`
2025-10-01 21:44:20 +01:00
Jim Shield
6317dee667 Stop double calculation of hunger and thirst
Missed this, it's doing the player stats + new stats and then in jim_bridge doing this again and doubling it all up
2025-10-01 21:43:14 +01:00
Jim Shield
15bb54c206 Add support for jim_bridge setStress function
Allows multiframework stress events
2025-10-01 01:20:33 +01:00
Jim Shield
94023857ff Release Notifier Push 2025-09-24 18:18:14 +01:00
6 changed files with 152 additions and 72 deletions

71
.github/workflows/notify-release.yml vendored Normal file
View File

@@ -0,0 +1,71 @@
name: Discord Release Notifier
on:
# Manual or UI-published releases
release:
types: [published]
# Releases created by your tag-driven workflow
workflow_run:
workflows: ["Package & Release"] # must match the 'name:' in release.yml
types: [completed]
permissions:
contents: read
jobs:
# 1) Handle manual / UI / non-workflow-created releases
notify-from-release:
if: github.event_name == 'release' && github.event.action == 'published'
runs-on: ubuntu-latest
steps:
- name: Send release payload to Discord Bot
env:
URL: http://${{ secrets.DISCORDBOT }}:3000/github-releases
run: |
curl -sS -X POST "$URL" \
-H 'Content-Type: application/json' \
--data-binary "@$GITHUB_EVENT_PATH"
# 2) Handle releases created by your 'Package & Release' workflow
# (which wont trigger `on: release` when using GITHUB_TOKEN)
notify-from-workflow-run:
if: >
github.event_name == 'workflow_run' &&
github.event.workflow_run.conclusion == 'success'
runs-on: ubuntu-latest
steps:
- name: Install jq
run: sudo apt-get update && sudo apt-get install -y jq
- name: Fetch release JSON by tag
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
set -euo pipefail
OWNER="${GITHUB_REPOSITORY%/*}"
REPO="${GITHUB_REPOSITORY#*/}"
TAG="${{ github.event.workflow_run.head_branch }}"
# head_branch is the tag name for a tag push workflow_run
curl -fsSL -H "Authorization: Bearer $GH_TOKEN" \
-H "Accept: application/vnd.github+json" \
"https://api.github.com/repos/$OWNER/$REPO/releases/tags/$TAG" \
> release.json
- name: Wrap as 'release' event payload & notify bot
env:
URL: http://${{ secrets.DISCORDBOT }}:3000/github-releases
run: |
set -euo pipefail
jq -n --slurpfile rel release.json \
--arg repo "$GITHUB_REPOSITORY" \
--arg repo_url "https://github.com/$GITHUB_REPOSITORY" \
--arg action "published" '
{ action: $action,
repository: { full_name: $repo, html_url: $repo_url },
release: $rel[0],
sender: { login: "github-actions[bot]" } }' > payload.json
curl -sS -X POST "$URL" \
-H 'Content-Type: application/json' \
--data-binary "@payload.json"

View File

@@ -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
@@ -137,14 +137,15 @@ RegisterNetEvent(getScript()..':Consume', function(itemName)
local canRun = consumable.canRun local canRun = consumable.canRun
local stats = consumable.stats local stats = consumable.stats
local time, stress, heal, armor, needStats = GenerateRandomValues({ local time, heal, armor, needStats = GenerateRandomValues({
time = consumable.time or { 5000, 6000 }, time = consumable.time or { 5000, 6000 },
stress = consumable.stress or 0,
heal = consumable.heal or 0, heal = consumable.heal or 0,
armor = consumable.armor or 0, armor = consumable.armor or 0,
hunger = consumable.stats and consumable.stats.hunger or 0, hunger = consumable.stats and consumable.stats.hunger or 0,
thirst = consumable.stats and consumable.stats.thirst or 0, thirst = consumable.stats and consumable.stats.thirst or 0,
stress = consumable.stress or 0,
}) })
if emote.AnimationOptions.Prop then if emote.AnimationOptions.Prop then
model = emote.AnimationOptions.Prop model = emote.AnimationOptions.Prop
bone = GetPedBoneIndex(Player, emote.AnimationOptions.PropBone) bone = GetPedBoneIndex(Player, emote.AnimationOptions.PropBone)
@@ -209,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,
@@ -221,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
@@ -263,7 +264,7 @@ RegisterNetEvent(getScript()..':Consume', function(itemName)
"Type: "..(type or ""), "Type: "..(type or ""),
"Hunger: "..(needStats.hunger or 0).."%", "Hunger: "..(needStats.hunger or 0).."%",
"Thirst: "..(needStats.thirst or 0).."%", "Thirst: "..(needStats.thirst or 0).."%",
"Stress: "..(stress or 0).."%", "Stress: "..(needStats.stress or 0).."%",
"Heal: "..(heal or 0).."%", "Heal: "..(heal or 0).."%",
"Armour: "..(armor or 0).."%", "Armour: "..(armor or 0).."%",
}, nil, nil) }, nil, nil)
@@ -294,39 +295,9 @@ RegisterNetEvent(getScript()..':Consume', function(itemName)
if not cancelled then if not cancelled then
hideText() hideText()
local needTypes = { }
if needStats then TriggerServerEvent(getScript()..":server:finishConsume", needStats)
--jsonPrint(needStats)
if needStats.hunger > 0 then
if Core and Core.Functions then
needTypes.hunger = (Core.Functions.GetPlayerData().metadata["hunger"] or 0) + needStats.hunger
needTypes.hunger = needTypes.hunger > 100 and 100 or needTypes.hunger
elseif ESX and ESX.GetPlayerData then
needTypes.hunger = (needStats.hunger / 100) * 1000000
needTypes.hunger = needTypes.hunger > 1000000 and 1000000 or needTypes.hunger
end
end
if needStats.thirst > 0 then
if Core and Core.Functions then
needTypes.thirst = (Core.Functions.GetPlayerData().metadata["thirst"] or 0) + needStats.thirst
needTypes.thirst = needTypes.thirst > 100 and 100 or needTypes.thirst
elseif ESX and ESX.GetPlayerData then
needTypes.thirst = (needStats.thirst / 100) * 1000000
needTypes.thirst = needTypes.thirst > 1000000 and 1000000 or needTypes.thirst
end
end
end
TriggerServerEvent(getScript()..":server:finishConsume", needTypes)
if stress and stress ~= 0 then
debugPrint("^5Debug^7: ^3Consume^7: ^2Relieving ^6"..stress.." ^2stress^7.")
TriggerServerEvent('hud:server:RelieveStress', stress)
end
if heal and heal ~= 0 then if heal and heal ~= 0 then
debugPrint("^5Debug^7: ^3Consume^7: ^2Healing player by^7: ^6"..heal) debugPrint("^5Debug^7: ^3Consume^7: ^2Healing player by^7: ^6"..heal)
SetEntityHealth(Player, GetEntityHealth(Player) + heal) SetEntityHealth(Player, GetEntityHealth(Player) + heal)
@@ -336,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
debugPrint("^5Debug^7: ^3Consume^7: ^2Current ^4alcoholCount^7: ^6"..alcoholCount) exports.jim_bridge:addAlcoholCount(1, stats.canOD)
if alcoholCount > 1 and alcoholCount < 4 then else
TriggerEvent("evidence:client:SetStatus", "alcohol", 200) alcoholCount = alcoholCount + 1
elseif alcoholCount >= 4 then debugPrint("^5Debug^7: ^3Consume^7: ^2Current ^4alcoholCount^7: ^6"..alcoholCount)
TriggerEvent("evidence:client:SetStatus", "heavyalcohol", 200) if alcoholCount > 1 and alcoholCount <= 4 then
CreateThread(function() TriggerEvent("evidence:client:SetStatus", "alcohol", 200)
AlienEffect() elseif alcoholCount >= 4 then
end) -- Used as overdosing/too drunk effect 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
end end
if stats then if stats then
@@ -366,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

View File

@@ -1,6 +1,6 @@
name "Jim-Consumables" name "Jim-Consumables"
author "Jimathy" author "Jimathy"
version "2.0.06" version "2.0.09"
description "Consumables Script" description "Consumables Script"
fx_version "cerulean" fx_version "cerulean"
game "gta5" game "gta5"

View File

@@ -120,10 +120,8 @@ RegisterNetEvent(getScript()..":server:finishConsume", function(needTypes)
removeItem(isConsuming[src].item, 1, src) removeItem(isConsuming[src].item, 1, src)
if isConsuming[src].rewardItem then if isConsuming[src].rewardItem then
debugPrint("^5Debug^7: ^2Giving player ^3"..src.." ^2reward items^7") debugPrint("^5Debug^7: ^2Giving player ^3"..src.." ^2reward items^7")
for i = 1, #isConsuming[src].rewardItem do local item = isConsuming[src].rewardItem
local item = isConsuming[src].rewardItem[i] addItem(item.item, item.amount, nil, src)
addItem(item.item, item.amount, nil, src)
end
end end
if isConsuming[src].returnItem then if isConsuming[src].returnItem then
debugPrint("^5Debug^7: ^2Giving player ^3"..src.." ^2return item^7") debugPrint("^5Debug^7: ^2Giving player ^3"..src.." ^2return item^7")
@@ -133,21 +131,24 @@ RegisterNetEvent(getScript()..":server:finishConsume", function(needTypes)
end end
end end
if isConsuming[src].packItem then if isConsuming[src].packItem then
for i = 1, #isConsuming[src].packItem do
debugPrint("^5Debug^7: ^2Giving player ^3"..src.." ^2Pack items^7") debugPrint("^5Debug^7: ^2Giving player ^3"..src.." ^2Pack items^7")
local item = isConsuming[src].packItem[i] local item = isConsuming[src].packItem
addItem(item.item, item.amount, nil, src) addItem(item.item, item.amount, nil, src)
end
end end
-- Needs -- Needs
if needTypes.thirst then if needTypes.thirst then
debugPrint("^5Debug^7: ^2Thrist^7: [^6"..(needTypes.thirst or 0).."^7]")
setThirst(src, needTypes.thirst) setThirst(src, needTypes.thirst)
end end
if needTypes.hunger then if needTypes.hunger then
debugPrint("^5Debug^7: ^2Hunger^7: [^6"..(needTypes.hunger or 0).."^7]")
setHunger(src, needTypes.hunger) setHunger(src, needTypes.hunger)
end end
debugPrint("^5Debug^7: ^2Hunger^7: [^6"..(needTypes.hunger or 0).."^7] ^2Thrist^7: [^6"..(needTypes.thirst or 0).."^7]" ) if needTypes.stress then
debugPrint("^5Debug^7: ^2Stress^7: [^6"..(needTypes.stress or 0).."^7]")
setStress(src, needTypes.stress)
end
isConsuming[src] = nil isConsuming[src] = nil
else else
return return

View File

@@ -15,9 +15,25 @@ function GenerateRandomValues(data)
transData[k] = v transData[k] = v
end end
end end
return transData["time"],
transData["stress"], if transData.hunger > 0 then
transData["heal"], transData.hunger = transData.hunger > 100 and 100 or transData.hunger
transData["armor"], end
{ hunger = transData["hunger"], thirst = transData["thirst"] }
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 end

View File

@@ -1,5 +1,6 @@
2.0.06 2.0.09
- Increase Secuirty to prevent potential exploits - Fix possible issue with nil needTypes tables being sent
- Fix packitems and return items not giving any items
https://github.com/jimathy/jim-consumables https://github.com/jimathy/jim-consumables/releases/latest