mirror of
https://github.com/jimathy/jim-consumables.git
synced 2026-08-18 23:16:03 +01:00
Compare commits
4 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
62db9f6900 | ||
|
|
6317dee667 | ||
|
|
15bb54c206 | ||
|
|
94023857ff |
71
.github/workflows/notify-release.yml
vendored
Normal file
71
.github/workflows/notify-release.yml
vendored
Normal 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 won’t 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"
|
||||||
@@ -300,32 +300,18 @@ RegisterNetEvent(getScript()..':Consume', function(itemName)
|
|||||||
|
|
||||||
--jsonPrint(needStats)
|
--jsonPrint(needStats)
|
||||||
if needStats.hunger > 0 then
|
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
|
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
|
end
|
||||||
|
|
||||||
if needStats.thirst > 0 then
|
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
|
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
|
||||||
end
|
end
|
||||||
TriggerServerEvent(getScript()..":server:finishConsume", needTypes)
|
TriggerServerEvent(getScript()..":server:finishConsume", needTypes)
|
||||||
|
|
||||||
if stress and stress ~= 0 then
|
if stress and stress ~= 0 then
|
||||||
debugPrint("^5Debug^7: ^3Consume^7: ^2Relieving ^6"..stress.." ^2stress^7.")
|
debugPrint("^5Debug^7: ^3Consume^7: ^2Relieving ^6"..stress.." ^2stress^7.")
|
||||||
TriggerServerEvent('hud:server:RelieveStress', stress)
|
needTypes.stress = stress
|
||||||
end
|
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)
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
name "Jim-Consumables"
|
name "Jim-Consumables"
|
||||||
author "Jimathy"
|
author "Jimathy"
|
||||||
version "2.0.06"
|
version "2.0.07"
|
||||||
description "Consumables Script"
|
description "Consumables Script"
|
||||||
fx_version "cerulean"
|
fx_version "cerulean"
|
||||||
game "gta5"
|
game "gta5"
|
||||||
|
|||||||
@@ -142,12 +142,17 @@ RegisterNetEvent(getScript()..":server:finishConsume", function(needTypes)
|
|||||||
|
|
||||||
-- 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
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
2.0.06
|
2.0.07
|
||||||
|
|
||||||
- Increase Secuirty to prevent potential exploits
|
- Add support for multi-framework stress events (fixes ESX stress)
|
||||||
|
- Fix double calculation of hunger and thirst
|
||||||
|
|
||||||
https://github.com/jimathy/jim-consumables
|
https://github.com/jimathy/jim-consumables/releases/latest
|
||||||
Reference in New Issue
Block a user