Skip to content

Commit

Permalink
Auto Build and Bug Fix (#71)
Browse files Browse the repository at this point in the history
* Add auto build. Remove dist from repo

* Add auto build. Remove dist from repo

* Fixed bug in ui where it didn't reflect currency type setting

* Fixed bug in ui where it didn't reflect currency type setting

* Updated readme to reflect release download

* Updated fxmanifest to reflect new auto build

* Fixed Auto Build File. Fixed fxmanifest.

* Fixing static asset links

* Fixing static asset links

* Fixing static asset links

* Fixing static asset links
  • Loading branch information
DavFount authored Jul 13, 2023
1 parent c2103ce commit 9b84f75
Show file tree
Hide file tree
Showing 105 changed files with 450 additions and 348 deletions.
41 changes: 41 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
name: "release"

on:
push:
branches:
- "main"

jobs:
release:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Set Node.js 16.x
uses: actions/setup-node@v3
with:
node-version: 16.x
- name: Install Node Modules
run: yarn install
working-directory: ./ui
- name: Build Application
run: yarn run build
working-directory: ./ui
- uses: vimtor/action-zip@v1
with:
files: fxmanifest.lua license.md README.md locale.lua version ui/dist client server config img languages
recursive: false
dest: bcc-stables.zip
- name: get-npm-version
id: package-version
uses: martinbeentjes/npm-get-version-action@main
with:
path: ui
- uses: "marvinpinto/action-automatic-releases@latest"
with:
repo_token: "${{ secrets.GITHUB_TOKEN }}"
automatic_release_tag: "${{ steps.package-version.outputs.current-version}}"
prerelease: false
title: "Release ${{ steps.package-version.outputs.current-version}}"
files: |
bcc-stables.zip
32 changes: 32 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
html
ui/node_modules

# Logs
ui/logs
ui/*.log
ui/npm-debug.log*
ui/yarn-debug.log*
ui/yarn-error.log*
ui/pnpm-debug.log*
ui/lerna-debug.log*

ui/node_modules
ui/.DS_Store
ui/dist
ui/dist-ssr
ui/coverage
ui/*.local

/cypress/videos/
/cypress/screenshots/

# Editor directories and files
ui/.vscode/*
ui/!.vscode/extensions.json
ui/.idea
ui/*.suo
ui/*.ntvs*
ui/*.njsproj
ui/*.sln
ui/*.sw?
ui/.yarn-installed
11 changes: 10 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
# bcc-stables

#### Description

Stables script for RedM servers using the [VORP framework](https://github.com/VORPCORE). Using the 7 original stable locations from the game. More stable locations may be added in the `config.lua` file.

#### Features

- Buy and sell horses through the stables
- Cash and/or gold may be used for payments in the menu
- Individual inventory for each horse
Expand All @@ -21,17 +23,22 @@ Stables script for RedM servers using the [VORP framework](https://github.com/VO
- Use oil lantern from inventory to equip a lantern to your horse

#### Tips

- Whistleing -- A short whistle will call your horse. A long one will set your horse to follow you. A second long whistle or mounting your horse will cancel following.

#### Commands

`/horseRespawn` Respawn your horse while bypassing the distance check

#### Dependencies

- [vorp_core](https://github.com/VORPCORE/vorp-core-lua)
- [vorp_inventory](https://github.com/VORPCORE/vorp_inventory-lua)
- [vorp_utils](https://github.com/VORPCORE/vorp_utils)

#### Installation

- Download the latest release `bcc-stables.zip` at [/releases/latest](https://github.com/BryceCanyonCounty/bcc-stables/releases/latest)
- Add `bcc-stables` folder to your resources folder
- Add `ensure bcc-stables` to your `resources.cfg`
- Run the included database file `bcc-stables.sql`
Expand All @@ -40,10 +47,12 @@ Stables script for RedM servers using the [VORP framework](https://github.com/VO
- Restart server

#### Credits

- lrp_stables
- vorp_stores
- [ByteSizd](https://github.com/AndrewR3K) - Vue Boilerplate for RedM
- [SavSin](https://github.com/DavFount) - UI conversion to VueJS

#### GitHub
- https://github.com/BryceCanyonCounty/bcc-stables

- https://github.com/BryceCanyonCounty/bcc-stables
282 changes: 141 additions & 141 deletions config/config.lua

Large diffs are not rendered by default.

16 changes: 9 additions & 7 deletions fxmanifest.lua
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ rdr3_warning 'I acknowledge that this is a prerelease build of RedM, and I am aw

game 'rdr3'
lua54 'yes'
author 'BCC @Apollyon'


client_scripts {
Expand All @@ -22,18 +23,19 @@ shared_scripts {
}

ui_page {
'ui/dist/index.html'
'ui/index.html'
}

files {
'ui/dist/index.html',
'ui/dist/js/*.*',
'ui/dist/css/*.*',
'ui/dist/fonts/*.*',
'ui/dist/img/*.*',
'ui/dist/style.css'
"ui/index.html",
"ui/js/*.*",
"ui/css/*.*",
"ui/fonts/*.*",
"ui/img/*.*",
}

dependencies {
'vorp_utils'
}

version '1.1.0'
166 changes: 93 additions & 73 deletions server/server.lua
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@ RegisterNetEvent('bcc-stables:GetMyHorses', function()
local charid = Character.charIdentifier

MySQL.Async.fetchAll('SELECT * FROM player_horses WHERE identifier = ? AND charid = ?', { identifier, charid },
function(horses)
TriggerClientEvent('bcc-stables:ReceiveHorsesData', src, horses)
end)
function(horses)
TriggerClientEvent('bcc-stables:ReceiveHorsesData', src, horses)
end)
end)

RegisterNetEvent('bcc-stables:BuyHorse', function(data)
Expand All @@ -26,35 +26,35 @@ RegisterNetEvent('bcc-stables:BuyHorse', function(data)
local maxHorses = Config.maxHorses

MySQL.Async.fetchAll('SELECT * FROM player_horses WHERE identifier = ? AND charid = ?', { identifier, charid },
function(horses)
if #horses >= maxHorses then
VORPcore.NotifyRightTip(src, _U('horseLimit') .. maxHorses .. _U('horses'), 5000)
TriggerClientEvent('bcc-stables:StableMenu', src)
return
end
Wait(200)

if data.IsCash then
local cashPrice = data.Cash
if Character.money >= cashPrice then
Character.removeCurrency(0, cashPrice)
else
VORPcore.NotifyRightTip(src, _U('shortCash'), 5000)
function(horses)
if #horses >= maxHorses then
VORPcore.NotifyRightTip(src, _U('horseLimit') .. maxHorses .. _U('horses'), 5000)
TriggerClientEvent('bcc-stables:StableMenu', src)
return
end
else
local goldPrice = data.Gold
if Character.gold >= goldPrice then
Character.removeCurrency(1, goldPrice)
Wait(200)

if data.IsCash then
local cashPrice = data.Cash
if Character.money >= cashPrice then
Character.removeCurrency(0, cashPrice)
else
VORPcore.NotifyRightTip(src, _U('shortCash'), 5000)
TriggerClientEvent('bcc-stables:StableMenu', src)
return
end
else
VORPcore.NotifyRightTip(src, _U('shortGold'), 5000)
TriggerClientEvent('bcc-stables:StableMenu', src)
return
local goldPrice = data.Gold
if Character.gold >= goldPrice then
Character.removeCurrency(1, goldPrice)
else
VORPcore.NotifyRightTip(src, _U('shortGold'), 5000)
TriggerClientEvent('bcc-stables:StableMenu', src)
return
end
end
end
TriggerClientEvent('bcc-stables:SetHorseName', src, data, false)
end)
TriggerClientEvent('bcc-stables:SetHorseName', src, data, false)
end)
end)

RegisterNetEvent('bcc-stables:BuyTack', function(data)
Expand Down Expand Up @@ -88,17 +88,18 @@ RegisterNetEvent('bcc-stables:SaveNewHorse', function(data, name)
local identifier = Character.identifier
local charid = Character.charIdentifier

MySQL.Async.execute('INSERT INTO player_horses (identifier, charid, name, model, gender) VALUES (?, ?, ?, ?, ?)', { identifier, charid, tostring(name), data.ModelH, data.gender },
function(done)
end)
MySQL.Async.execute('INSERT INTO player_horses (identifier, charid, name, model, gender) VALUES (?, ?, ?, ?, ?)',
{ identifier, charid, tostring(name), data.ModelH, data.gender },
function(done)
end)
end)

RegisterNetEvent('bcc-stables:UpdateHorseName', function(data, name)
local horseId = data.horseId

MySQL.Async.execute('UPDATE player_horses SET name = ? WHERE id = ?', { name, horseId },
function(done)
end)
function(done)
end)
end)

RegisterNetEvent('bcc-stables:SelectHorse', function(id)
Expand All @@ -108,19 +109,23 @@ RegisterNetEvent('bcc-stables:SelectHorse', function(id)
local charid = Character.charIdentifier

MySQL.Async.fetchAll('SELECT * FROM player_horses WHERE identifier = ? AND charid = ?', { identifier, charid },
function(horse)
for i = 1, #horse do
local horseId = horse[i].id
MySQL.Async.execute('UPDATE player_horses SET selected = ? WHERE identifier = ? AND charid = ? AND id = ?', { 0, identifier, charid, horseId },
function(done)
if horse[i].id == id then
MySQL.Async.execute('UPDATE player_horses SET selected = ? WHERE identifier = ? AND charid = ? AND id = ?', { 1, identifier, charid, id },
function(horse)
for i = 1, #horse do
local horseId = horse[i].id
MySQL.Async.execute(
'UPDATE player_horses SET selected = ? WHERE identifier = ? AND charid = ? AND id = ?',
{ 0, identifier, charid, horseId },
function(done)
if horse[i].id == id then
MySQL.Async.execute(
'UPDATE player_horses SET selected = ? WHERE identifier = ? AND charid = ? AND id = ?',
{ 1, identifier, charid, id },
function(done)
end)
end
end)
end
end)
end
end)
end
end)
end)

RegisterNetEvent('bcc-stables:GetSelectedHorse', function()
Expand All @@ -130,17 +135,18 @@ RegisterNetEvent('bcc-stables:GetSelectedHorse', function()
local charid = Character.charIdentifier

MySQL.Async.fetchAll('SELECT * FROM player_horses WHERE identifier = ? AND charid = ?', { identifier, charid },
function(horses)
if #horses ~= 0 then
for i = 1, #horses do
if horses[i].selected == 1 then
TriggerClientEvent('bcc-stables:SetHorseInfo', src, horses[i].model, horses[i].name, horses[i].components, horses[i].id, horses[i].gender)
function(horses)
if #horses ~= 0 then
for i = 1, #horses do
if horses[i].selected == 1 then
TriggerClientEvent('bcc-stables:SetHorseInfo', src, horses[i].model, horses[i].name,
horses[i].components, horses[i].id, horses[i].gender)
end
end
else
VORPcore.NotifyRightTip(src, _U('noHorses'), 5000)
end
else
VORPcore.NotifyRightTip(src, _U('noHorses'), 5000)
end
end)
end)
end)

RegisterNetEvent('bcc-stables:UpdateComponents', function(components, horseId, MyHorse_entity)
Expand All @@ -150,10 +156,11 @@ RegisterNetEvent('bcc-stables:UpdateComponents', function(components, horseId, M
local charid = Character.charIdentifier
local encodedComponents = json.encode(components)

MySQL.Async.execute('UPDATE player_horses SET components = ? WHERE identifier = ? AND charid = ? AND id = ?', { encodedComponents, identifier, charid, horseId },
function(done)
TriggerClientEvent('bcc-stables:SetComponents', src, MyHorse_entity, components)
end)
MySQL.Async.execute('UPDATE player_horses SET components = ? WHERE identifier = ? AND charid = ? AND id = ?',
{ encodedComponents, identifier, charid, horseId },
function(done)
TriggerClientEvent('bcc-stables:SetComponents', src, MyHorse_entity, components)
end)
end)

RegisterNetEvent('bcc-stables:SellHorse', function(id)
Expand All @@ -164,25 +171,26 @@ RegisterNetEvent('bcc-stables:SellHorse', function(id)
local modelHorse = nil

MySQL.Async.fetchAll('SELECT * FROM player_horses WHERE identifier = ? AND charid = ?', { identifier, charid },
function(horses)
for i = 1, #horses do
if tonumber(horses[i].id) == tonumber(id) then
modelHorse = horses[i].model
MySQL.Async.execute('DELETE FROM player_horses WHERE identifier = ? AND charid = ? AND id = ?', { identifier, charid, id },
function(done)
for _, horseConfig in pairs(Config.Horses) do
for models, values in pairs(horseConfig.colors) do
if models == modelHorse then
local sellPrice = (Config.sellPrice * values.cashPrice)
Character.addCurrency(0, sellPrice)
VORPcore.NotifyRightTip(src, _U('soldHorse') .. sellPrice, 5000)
function(horses)
for i = 1, #horses do
if tonumber(horses[i].id) == tonumber(id) then
modelHorse = horses[i].model
MySQL.Async.execute('DELETE FROM player_horses WHERE identifier = ? AND charid = ? AND id = ?',
{ identifier, charid, id },
function(done)
for _, horseConfig in pairs(Config.Horses) do
for models, values in pairs(horseConfig.colors) do
if models == modelHorse then
local sellPrice = (Config.sellPrice * values.cashPrice)
Character.addCurrency(0, sellPrice)
VORPcore.NotifyRightTip(src, _U('soldHorse') .. sellPrice, 5000)
end
end
end
end
end
end)
end)
end
end
end
end)
end)
end)

-- Inventory
Expand Down Expand Up @@ -229,3 +237,15 @@ RegisterNetEvent('bcc-stables:GetPlayerJob', function()

TriggerClientEvent('bcc-stables:SendPlayerJob', src, CharacterJob, CharacterGrade)
end)

--- Check if properly downloaded
function file_exists(name)
local f = LoadResourceFile(GetCurrentResourceName(), name)
return f ~= nil
end

if not file_exists('./ui/index.html') then
print("^1 INCORRECT DOWNLOAD! ^0")
print(
'^4 Please Download: ^2(bcc-stables.zip) ^4from ^3<https://github.com/BryceCanyonCounty/bcc-stables/releases/latest>^0')
end
Loading

0 comments on commit 9b84f75

Please sign in to comment.