jg-advancedgarages

Integration with jg-advancedgarages

1

Find folder: jg-advancedgarages/framework

Inside this folder go to the file sv-functions.lua

Replace function Framework.Server.GetPlayerGang(src) with this:

function Framework.Server.GetPlayerGang(src)
  if (Config.Gangs == "auto" and GetResourceState("rcore_gangs") == "started") or Config.Gangs == "rcore_gangs"  then
    local gang = exports.rcore_gangs:GetPlayerGang(src)
    if not gang then return {} end

    return {
      name = gang.name,
      label = gang.name,
      grade = 0 -- rcore_gangs' grade system are only strings
    }
  elseif (Config.Gangs == "auto" and GetResourceState("op-crime") == "started") or Config.Gangs == "op-crime" then
    local ident = Framework.Server.GetPlayerIdentifier(src)
    local playerGang = exports['op-crime']:getPlayerOrganisation(ident)
    if not playerGang then return end

    return {
      name = tostring("gang_" .. playerGang.orgIndex),
      label = tostring(playerGang.orgData.label),
      grade = 0 
    }
  elseif (Config.Gangs == "auto" and GetResourceState("qb-gangs") == "started") or Config.Gangs == "qb-gangs" or Config.Framework == "QBCore" or Config.Framework == "Qbox" then

    local player = Framework.Server.GetPlayer(src)
    if not player then return false end

    return {
      name = player.PlayerData.gang.name,
      label = player.PlayerData.gang.label,
      grade = player.PlayerData.gang.grade.level
    }
  elseif Config.Framework == "ESX" then
    -- To implement gangs in ESX, enable Config.GangEnableCustomESXIntegration & then add the necessary exports here.
    -- It must return the same data structure as QB/X above, with { name, label, grade }
    -- Heads up, you must also add the exports to cl-functions.lua -> Framework.Client.GetPlayerGang
    error("ESX does not natively support gangs.");
  end

  return false
end
2

The same file

in the same file find function Framework.Server.GetGangs() and replace it with this:

function Framework.Server.GetGangs()
  if (Config.Gangs == "auto" and GetResourceState("rcore_gangs") == "started") or Config.Gangs == "rcore_gangs" then
    local gangs = MySQL.query.await("SELECT name FROM gangs")
    return gangs or {}
  elseif (Config.Gangs == "auto" and GetResourceState("op-crime") == "started") or Config.Gangs == "op-crime" then 
    local gangs = exports['op-crime']:getOrganisationsList()
    local newGangs = {}

    for k, v in pairs(gangs) do 
      table.insert(newGangs, {
        name = tostring("gang_" .. v.identifier), 
        label = tostring("gang_" .. v.identifier),
        grades = {
          ['0'] = { name = 'Recruit' }
        }
      })
    end
    return newGangs
  elseif (Config.Gangs == "auto" and GetResourceState("qb-gangs") == "started") or Config.Gangs == "qb-gangs" then 
    if Config.Framework == "QBCore" then
      return QBCore.Shared.Gangs
    elseif Config.Framework == "Qbox" then
      return exports.qbx_core:GetGangs()
    end
  elseif Config.Framework == "ESX" then
    error("ESX does not natively support gangs.");
  end

  return false
end
3

Find folder: jg-advancedgarages/framework

Inside this folder go to the file cl-functions.lua

Inside this folder find function Framework.Client.GetPlayerGang() and replace it with this

function Framework.Client.GetPlayerGang()
  if (Config.Gangs == "auto" and GetResourceState("rcore_gangs") == "started") or Config.Gangs == "rcore_gangs" then
    local gang = exports.rcore_gangs:GetPlayerGang()
    if not gang then return {} end

    return {
      name = gang.name,
      label = gang.name,
      grade = 0 -- rcore_gangs' grade system are only strings
    }
  elseif (Config.Gangs == "auto" and GetResourceState("op-crime") == "started") or Config.Gangs == "op-crime" then
    local orgData = exports['op-crime']:getPlayerOrganisation()
    if not orgData then return {} end

    return {
      name = tostring("gang_" .. orgData.id),
      label = orgData.label,
      grade = 0
    }
  elseif (Config.Gangs == "auto" and GetResourceState("qb-gangs") == "started") or Config.Gangs == "qb-gangs" or Config.Framework == "QBCore" or Config.Framework == "Qbox" then
    local player = Framework.Client.GetPlayerData()
    if not player or not player.gang then return {} end

    return {
      name = player.gang.name,
      label = player.gang.label,
      grade = player.gang.grade.level
    }
  elseif Config.Framework == "ESX" then
    -- To implement gangs in ESX, enable Config.GangEnableCustomESXIntegration & then add the necessary exports here.
    -- It must return the same data structure as QB/X above, with { name, label, grade }
    -- Heads up, you must also add the exports to sv-functions.lua -> Framework.Server.GetPlayerGang
    error("ESX does not natively support gangs.");
  end

  return false
end
4

Find folder: jg-advancedgarages/framework

Go to the jg-advancedgarages/framework/cl-functions.lua and place this code on the end of the file.

-- Handler to fetch gang change
RegisterNetEvent("op-crime:jobChanged")
AddEventHandler('op-crime:jobChanged', function(jobId, jobLabel, rankName)
  Globals.PlayerData.gang = {
    name = jobId,
    label = jobLabel,
    grade = 0
  }
  Wait(5000)
  TriggerEvent("jg-advancedgarages:client:update-blips-text-uis")
end)
5

Download sv-opcrime.lua file

This is file which adds events to inject gang garages data into jg-garages, since this garage system doesn't come with exports to open gang garage.

6

Find folder: jg-advancedgarages/framework

Place sv-opcrime.lua file which you dowloaded into this folder.

7

Set garage system in op-crime

Set Config.GarageScript = "jg-advancedgarages"

Last updated