> ## Documentation Index
> Fetch the complete documentation index at: https://rsg.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# 📤 Shared Exports

> Learn how to use exports to update the shared dynamically!

| **Function or Event**                        | **Scope** | **Description**                                                                                    | **returns**                |
| -------------------------------------------- | --------- | -------------------------------------------------------------------------------------------------- | -------------------------- |
| exports\['rsg-core']:AddItem(itemName, item) | Server    | Accepts an item name and item object - will add new entry to RSGCore.Shared.Items                  | boolean, string            |
| exports\['rsg-core']:AddJob(jobName, job)    | Server    | Accepts an job name and job object - will add new entry to RSGCore.Shared.Jobs                     | boolean, string            |
| exports\['rsg-core']:AddGang(gangName, gang) | Server    | Accepts an gang name and gang object - will add new entry to RSGCore.Shared.Gangs                  | boolean, string            |
| exports\['rsg-core']:AddItems(items)         | Server    | Accepts a table or array - will loop through the table and add new entries to RSGCore.Shared.Items | boolean, string, errorItem |
| exports\['rsg-core']:AddJobs(jobs)           | Server    | Accepts a table or array - will loop through the table and add new entries to RSGCore.Shared.Jobs  | boolean, string, errorItem |
| exports\['rsg-core']:AddGangs(gangs)         | Server    | Accepts an item name and item object - will add new entry to RSGCore.Shared.Items                  | boolean, string, errorItem |
| RSGCore.Functions.AddItem(itemName, item)    | Server    | Accepts an item name and item object - will add new entry to RSGCore.Shared.Items                  | boolean, string            |
| RSGCore.Functions.AddJob(jobName, Job)       | Server    | Accepts an job name and job object - will add new entry to RSGCore.Shared.Jobs                     | boolean, string            |
| RSGCore.Functions.AddGang(gangName, gang)    | Server    | Accepts an gang name and gang object - will add new entry to RSGCore.Shared.Gangs                  | boolean, string            |
| RSGCore.Functions.AddItems(items)            | Server    | Accepts a table or array - will loop through the table and add new entries to RSGCore.Shared.Items | boolean, string, errorItem |
| RSGCore.Functions.AddJobs(jobs)              | Server    | Accepts a table or array - will loop through the table and add new entries to RSGCore.Shared.Jobs  | boolean, string, errorItem |
| RSGCore.Functions.AddGangs(gangs)            | Server    | Accepts a table or array - will loop through the table and add new entries to RSGCore.Shared.Gangs | boolean, string, errorItem |

## Import Jobs

* This method allows for any resource to insert job data into the shared file for the core. That means that you can make a resource, and on load, make those jobs available for use. This can be accomplished through one the ways shown below. Utilizing the function requires importing the core but using the export does not

<Warning>
  Read over and learn the [Shared](https://rsg.mintlify.app/essentials/shared) structure before attempting to use these
</Warning>

<Info>
  You must add this code to the client-side file of your resource when using these if you need the core object!
</Info>

```lua theme={null}
RegisterNetEvent('RSGCore:Client:UpdateObject', function()
	RSGCore = exports['rsg-core']:GetCoreObject()
end)
```

<Info>
  You must add this code to the server-side file of your resource when using these if you need the core object!
</Info>

```lua theme={null}
RegisterNetEvent('RSGCore:Server:UpdateObject', function()
	if source ~= '' then return false end
	RSGCore = exports['rsg-core']:GetCoreObject()
end)
```

### RSGCore.Functions.AddJob

```lua theme={null}
RSGCore.Functions.AddJob(jobName --[[string]], job --[[table]])

-- Example
RSGCore.Functions.AddJob('unemployed', {
    label = 'Civilian',
    defaultDuty = true,
    offDutyPay = false,
    grades = {
        ['0'] = {
            name = 'Freelancer',
            payment = 3
        }
    }
})
```

### exports\['rsg-core']:AddJob

```lua theme={null}
exports['rsg-core']:AddJob(jobName --[[string]], job --[[table]])

-- Example
exports['rsg-core']:AddJob('unemployed', {
    label = 'Civilian',
    defaultDuty = true,
    offDutyPay = false,
    grades = {
        ['0'] = {
            name = 'Freelancer',
            payment = 3
        }
    }
})
```

### RSGCore.Functions.AddJobs

```lua theme={null}
RSGCore.Functions.AddJobs(jobs --[[table]])

-- Example
RSGCore.Functions.AddJobs({
    ['unemployed'] = {
        label = 'Civilian',
        defaultDuty = true,
        offDutyPay = false,
        grades = {
            ['0'] = {
                name = 'Freelancer',
                payment = 3
        }
    },
    ['vallaw'] = {
	label = 'Valentine Law Enforcement',
	type = 'leo',
	defaultDuty = true,
	offDutyPay = false,
	grades = {
            ['0'] = {
                name = 'Recruit',
                payment = 7
        }
    }
})
```

## Import Gangs

* This method allows for any resource to insert gang data into the shared file for the core. That means that you can make a resource, and on load, make those gangs available for use. This can be accomplished through one the ways shown below. Utilizing the function requires importing the core but using the export does not

### RSGCore.Functions.AddGang

```lua theme={null}
RSGCore.Functions.AddGang(gangName --[[string]], gang --[[table]])

-- Example
RSGCore.Functions.AddGang('odriscoll', {
    label = 'O Driscoll Boys',
    grades = {
        ['0'] = {
            name = 'Recruit'
        }
    }
})
```

### exports\['rsg-core']:AddGang

```lua theme={null}
exports['rsg-core']:AddGang(gangName --[[string]], gang --[[table]])

-- Example
exports['rsg-core']:AddGang('odriscoll', {
    label = 'O Driscoll Boys',
    grades = {
        ['0'] = {
            name = 'Recruit'
        }
    }
})
```

### QBCore.Functions.AddGangs

```lua theme={null}
RSGCore.Functions.AddGangs(gangs --[[table]])

-- Example
RSGCore.Functions.AddGangs({
    ['odriscoll'] = {
        label = 'O Driscoll Boys',
        grades = {
            ['0'] = {
                name = 'Recruit'
            }
        }
    },
    ['lemoyne'] = {
        label = 'Lemoyne Raiders',
        grades = {
            ['0'] = {
                name = 'Recruit'
            }
        }
    }
})
```

### exports\['rsg-core']:AddGangs

```lua theme={null}
exports['rsg-core']:AddGangs(gangs --[[table]])

-- Example
exports[rsg-core']:AddGangs({
    ['odriscoll'] = {
        label = 'O Driscoll Boys',
        grades = {
            ['0'] = {
                name = 'Recruit'
            }
        }
    },
    ['lemoyne'] = {
        label = 'Lemoyne Raiders',
        grades = {
            ['0'] = {
                name = 'Recruit'
            }
        }
    }
})
```

## Import Items

* This method allows for any resource to insert item data into the shared file for the core. That means that you can make a resource, and on load, make those items available for use. This can be accomplished through one the ways shown below. Utilizing the function requires importing the core but using the export does not

### RSGCore.Functions.AddItem

```
RSGCore.Functions.AddItem(itemName --[[string]], item --[[table]])

-- Example
RSGCore.Functions.AddItem('water', {
    name = 'water',
    label = 'Water',
    weight = 100,
    type = 'item',
    image = 'water.png',
    unique = false,
    useable = true,
    shouldClose = true,
    description = 'For all the thirsty out there'
})
```

### exports\['rsg-core']:AddItem

```
exports['rsg-core']:AddItem(itemName --[[string]], item --[[table]])

-- Example
exports['rsg-core']:AddItem('water', {
    name = 'water',
    label = 'Drinkable Water',
    weight = 10,
    type = 'item',
    image = 'water.png',
    unique = false,
    useable = true,
    shouldClose = true,
    description = 'For all the thirsty out there'
})
```

###
