mirror of
https://github.com/jimathy/jim_bridge.git
synced 2026-08-17 05:56:02 +01:00
Support for esx_society
`esx_society` requires societies to be registered manually before opening. this forces it also adds full support for charging, funding and retrieving balances in `esx_society`
This commit is contained in:
@@ -33,6 +33,7 @@ local bossMenuFunc = {
|
|||||||
|
|
||||||
{ name = "esx_society",
|
{ name = "esx_society",
|
||||||
openBossMenu = function(isGang, group)
|
openBossMenu = function(isGang, group)
|
||||||
|
TriggerServerEvent(getScript()..":registerESXSociety", isGang, group)
|
||||||
TriggerEvent('esx_society:openBossMenu', group, function() end, { wash = false })
|
TriggerEvent('esx_society:openBossMenu', group, function() end, { wash = false })
|
||||||
end,
|
end,
|
||||||
},
|
},
|
||||||
@@ -60,6 +61,20 @@ function openBossMenu(isGang, group)
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
-- Register ESX Society account in the server
|
||||||
|
RegisterNetEvent(getScript()..":registerESXSociety", function(group)
|
||||||
|
local checkExist = exports.esx_society:GetSociety(group)
|
||||||
|
if checkExist == nil then
|
||||||
|
exports.esx_society:registerSociety(
|
||||||
|
group,
|
||||||
|
Gangs[group] and Gangs[group].label or Jobs[group] and Jobs[group].label,
|
||||||
|
group,
|
||||||
|
group,
|
||||||
|
group,
|
||||||
|
{type = "public"}
|
||||||
|
)
|
||||||
|
end
|
||||||
|
end)
|
||||||
|
|
||||||
-------------------------------------------------------------
|
-------------------------------------------------------------
|
||||||
-- Global Duty Status
|
-- Global Duty Status
|
||||||
|
|||||||
@@ -12,52 +12,6 @@
|
|||||||
]]
|
]]
|
||||||
|
|
||||||
local societyFunc = {
|
local societyFunc = {
|
||||||
{ bankName = "qb-banking",
|
|
||||||
getAccount =
|
|
||||||
function(society)
|
|
||||||
if not exports["qb-banking"]:GetAccount(society) then
|
|
||||||
if Jobs[society] then
|
|
||||||
print("^6Bridge^7: ^2Making new bank account in ^7'^3qb-banking^7' ^2for ^7'^3"..society.."^7'")
|
|
||||||
exports["qb-banking"]:CreateJobAccount(society, 0)
|
|
||||||
Wait(150)
|
|
||||||
elseif Gangs[society] then
|
|
||||||
print("^6Bridge^7: ^2Making new bank account in ^7'^3qb-banking^7' ^2for ^7'^3"..society.."^7'")
|
|
||||||
exports["qb-banking"]:CreateGangAccount(society, 0)
|
|
||||||
Wait(150)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
return exports["qb-banking"]:GetAccountBalance(society)
|
|
||||||
end,
|
|
||||||
chargeSociety =
|
|
||||||
function(society, amount)
|
|
||||||
if not exports["qb-banking"]:GetAccount(society) then
|
|
||||||
if Jobs[society] then
|
|
||||||
print("^6Bridge^7: ^2Making new bank account in ^7'^3qb-banking^7' ^2for ^7'^3"..society.."^7'")
|
|
||||||
exports["qb-banking"]:CreateJobAccount(society, 0) Wait(150) -- make new account if return "null"
|
|
||||||
elseif Gangs[society] then
|
|
||||||
print("^6Bridge^7: ^2Making new bank account in ^7'^3qb-banking^7' ^2for ^7'^3"..society.."^7'")
|
|
||||||
exports["qb-banking"]:CreateGangAccount(society, 0) Wait(150) -- make new account if return "null"
|
|
||||||
end
|
|
||||||
end
|
|
||||||
exports["qb-banking"]:RemoveMoney(society, amount)
|
|
||||||
end,
|
|
||||||
fundSociety =
|
|
||||||
function(society, amount)
|
|
||||||
if not exports["qb-banking"]:GetAccount(society) then
|
|
||||||
if Jobs[society] then
|
|
||||||
print("^6Bridge^7: ^2Making new bank account in ^7'^3qb-banking^7' ^2for ^7'^3"..society.."^7'")
|
|
||||||
exports["qb-banking"]:CreateJobAccount(society, 0)
|
|
||||||
Wait(150)
|
|
||||||
elseif Gangs[society] then
|
|
||||||
print("^6Bridge^7: ^2Making new bank account in ^7'^3qb-banking^7' ^2for ^7'^3"..society.."^7'")
|
|
||||||
exports["qb-banking"]:CreateGangAccount(society, 0)
|
|
||||||
Wait(150)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
exports["qb-banking"]:AddMoney(society, amount)
|
|
||||||
end,
|
|
||||||
},
|
|
||||||
|
|
||||||
{ bankName = "Renewed-Banking",
|
{ bankName = "Renewed-Banking",
|
||||||
getAccount =
|
getAccount =
|
||||||
function(society)
|
function(society)
|
||||||
@@ -129,6 +83,115 @@ local societyFunc = {
|
|||||||
end
|
end
|
||||||
end,
|
end,
|
||||||
},
|
},
|
||||||
|
|
||||||
|
{ bankName = "qb-banking",
|
||||||
|
getAccount =
|
||||||
|
function(society)
|
||||||
|
if not exports["qb-banking"]:GetAccount(society) then
|
||||||
|
if Jobs[society] then
|
||||||
|
print("^6Bridge^7: ^2Making new bank account in ^7'^3qb-banking^7' ^2for ^7'^3"..society.."^7'")
|
||||||
|
exports["qb-banking"]:CreateJobAccount(society, 0)
|
||||||
|
Wait(150)
|
||||||
|
elseif Gangs[society] then
|
||||||
|
print("^6Bridge^7: ^2Making new bank account in ^7'^3qb-banking^7' ^2for ^7'^3"..society.."^7'")
|
||||||
|
exports["qb-banking"]:CreateGangAccount(society, 0)
|
||||||
|
Wait(150)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
return exports["qb-banking"]:GetAccountBalance(society)
|
||||||
|
end,
|
||||||
|
chargeSociety =
|
||||||
|
function(society, amount)
|
||||||
|
if not exports["qb-banking"]:GetAccount(society) then
|
||||||
|
if Jobs[society] then
|
||||||
|
print("^6Bridge^7: ^2Making new bank account in ^7'^3qb-banking^7' ^2for ^7'^3"..society.."^7'")
|
||||||
|
exports["qb-banking"]:CreateJobAccount(society, 0) Wait(150) -- make new account if return "null"
|
||||||
|
elseif Gangs[society] then
|
||||||
|
print("^6Bridge^7: ^2Making new bank account in ^7'^3qb-banking^7' ^2for ^7'^3"..society.."^7'")
|
||||||
|
exports["qb-banking"]:CreateGangAccount(society, 0) Wait(150) -- make new account if return "null"
|
||||||
|
end
|
||||||
|
end
|
||||||
|
exports["qb-banking"]:RemoveMoney(society, amount)
|
||||||
|
end,
|
||||||
|
fundSociety =
|
||||||
|
function(society, amount)
|
||||||
|
if not exports["qb-banking"]:GetAccount(society) then
|
||||||
|
if Jobs[society] then
|
||||||
|
print("^6Bridge^7: ^2Making new bank account in ^7'^3qb-banking^7' ^2for ^7'^3"..society.."^7'")
|
||||||
|
exports["qb-banking"]:CreateJobAccount(society, 0)
|
||||||
|
Wait(150)
|
||||||
|
elseif Gangs[society] then
|
||||||
|
print("^6Bridge^7: ^2Making new bank account in ^7'^3qb-banking^7' ^2for ^7'^3"..society.."^7'")
|
||||||
|
exports["qb-banking"]:CreateGangAccount(society, 0)
|
||||||
|
Wait(150)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
exports["qb-banking"]:AddMoney(society, amount)
|
||||||
|
end,
|
||||||
|
},
|
||||||
|
|
||||||
|
{ bankName = "esx_society",
|
||||||
|
getAccount =
|
||||||
|
function(society)
|
||||||
|
local checkExist = exports.esx_society:GetSociety(society)
|
||||||
|
if checkExist == nil then
|
||||||
|
print("^6Bridge^7: ^2Making new bank account in ^7'^3esx_society^7' ^2for ^7'^3"..society.."^7'")
|
||||||
|
exports.esx_society:registerSociety(
|
||||||
|
society,
|
||||||
|
Gangs[society] and Gangs[society].label or Jobs[society] and Jobs[society].label,
|
||||||
|
society,
|
||||||
|
society,
|
||||||
|
society,
|
||||||
|
{type = "public"}
|
||||||
|
)
|
||||||
|
end
|
||||||
|
local p = promise.new()
|
||||||
|
TriggerEvent('esx_addonaccount:getSharedAccount', checkExist.account, function(account)
|
||||||
|
p:resolve(account.money)
|
||||||
|
end)
|
||||||
|
local newAmount = Citizen.Await(p)
|
||||||
|
return newAmount
|
||||||
|
end,
|
||||||
|
chargeSociety =
|
||||||
|
function(society, amount)
|
||||||
|
local checkExist = exports.esx_society:GetSociety(society)
|
||||||
|
if checkExist == nil then
|
||||||
|
print("^6Bridge^7: ^2Making new bank account in ^7'^3esx_society^7' ^2for ^7'^3"..society.."^7'")
|
||||||
|
exports.esx_society:registerSociety(
|
||||||
|
society,
|
||||||
|
Gangs[society] and Gangs[society].label or Jobs[society] and Jobs[society].label,
|
||||||
|
society,
|
||||||
|
society,
|
||||||
|
society,
|
||||||
|
{type = "public"}
|
||||||
|
)
|
||||||
|
end
|
||||||
|
TriggerEvent('esx_addonaccount:getSharedAccount', checkExist.account, function(account)
|
||||||
|
if amount > 0 and account.money >= amount then
|
||||||
|
account.removeMoney(amount)
|
||||||
|
end
|
||||||
|
end)
|
||||||
|
end,
|
||||||
|
fundSociety =
|
||||||
|
function(society, amount)
|
||||||
|
local checkExist = exports.esx_society:GetSociety(society)
|
||||||
|
if checkExist == nil then
|
||||||
|
print("^6Bridge^7: ^2Making new bank account in ^7'^3esx_society^7' ^2for ^7'^3"..society.."^7'")
|
||||||
|
exports.esx_society:registerSociety(
|
||||||
|
society,
|
||||||
|
Gangs[society] and Gangs[society].label or Jobs[society] and Jobs[society].label,
|
||||||
|
society,
|
||||||
|
society,
|
||||||
|
society,
|
||||||
|
{type = "public"}
|
||||||
|
)
|
||||||
|
end
|
||||||
|
TriggerEvent('esx_addonaccount:getSharedAccount', checkExist.account, function(account)
|
||||||
|
account.addMoney(amount)
|
||||||
|
end)
|
||||||
|
end,
|
||||||
|
},
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -201,13 +264,3 @@ function fundSociety(society, amount)
|
|||||||
|
|
||||||
print("^1Error^7: ^3FundSociety^7: ^2No supported banking script found")
|
print("^1Error^7: ^3FundSociety^7: ^2No supported banking script found")
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
-- other
|
|
||||||
if isStarted("esx_society") then
|
|
||||||
createCallback(getScript()..":getESXSocietyAccount", function(source, society)
|
|
||||||
-- Example query – adjust table/field names to match your esx_society implementation.
|
|
||||||
local result = MySQL.scalar.await('SELECT money FROM society_money WHERE society = ?', { society })
|
|
||||||
return result or 0
|
|
||||||
end)
|
|
||||||
end
|
|
||||||
Reference in New Issue
Block a user