-
Notifications
You must be signed in to change notification settings - Fork 27
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
26e1329
commit aeb6c56
Showing
42 changed files
with
2,422 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
const fs = require('fs') | ||
|
||
const version = process.env.TGT_RELEASE_VERSION | ||
const newVersion = version.replace('v', '') | ||
|
||
const manifestFile = fs.readFileSync('fxmanifest.lua', {encoding: 'utf8'}) | ||
|
||
const newFileContent = manifestFile.replace(/\bversion\s+(.*)$/gm, `version '${newVersion}'`) | ||
|
||
fs.writeFileSync('fxmanifest.lua', newFileContent) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
name: Release | ||
|
||
on: | ||
push: | ||
tags: | ||
- 'v*.*.*' | ||
|
||
jobs: | ||
create-release: | ||
name: Build and Create Tagged Release | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Install archive tools | ||
run: sudo apt install zip | ||
|
||
- name: Checkout source code | ||
uses: actions/checkout@v2 | ||
with: | ||
fetch-depth: 0 | ||
ref: ${{ github.event.repository.default_branch }} | ||
|
||
- name: Setup node | ||
uses: actions/setup-node@v3 | ||
with: | ||
node-version: 16.x | ||
cache: 'yarn' | ||
cache-dependency-path: web | ||
|
||
- name: Set env | ||
run: echo "RELEASE_VERSION=${GITHUB_REF#refs/*/}" >> $GITHUB_ENV | ||
|
||
- name: Use Node.js ${{ matrix.node-version }} | ||
uses: actions/setup-node@v3 | ||
with: | ||
node-version: ${{ matrix.node-version }} | ||
|
||
- name: Install dependencies & Build | ||
run: yarn --frozen-lockfile && yarn build | ||
working-directory: web | ||
|
||
- name: Bump manifest version | ||
run: node .github/actions/bump-manifest-version.js | ||
env: | ||
TGT_RELEASE_VERSION: ${{ github.ref_name }} | ||
|
||
- name: Push manifest change | ||
uses: EndBug/add-and-commit@v8 | ||
with: | ||
add: fxmanifest.lua | ||
push: true | ||
author_name: Manifest Bumper | ||
author_email: 41898282+github-actions[bot]@users.noreply.github.com | ||
message: 'chore: bump manifest version to ${{ github.ref_name }}' | ||
|
||
- name: Update tag ref | ||
uses: EndBug/latest-tag@latest | ||
with: | ||
tag-name: ${{ github.ref_name }} | ||
|
||
- name: Bundle files | ||
run: | | ||
mkdir -p ./temp/fivem-scenes | ||
cp ./{LICENSE,README.md,fxmanifest.lua,config.lua} ./temp/fivem-scenes | ||
cp -r ./client ./temp/fivem-scenes | ||
cp -r ./server ./temp/fivem-scenes | ||
cp -r ./stream ./temp/fivem-scenes | ||
mkdir -p ./temp/fivem-scenes/web/build | ||
cp -r ./web/build/* ./temp/fivem-scenes/web/build/ | ||
cd ./temp && zip -r ../fivem-scenes.zip ./fivem-scenes | ||
- name: Create Release | ||
uses: 'marvinpinto/[email protected]' | ||
id: auto_release | ||
with: | ||
repo_token: '${{ secrets.GITHUB_TOKEN }}' | ||
title: ${{ env.RELEASE_VERSION }} | ||
prerelease: false | ||
files: fivem-scenes.zip | ||
|
||
env: | ||
CI: false | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
# fivem-scenes | ||
A standalone scene creation script | ||
|
||
## Release | ||
Make sure to download the latest release from the Releases section on the right and not the source code | ||
https://github.com/SamShanks1/fivem-scenes/releases/latest/download/fivem-scenes.zip | ||
|
||
## Dependencies | ||
- [ox_lib](https://github.com/overextended/ox_lib) | ||
|
||
## Features | ||
* Create scene using a laser point with the command CreateScene | ||
* Custom Background & Fonts (credits to dpscenes) | ||
* Change the text, colour, font size, shadow and outline | ||
* Change the background type, colour, height, width, position and opacity | ||
* View the changes being made before placing the scene | ||
|
||
## Example Usage | ||
### Interface Examples | ||
![Interface](https://i.gyazo.com/6d174db1baf1447e8c558a292d1bf1f2.png) | ||
### Video Example | ||
[![Video Example](https://i.gyazo.com/b1a47c5bcfcc831aea3478c255a94794.png)](https://streamable.com/5mqlra) | ||
|
||
|
||
# ToDo List | ||
* Help button on UI showing [Text Formatting](https://docs.fivem.net/docs/game-references/text-formatting) | ||
* Delete Scenes | ||
* Edit Scenes | ||
* Scene duration / save to database | ||
* Show Scene duration | ||
|
||
## Credits | ||
Credit to [ItsANoBrainer's qb-scenes](https://github.com/ItsANoBrainer/qb-scenes) for a lot of the functions, lua code and inspiration. | ||
|
||
Credit to [Andristum's dpscenes](https://github.com/andristum/dpscenes) for the fonts, backgrounds and some more lua code. | ||
|
||
## License | ||
[GNU GPL v3](http://www.gnu.org/licenses/gpl-3.0.html) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,157 @@ | ||
local creationLaser = false | ||
local editingScene = false | ||
local scenes = {} | ||
local sceneData = {} | ||
local closestScenes = {} | ||
|
||
lib.requestStreamedTextureDict("commonmenu") | ||
lib.requestStreamedTextureDict("scenes") | ||
|
||
local function toggleNuiFrame(shouldShow) | ||
SetNuiFocus(shouldShow, shouldShow) | ||
SendReactMessage('setVisible', shouldShow) | ||
end | ||
|
||
RegisterNUICallback('hideFrame', function(_, cb) | ||
toggleNuiFrame(false) | ||
editingScene = false | ||
cb({}) | ||
end) | ||
|
||
RegisterNUICallback('CreateScene', function(data, cb) | ||
toggleNuiFrame(false) | ||
editingScene = false | ||
TriggerServerEvent('fivem-scenes:server:createScene', sceneData) | ||
cb({}) | ||
end) | ||
|
||
RegisterNUICallback('UpdateScene', function(data, cb) | ||
data.coords = sceneData.coords | ||
sceneData = data | ||
cb({}) | ||
end) | ||
|
||
RegisterCommand('createScene', function() | ||
ToggleCreationLaser() | ||
end, false) | ||
|
||
RegisterNetEvent('fivem-scenes:client:newScene', function(data) | ||
scenes[#scenes+1] = data | ||
end) | ||
|
||
CreateThread(function() | ||
local data = lib.callback.await("fivem-scenes:server:getScenes") | ||
scenes = data | ||
end) | ||
|
||
CreateThread(function() | ||
while true do | ||
closestScenes = {} | ||
for i=1, #scenes do | ||
local currentScene = scenes[i] | ||
local plyPosition = GetEntityCoords(PlayerPedId()) | ||
local distance = #(plyPosition - currentScene.coords) | ||
if distance < Config.MaxPlacementDistance then | ||
closestScenes[#closestScenes+1] = currentScene | ||
end | ||
end | ||
Wait(1000) | ||
end | ||
end) | ||
|
||
CreateThread(function() | ||
while true do | ||
local wait = 1000 | ||
if #closestScenes > 0 then | ||
wait = 0 | ||
for i=1, #closestScenes do | ||
DrawScene(closestScenes[i]) | ||
end | ||
end | ||
Wait(wait) | ||
end | ||
end) | ||
|
||
function ToggleCreationLaser() | ||
creationLaser = true | ||
if creationLaser then | ||
CreateThread(function() | ||
while creationLaser do | ||
local hit, coords = DrawLaser('PRESS ~g~E~w~ TO CREATE SCENE', {r = 2, g = 241, b = 181, a = 200}) | ||
|
||
sceneData.coords = coords | ||
if IsControlJustReleased(0, 38) then | ||
if hit then | ||
creationLaser = false | ||
EditingScene() | ||
toggleNuiFrame(true) | ||
else | ||
lib.notify({description = "Laser did not hit anything.", type = "error"}) | ||
end | ||
end | ||
Wait(0) | ||
end | ||
end) | ||
end | ||
end | ||
|
||
function EditingScene() | ||
editingScene = true | ||
if editingScene then | ||
CreateThread(function() | ||
while editingScene do | ||
DrawScene(sceneData) | ||
Wait(0) | ||
end | ||
end) | ||
end | ||
end | ||
|
||
function DrawLaser(message, color) | ||
local hit, coords = RayCastGamePlayCamera(Config.MaxPlacementDistance) | ||
Draw2DText(message, 4, {255, 255, 255}, 0.4, 0.43, 0.888 + 0.025) | ||
|
||
if hit then | ||
local position = GetEntityCoords(PlayerPedId()) | ||
DrawLine(position.x, position.y, position.z, coords.x, coords.y, coords.z, color.r, color.g, color.b, color.a) | ||
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) | ||
end | ||
|
||
return hit, coords | ||
end | ||
|
||
function DrawScene(currentScene) | ||
local onScreen, screenX, screenY = GetScreenCoordFromWorldCoord(currentScene.coords.x, currentScene.coords.y, currentScene.coords.z) | ||
if onScreen then | ||
local camCoords = GetFinalRenderedCamCoord() | ||
local distance = #(currentScene.coords - camCoords) | ||
local fov = (1 / GetGameplayCamFov()) * 75 | ||
local scale = (1 / distance) * (4) * fov * (currentScene.fontSize or 1) | ||
local r,g,b=rgbToHex(currentScene.colour or "#ffffff") | ||
local text = currentScene.text | ||
SetTextScale(0.0, scale) | ||
SetTextFont(currentScene.font or 0) | ||
SetTextColour(r, g, b, 255) | ||
SetTextProportional(true) | ||
SetTextWrap(0.0, 1.0) | ||
SetTextCentre(true) | ||
if currentScene.shadow then | ||
SetTextDropshadow(1, 255, 255, 255, 0) | ||
end | ||
if currentScene.outline then | ||
SetTextOutline() | ||
end | ||
BeginTextCommandGetWidth("STRING") | ||
AddTextComponentString(text ~= "" and text or "Example Text") | ||
local H = GetRenderedCharacterHeight(scale, currentScene.font)+0.0030 | ||
local W = EndTextCommandGetWidth(currentScene.font)+0.005 | ||
BeginTextCommandDisplayText("STRING") | ||
AddTextComponentString(text ~= "" and text or "Example Text") | ||
EndTextCommandDisplayText(screenX, screenY) | ||
|
||
if currentScene.background and currentScene.background ~= "none" then | ||
local br, bg, bb = rgbToHex(currentScene.backgroundColour) | ||
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) | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
---Credit https://github.com/andristum/dpscenes | ||
|
||
Fonts = { | ||
{label = "Chalet Comprimé", value = "4", group = "Normal"}, | ||
{label = "Chalet", value = "0", group = "Normal"}, | ||
{label = "Sign Painter", value = "1", group = "Handwritten"}, | ||
{label = "Pricedown", value = "7", group = "Misc"}, | ||
} | ||
|
||
local AddonFonts = { | ||
--Normal | ||
{"ArialNarrow", "Arial Narrow", "Normal"}, | ||
{"Lato", "Lato", "Normal"}, | ||
-- Handwritten | ||
{"Inkfree", "Inkfree", "Handwritten"}, | ||
{"Kid", "Kid", "Handwritten"}, | ||
{"Strawberry", "Strawberry", "Handwritten"}, | ||
{"PaperDaisy", "Paper Daisy", "Handwritten"}, | ||
{"ALittleSunshine", "A Little Sunshine", "Handwritten"}, | ||
{"WriteMeASong", "Write Me A Song", "Handwritten"}, | ||
-- Graffiti | ||
{"BeatStreet", "Beat Street", "Graffiti"}, | ||
{"DirtyLizard", "Dirty Lizard", "Graffiti"}, | ||
{"Maren", "Maren", "Graffiti"}, | ||
-- Misc | ||
{"HappyDay", "Happy Day", "Misc"}, | ||
{"ImpactLabel", "Impact Label", "Misc"}, | ||
{"Easter", "Easter", "Misc"}, | ||
} | ||
|
||
|
||
for i = 1, #AddonFonts do | ||
RegisterFontFile(AddonFonts[i][1]) | ||
local Id = RegisterFontId(AddonFonts[i][2]) | ||
Fonts[#Fonts+1] = {label = AddonFonts[i][2], value = tostring(Id), group = AddonFonts[i][3]} | ||
end | ||
|
||
|
||
RegisterNUICallback('getFonts', function(_, cb) | ||
cb(Fonts) | ||
end) |
Oops, something went wrong.