Skip to content
This repository was archived by the owner on Dec 14, 2025. It is now read-only.

Commit aeb6c56

Browse files
committed
initial
1 parent 26e1329 commit aeb6c56

42 files changed

Lines changed: 2422 additions & 0 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
const fs = require('fs')
2+
3+
const version = process.env.TGT_RELEASE_VERSION
4+
const newVersion = version.replace('v', '')
5+
6+
const manifestFile = fs.readFileSync('fxmanifest.lua', {encoding: 'utf8'})
7+
8+
const newFileContent = manifestFile.replace(/\bversion\s+(.*)$/gm, `version '${newVersion}'`)
9+
10+
fs.writeFileSync('fxmanifest.lua', newFileContent)

.github/workflows/release.yml

Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
name: Release
2+
3+
on:
4+
push:
5+
tags:
6+
- 'v*.*.*'
7+
8+
jobs:
9+
create-release:
10+
name: Build and Create Tagged Release
11+
runs-on: ubuntu-latest
12+
steps:
13+
- name: Install archive tools
14+
run: sudo apt install zip
15+
16+
- name: Checkout source code
17+
uses: actions/checkout@v2
18+
with:
19+
fetch-depth: 0
20+
ref: ${{ github.event.repository.default_branch }}
21+
22+
- name: Setup node
23+
uses: actions/setup-node@v3
24+
with:
25+
node-version: 16.x
26+
cache: 'yarn'
27+
cache-dependency-path: web
28+
29+
- name: Set env
30+
run: echo "RELEASE_VERSION=${GITHUB_REF#refs/*/}" >> $GITHUB_ENV
31+
32+
- name: Use Node.js ${{ matrix.node-version }}
33+
uses: actions/setup-node@v3
34+
with:
35+
node-version: ${{ matrix.node-version }}
36+
37+
- name: Install dependencies & Build
38+
run: yarn --frozen-lockfile && yarn build
39+
working-directory: web
40+
41+
- name: Bump manifest version
42+
run: node .github/actions/bump-manifest-version.js
43+
env:
44+
TGT_RELEASE_VERSION: ${{ github.ref_name }}
45+
46+
- name: Push manifest change
47+
uses: EndBug/add-and-commit@v8
48+
with:
49+
add: fxmanifest.lua
50+
push: true
51+
author_name: Manifest Bumper
52+
author_email: 41898282+github-actions[bot]@users.noreply.github.com
53+
message: 'chore: bump manifest version to ${{ github.ref_name }}'
54+
55+
- name: Update tag ref
56+
uses: EndBug/latest-tag@latest
57+
with:
58+
tag-name: ${{ github.ref_name }}
59+
60+
- name: Bundle files
61+
run: |
62+
mkdir -p ./temp/fivem-scenes
63+
cp ./{LICENSE,README.md,fxmanifest.lua,config.lua} ./temp/fivem-scenes
64+
cp -r ./client ./temp/fivem-scenes
65+
cp -r ./server ./temp/fivem-scenes
66+
cp -r ./stream ./temp/fivem-scenes
67+
mkdir -p ./temp/fivem-scenes/web/build
68+
cp -r ./web/build/* ./temp/fivem-scenes/web/build/
69+
cd ./temp && zip -r ../fivem-scenes.zip ./fivem-scenes
70+
71+
- name: Create Release
72+
uses: 'marvinpinto/action-automatic-releases@v1.2.1'
73+
id: auto_release
74+
with:
75+
repo_token: '${{ secrets.GITHUB_TOKEN }}'
76+
title: ${{ env.RELEASE_VERSION }}
77+
prerelease: false
78+
files: fivem-scenes.zip
79+
80+
env:
81+
CI: false
82+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

README.md

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
# fivem-scenes
2+
A standalone scene creation script
3+
4+
## Release
5+
Make sure to download the latest release from the Releases section on the right and not the source code
6+
https://github.com/SamShanks1/fivem-scenes/releases/latest/download/fivem-scenes.zip
7+
8+
## Dependencies
9+
- [ox_lib](https://github.com/overextended/ox_lib)
10+
11+
## Features
12+
* Create scene using a laser point with the command CreateScene
13+
* Custom Background & Fonts (credits to dpscenes)
14+
* Change the text, colour, font size, shadow and outline
15+
* Change the background type, colour, height, width, position and opacity
16+
* View the changes being made before placing the scene
17+
18+
## Example Usage
19+
### Interface Examples
20+
![Interface](https://i.gyazo.com/6d174db1baf1447e8c558a292d1bf1f2.png)
21+
### Video Example
22+
[![Video Example](https://i.gyazo.com/b1a47c5bcfcc831aea3478c255a94794.png)](https://streamable.com/5mqlra)
23+
24+
25+
# ToDo List
26+
* Help button on UI showing [Text Formatting](https://docs.fivem.net/docs/game-references/text-formatting)
27+
* Delete Scenes
28+
* Edit Scenes
29+
* Scene duration / save to database
30+
* Show Scene duration
31+
32+
## Credits
33+
Credit to [ItsANoBrainer's qb-scenes](https://github.com/ItsANoBrainer/qb-scenes) for a lot of the functions, lua code and inspiration.
34+
35+
Credit to [Andristum's dpscenes](https://github.com/andristum/dpscenes) for the fonts, backgrounds and some more lua code.
36+
37+
## License
38+
[GNU GPL v3](http://www.gnu.org/licenses/gpl-3.0.html)

client/client.lua

Lines changed: 157 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,157 @@
1+
local creationLaser = false
2+
local editingScene = false
3+
local scenes = {}
4+
local sceneData = {}
5+
local closestScenes = {}
6+
7+
lib.requestStreamedTextureDict("commonmenu")
8+
lib.requestStreamedTextureDict("scenes")
9+
10+
local function toggleNuiFrame(shouldShow)
11+
SetNuiFocus(shouldShow, shouldShow)
12+
SendReactMessage('setVisible', shouldShow)
13+
end
14+
15+
RegisterNUICallback('hideFrame', function(_, cb)
16+
toggleNuiFrame(false)
17+
editingScene = false
18+
cb({})
19+
end)
20+
21+
RegisterNUICallback('CreateScene', function(data, cb)
22+
toggleNuiFrame(false)
23+
editingScene = false
24+
TriggerServerEvent('fivem-scenes:server:createScene', sceneData)
25+
cb({})
26+
end)
27+
28+
RegisterNUICallback('UpdateScene', function(data, cb)
29+
data.coords = sceneData.coords
30+
sceneData = data
31+
cb({})
32+
end)
33+
34+
RegisterCommand('createScene', function()
35+
ToggleCreationLaser()
36+
end, false)
37+
38+
RegisterNetEvent('fivem-scenes:client:newScene', function(data)
39+
scenes[#scenes+1] = data
40+
end)
41+
42+
CreateThread(function()
43+
local data = lib.callback.await("fivem-scenes:server:getScenes")
44+
scenes = data
45+
end)
46+
47+
CreateThread(function()
48+
while true do
49+
closestScenes = {}
50+
for i=1, #scenes do
51+
local currentScene = scenes[i]
52+
local plyPosition = GetEntityCoords(PlayerPedId())
53+
local distance = #(plyPosition - currentScene.coords)
54+
if distance < Config.MaxPlacementDistance then
55+
closestScenes[#closestScenes+1] = currentScene
56+
end
57+
end
58+
Wait(1000)
59+
end
60+
end)
61+
62+
CreateThread(function()
63+
while true do
64+
local wait = 1000
65+
if #closestScenes > 0 then
66+
wait = 0
67+
for i=1, #closestScenes do
68+
DrawScene(closestScenes[i])
69+
end
70+
end
71+
Wait(wait)
72+
end
73+
end)
74+
75+
function ToggleCreationLaser()
76+
creationLaser = true
77+
if creationLaser then
78+
CreateThread(function()
79+
while creationLaser do
80+
local hit, coords = DrawLaser('PRESS ~g~E~w~ TO CREATE SCENE', {r = 2, g = 241, b = 181, a = 200})
81+
82+
sceneData.coords = coords
83+
if IsControlJustReleased(0, 38) then
84+
if hit then
85+
creationLaser = false
86+
EditingScene()
87+
toggleNuiFrame(true)
88+
else
89+
lib.notify({description = "Laser did not hit anything.", type = "error"})
90+
end
91+
end
92+
Wait(0)
93+
end
94+
end)
95+
end
96+
end
97+
98+
function EditingScene()
99+
editingScene = true
100+
if editingScene then
101+
CreateThread(function()
102+
while editingScene do
103+
DrawScene(sceneData)
104+
Wait(0)
105+
end
106+
end)
107+
end
108+
end
109+
110+
function DrawLaser(message, color)
111+
local hit, coords = RayCastGamePlayCamera(Config.MaxPlacementDistance)
112+
Draw2DText(message, 4, {255, 255, 255}, 0.4, 0.43, 0.888 + 0.025)
113+
114+
if hit then
115+
local position = GetEntityCoords(PlayerPedId())
116+
DrawLine(position.x, position.y, position.z, coords.x, coords.y, coords.z, color.r, color.g, color.b, color.a)
117+
DrawMarker(28, coords.x, coords.y, coords.z, 0.0, 0.0, 0.0, 0.0, 180.0, 0.0, 0.1, 0.1, 0.1, color.r, color.g, color.b, color.a, false, true, 2, nil, nil, false)
118+
end
119+
120+
return hit, coords
121+
end
122+
123+
function DrawScene(currentScene)
124+
local onScreen, screenX, screenY = GetScreenCoordFromWorldCoord(currentScene.coords.x, currentScene.coords.y, currentScene.coords.z)
125+
if onScreen then
126+
local camCoords = GetFinalRenderedCamCoord()
127+
local distance = #(currentScene.coords - camCoords)
128+
local fov = (1 / GetGameplayCamFov()) * 75
129+
local scale = (1 / distance) * (4) * fov * (currentScene.fontSize or 1)
130+
local r,g,b=rgbToHex(currentScene.colour or "#ffffff")
131+
local text = currentScene.text
132+
SetTextScale(0.0, scale)
133+
SetTextFont(currentScene.font or 0)
134+
SetTextColour(r, g, b, 255)
135+
SetTextProportional(true)
136+
SetTextWrap(0.0, 1.0)
137+
SetTextCentre(true)
138+
if currentScene.shadow then
139+
SetTextDropshadow(1, 255, 255, 255, 0)
140+
end
141+
if currentScene.outline then
142+
SetTextOutline()
143+
end
144+
BeginTextCommandGetWidth("STRING")
145+
AddTextComponentString(text ~= "" and text or "Example Text")
146+
local H = GetRenderedCharacterHeight(scale, currentScene.font)+0.0030
147+
local W = EndTextCommandGetWidth(currentScene.font)+0.005
148+
BeginTextCommandDisplayText("STRING")
149+
AddTextComponentString(text ~= "" and text or "Example Text")
150+
EndTextCommandDisplayText(screenX, screenY)
151+
152+
if currentScene.background and currentScene.background ~= "none" then
153+
local br, bg, bb = rgbToHex(currentScene.backgroundColour)
154+
DrawSprite("scenes", currentScene.background, screenX+currentScene.backgroundX*scale, screenY+currentScene.backgroundY*scale, W+currentScene.backgroundWidth*scale, H+currentScene.backgroundHeight*scale, 0, br,bg,bb, currentScene.backgroundAlpha)
155+
end
156+
end
157+
end

client/fonts.lua

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
---Credit https://github.com/andristum/dpscenes
2+
3+
Fonts = {
4+
{label = "Chalet Comprimé", value = "4", group = "Normal"},
5+
{label = "Chalet", value = "0", group = "Normal"},
6+
{label = "Sign Painter", value = "1", group = "Handwritten"},
7+
{label = "Pricedown", value = "7", group = "Misc"},
8+
}
9+
10+
local AddonFonts = {
11+
--Normal
12+
{"ArialNarrow", "Arial Narrow", "Normal"},
13+
{"Lato", "Lato", "Normal"},
14+
-- Handwritten
15+
{"Inkfree", "Inkfree", "Handwritten"},
16+
{"Kid", "Kid", "Handwritten"},
17+
{"Strawberry", "Strawberry", "Handwritten"},
18+
{"PaperDaisy", "Paper Daisy", "Handwritten"},
19+
{"ALittleSunshine", "A Little Sunshine", "Handwritten"},
20+
{"WriteMeASong", "Write Me A Song", "Handwritten"},
21+
-- Graffiti
22+
{"BeatStreet", "Beat Street", "Graffiti"},
23+
{"DirtyLizard", "Dirty Lizard", "Graffiti"},
24+
{"Maren", "Maren", "Graffiti"},
25+
-- Misc
26+
{"HappyDay", "Happy Day", "Misc"},
27+
{"ImpactLabel", "Impact Label", "Misc"},
28+
{"Easter", "Easter", "Misc"},
29+
}
30+
31+
32+
for i = 1, #AddonFonts do
33+
RegisterFontFile(AddonFonts[i][1])
34+
local Id = RegisterFontId(AddonFonts[i][2])
35+
Fonts[#Fonts+1] = {label = AddonFonts[i][2], value = tostring(Id), group = AddonFonts[i][3]}
36+
end
37+
38+
39+
RegisterNUICallback('getFonts', function(_, cb)
40+
cb(Fonts)
41+
end)

0 commit comments

Comments
 (0)