Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
f3e847a
fix(server/main.lua): ensure player has weapon before removal
MrSne7aky Aug 15, 2025
ad23050
ix(server/main.lua): ensure player has weapon before removal
MrSne7aky Aug 15, 2025
16e4986
Merge branch 'dev' into patch-1
OualiS Aug 31, 2025
ecfb592
Remove outdated check for `esx_hud`
Sep 1, 2025
85ad061
Switch to ESX TextUI
Sep 1, 2025
3e759de
Switch to ESX TextUI
Sep 1, 2025
a10dd80
refactor(esx_accessories/client/main): switch to ESX:TextUI
Sep 1, 2025
da9c596
refactor(esx_drugs): switch to ESX:TextUI
Sep 2, 2025
638aa14
refactor(esx_accessories/client/main): switch to ESX:TextUI
Sep 3, 2025
cf8a18f
refactor(esx_taxijob): switch to ESX:TextUI
Sep 3, 2025
3798f90
refactor(addonaccount): add type annotations
Mirrrrrow Sep 4, 2025
b80a078
chore: update manifest
Mirrrrrow Sep 4, 2025
f0218c0
chore: remove comments
Mirrrrrow Sep 4, 2025
3449ff3
refactor(server): rewrite
Mirrrrrow Sep 4, 2025
c0074ea
refactor(esx_addonaccount): lazy load accounts
Mirrrrrow Sep 5, 2025
142e62d
feat(esx_addonaccount): add fn to sync accounts with database
Mirrrrrow Sep 5, 2025
097d539
feat(esx_addonaccount): save accounts on restart
Mirrrrrow Sep 5, 2025
f7f9b95
fix(esx_addonaccount): load database module
Mirrrrrow Sep 5, 2025
3016032
fix(esx_addonaccount): properly save accounts
Mirrrrrow Sep 5, 2025
f13e0a2
fix(esx_addonaccount): correct account query
Mirrrrrow Sep 6, 2025
ed5322f
fix(esx_addonaccount/server): table indexing error
Mirrrrrow Sep 6, 2025
9cb5e7d
feat(addonaccount): return success of operations
Mirrrrrow Sep 9, 2025
42ffd91
feat(esx_addonaccount): introduce `TransferMoney` export.
Mirrrrrow Sep 9, 2025
fcb8369
feat(esx_addonaccount): add `transferMoney` method to class
Mirrrrrow Sep 11, 2025
5050376
Merge pull request #17 from MrSne7aky/patch-1
FBFezz Sep 23, 2025
9445b6e
Merge pull request #54 from Fellow25/hud-fix
FBFezz Sep 23, 2025
b694c51
Merge pull request #55 from Fellow25/dmvschool-fix
FBFezz Sep 23, 2025
b81ec03
Merge pull request #57 from Fellow25/accessories-fix
FBFezz Sep 23, 2025
149d4ae
Merge pull request #60 from Fellow25/taxijob-fix
FBFezz Sep 23, 2025
f434f0d
Merge pull request #61 from Mirrrrrow/dev
FBFezz Sep 30, 2025
e2b39e8
Revert "refactor(esx_hud): remove outdated check"
N0tNvll Oct 3, 2025
81b77fa
Merge pull request #72 from esx-framework/revert-54-hud-fix
N0tNvll Oct 3, 2025
1a4be3a
change: ESX Garage web interface to Vue 3 and initialize with Tailwin…
N0tNvll Oct 5, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
108 changes: 28 additions & 80 deletions [esx_addons]/esx_accessories/client/main.lua
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
local HasAlreadyEnteredMarker = false
local LastZone, CurrentAction, CurrentActionMsg
local CurrentActionData = {}
local show_text = false

function OpenAccessoryMenu()
local elements = {
Expand Down Expand Up @@ -104,33 +102,13 @@ function OpenShopMenu(accessory)

ESX.CloseContext()
end
CurrentAction = 'shop_menu'
CurrentActionMsg = TranslateCap('press_access')
CurrentActionData = {}
end, function(menu)
CurrentAction = 'shop_menu'
CurrentActionMsg = TranslateCap('press_access')
CurrentActionData = {}
end)
end, function(data, menu)
menu.close()
CurrentAction = 'shop_menu'
CurrentActionMsg = TranslateCap('press_access')
CurrentActionData = {}
end, restrict)
end

AddEventHandler('esx_accessories:hasEnteredMarker', function(zone)
CurrentAction = 'shop_menu'
CurrentActionMsg = TranslateCap('press_access')
CurrentActionData = { accessory = zone }
end)

AddEventHandler('esx_accessories:hasExitedMarker', function(zone)
ESX.CloseContext()
CurrentAction = nil
end)

-- Create Blips --
CreateThread(function()
for k,v in pairs(Config.ShopsBlips) do
Expand All @@ -152,74 +130,44 @@ CreateThread(function()
end
end)

local nearMarker = false
-- Display markers
CreateThread(function()
while true do
local sleep = 1500
local coords = GetEntityCoords(PlayerPedId())
local interval = true
local playerCoords = GetEntityCoords(PlayerPedId())
local isInMarker = false

for k,v in pairs(Config.Zones) do
for i = 1, #v.Pos, 1 do
if(Config.Type ~= -1 and #(coords - v.Pos[i]) < Config.DrawDistance) then
local distance = #(playerCoords - v.Pos[i])

if Config.Type ~= -1 and distance < Config.DrawDistance then
DrawMarker(Config.Type, v.Pos[i], 0.0, 0.0, 0.0, 0, 0.0, 0.0, Config.Size.x, Config.Size.y, Config.Size.z, Config.Color.r, Config.Color.g, Config.Color.b, 255, true, false, 2, true, false, false, false)
sleep = 0
break
interval = false
end
end
end
if sleep == 0 then nearMarker = true else nearMarker = false end
Wait(sleep)
end
end)

CreateThread(function()
while true do
local sleep = 1500
if nearMarker then
sleep = 0
local coords = GetEntityCoords(PlayerPedId())
local isInMarker = false
local currentZone = nil
for k,v in pairs(Config.Zones) do
for i = 1, #v.Pos, 1 do
if #(coords - v.Pos[i]) < Config.Size.x then
isInMarker = true
currentZone = k
break

if distance < Config.Size.x then
isInMarker = true
interval = false
if IsControlJustReleased(0, 38) then
OpenShopMenu(k)
end
end
end

if (isInMarker and not HasAlreadyEnteredMarker) or (isInMarker and LastZone ~= currentZone) then
HasAlreadyEnteredMarker = true
LastZone = currentZone
TriggerEvent('esx_accessories:hasEnteredMarker', currentZone)
end

if not isInMarker and HasAlreadyEnteredMarker then
HasAlreadyEnteredMarker = false
TriggerEvent('esx_accessories:hasExitedMarker', LastZone)
end
end
Wait(sleep)
end
end)

-- Key controls
CreateThread(function()
while true do
local Sleep = 1500

if CurrentAction then
Sleep = 0
ESX.ShowHelpNotification(CurrentActionMsg)

if IsControlJustReleased(0, 38) and CurrentActionData.accessory then
OpenShopMenu(CurrentActionData.accessory)
CurrentAction = nil
end
if isInMarker and not show_text then
ESX.TextUI(TranslateCap('press_access'))
show_text = true
elseif not isInMarker and show_text then
ESX.HideUI()
show_text = false
end

if interval then
Wait(500)
else
Wait(0)
end
Wait(Sleep)
end
end)

Expand All @@ -229,4 +177,4 @@ if Config.EnableControls then
OpenAccessoryMenu()
end
end)
end
end
2 changes: 1 addition & 1 deletion [esx_addons]/esx_accessories/locales/cs.lua
Original file line number Diff line number Diff line change
Expand Up @@ -16,5 +16,5 @@ Locales ['cs'] = {
['no_helmet'] = 'nemáte helmu',
['no_mask'] = 'nemáte masku',
['you_paid'] = 'zaplatili jste $%s',
['keymap'] = 'Open Accessory Menu', --not translated
['keymap'] = 'Otevřít nabídku doplňků',
}
2 changes: 1 addition & 1 deletion [esx_addons]/esx_accessories/locales/es.lua
Original file line number Diff line number Diff line change
Expand Up @@ -16,5 +16,5 @@ Locales ['es'] = {
['no_helmet'] = 'No tienes ningún casco',
['no_mask'] = 'No tienes ninguna máscara',
['you_paid'] = 'Pagaste %s$',
['keymap'] = 'Open Accessory Menu', --not translated
['keymap'] = 'Abrir menú de accesorios',
}
2 changes: 1 addition & 1 deletion [esx_addons]/esx_accessories/locales/fi.lua
Original file line number Diff line number Diff line change
Expand Up @@ -16,5 +16,5 @@ Locales ['fi'] = {
['no_helmet'] = 'sinulla ei ole kypäriä',
['no_mask'] = 'sinulla ei ole maskeja',
['you_paid'] = 'sinä maksoit $%s',
['keymap'] = 'Open Accessory Menu', --not translated
['keymap'] = 'Avaa asustevalikko',
}
2 changes: 1 addition & 1 deletion [esx_addons]/esx_accessories/locales/hu.lua
Original file line number Diff line number Diff line change
Expand Up @@ -16,5 +16,5 @@ Locales ['hu'] = {
['no_helmet'] = 'Nincsen sapkád',
['no_mask'] = 'Nincsen maszkod',
['you_paid'] = 'Fizettél $%s',
['keymap'] = 'Open Accessory Menu', --not translated
['keymap'] = 'Kiegészítő menü megnyitása',
}
2 changes: 1 addition & 1 deletion [esx_addons]/esx_accessories/locales/nl.lua
Original file line number Diff line number Diff line change
Expand Up @@ -16,5 +16,5 @@ Locales ['nl'] = {
['no_helmet'] = 'je hebt geen helm',
['no_mask'] = 'je hebt geen masker',
['you_paid'] = 'je betaalde €%s',
['keymap'] = 'Open Accessory Menu', --not translated
['keymap'] = 'Accessoiremenu openen',
}
2 changes: 1 addition & 1 deletion [esx_addons]/esx_accessories/locales/pl.lua
Original file line number Diff line number Diff line change
Expand Up @@ -16,5 +16,5 @@ Locales ['pl'] = {
['no_helmet'] = 'nie posiadasz nakrycia głowy',
['no_mask'] = 'nie posiadasz maski',
['you_paid'] = 'płacisz %s $',
['keymap'] = 'Open Accessory Menu', --not translated
['keymap'] = 'Otwórz menu akcesoriów',
}
2 changes: 1 addition & 1 deletion [esx_addons]/esx_accessories/locales/sl.lua
Original file line number Diff line number Diff line change
Expand Up @@ -16,5 +16,5 @@ Locales ['sl'] = {
['no_helmet'] = 'Vi nimate kape/klobuka',
['no_mask'] = 'Vi nimate maske!',
['you_paid'] = 'Vi ste plačali $%s',
['keymap'] = 'Open Accessory Menu', --not translated
['keymap'] = 'Odpri meni dodatkov'
}
18 changes: 6 additions & 12 deletions [esx_addons]/esx_addonaccount/fxmanifest.lua
Original file line number Diff line number Diff line change
@@ -1,23 +1,17 @@
fx_version 'adamant'
fx_version 'cerulean'
game 'gta5'
lua54 'yes'
use_fxv2_oal 'yes'

author 'ESX-Framework'
description 'Allows resources to store account data, such as society funds'
lua54 'yes'
version '1.1'
description 'Allows resources to store account data, such as society funds.'
version '1.2'
legacyversion '1.13.4'

server_scripts {
'@es_extended/imports.lua',
'@oxmysql/lib/MySQL.lua',
'server/classes/addonaccount.lua',
'server/database.lua',
'server/main.lua'
}

server_exports {
'GetSharedAccount',
'AddSharedAccount',
'GetAccount'
}

dependency 'es_extended'
56 changes: 42 additions & 14 deletions [esx_addons]/esx_addonaccount/server/classes/addonaccount.lua
Original file line number Diff line number Diff line change
@@ -1,36 +1,64 @@
---@class AddonAccount
---@field name string
---@field owner? string
---@field money number
---@field addMoney fun(amount: number): boolean
---@field removeMoney fun(amount: number): boolean
---@field setMoney fun(amount: number): boolean
---@field transferMoney fun(target: TransactionAccount, amount: number): boolean
---@field save function

---@param name string
---@param owner? string
---@param money number
---@return AddonAccount
function CreateAddonAccount(name, owner, money)
local self = {}
---@diagnostic disable-next-line: missing-fields
local self = {} --[[@type AddonAccount]]

self.name = name
self.name = name
self.owner = owner
self.money = money

function self.addMoney(amount)
self.money = self.money + amount
self.save()
self.money += amount

TriggerEvent('esx_addonaccount:addMoney', self.name, amount)
TriggerClientEvent('esx_addonaccount:setMoney', -1, self.name, self.money)
return true
end

function self.removeMoney(amount)
self.money = self.money - amount
self.save()
if amount > self.money then return false end

self.money -= amount

TriggerEvent('esx_addonaccount:removeMoney', self.name, amount)
TriggerClientEvent('esx_addonaccount:setMoney', -1, self.name, self.money)
return true
end

function self.setMoney(amount)
self.money = amount
self.save()

TriggerEvent('esx_addonaccount:setMoney', self.name, amount)
TriggerClientEvent('esx_addonaccount:setMoney', -1, self.name, self.money)
return true
end

function self.save()
if self.owner == nil then
MySQL.update('UPDATE addon_account_data SET money = ? WHERE account_name = ?', { self.money, self.name })
else
MySQL.update('UPDATE addon_account_data SET money = ? WHERE account_name = ? AND owner = ?',
{ self.money, self.name, self.owner })
function self.transferMoney(target, amount)
local targetAccount = GetTransactionAccount(target)
if not targetAccount then return false end

if not self.removeMoney(amount) then
return false
end
TriggerClientEvent('esx_addonaccount:setMoney', -1, self.name, self.money)

targetAccount.addMoney(amount)
return true
end

function self.save()
end

return self
Expand Down
63 changes: 63 additions & 0 deletions [esx_addons]/esx_addonaccount/server/database.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
Database = {}

---@class DatabaseAccountRow
---@field name string
---@field label string
---@field shared number
---@field id number
---@field account_name? string
---@field money number
---@field owner? string

---@param name string
---@param owner string
---@return DatabaseAccountRow?
function Database.fetchAccount(name, owner)
local accountData = MySQL.single.await([[
SELECT * FROM addon_account aa
LEFT JOIN addon_account_data aad ON aa.name = aad.account_name
WHERE aa.shared = 0 AND aa.name = ? AND aad.owner = ?
]], { name, owner })

return accountData
end

---@param name string
---@return DatabaseAccountRow?
function Database.fetchSharedAccount(name)
local accountData = MySQL.single.await([[
SELECT * FROM addon_account aa
LEFT JOIN addon_account_data aad ON aa.name = aad.account_name
WHERE aa.shared = 1 AND aa.name = ?
]], { name })

return accountData
end

function Database.saveAccounts()
-- Save accounts that are not shared
local params, n = {}, 0
for _, accountData in pairs(Accounts) do
for owner, account in pairs(accountData) do
n += 1
params[n] = { account.money, account.name, owner }
end
end

if n > 0 then
MySQL.prepare.await([[
UPDATE addon_account_data SET money = ? WHERE account_name = ? AND owner = ?;
]], params)
end

-- Save shared accounts
params, n = {}, 0
for _, account in pairs(SharedAccounts) do
n += 1
params[n] = { account.money, account.name, nil }
end

MySQL.prepare.await([[
UPDATE addon_account_data SET money = ? WHERE account_name = ?;
]], params)
end
Loading
Loading