> For the complete documentation index, see [llms.txt](https://titans-productions.gitbook.io/documentation/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://titans-productions.gitbook.io/documentation/redm/scripts/ranch/development-api/server.md).

# Server

### Exports

API Getter Function

```lua
local RanchAPI = exports.tp_ranch:getAPI()
```

1. Get all ranch data

```lua
--- @return table form.
local Ranches = RanchAPI.GetRanches()
```

2. Get all player owned ranch ids.

```lua
--- @return table form.
--- @param source - requires the online player source id.
local OwnedRanches = RanchAPI.GetPlayerOwnedRanchIds(source)
```

3. Get all player owned ranch data.

```lua
--- @return table form.
--- @param source - requires the online player source id.
local OwnedRanches = RanchAPI.GetPlayerOwnedRanchesData(source)
```

4. Set ranch ownership by player source.

```lua
--- @param ranchId - requires an existing ranch index name.
--- @param source - requires the online player source id.
RanchAPI.SetRanchOwnershipBySource(ranchId, source)
```

5. Set ranch ownership by player identifiers.

```lua
--- @param ranchId - requires an existing ranch index name.
--- @param identifier - requires a player steam hex.
--- @param charidentifier - requires a player character id.
RanchAPI.SetRanchOwnershipByIdentifiers(ranchId, identifier, charidentifier)
```

6. Remove ranch ownership by player identifiers.

```lua
--- @param ranchId - requires an existing ranch index name.
--- @param identifier - requires a player steam hex.
--- @param charidentifier - requires a player character id.
RanchAPI.RemovePlayerRanchOwnershipByIdentifiers(ranchId, identifier, charidentifier)
```

### Events

1. Add feeding capacity for cows and goats.

```lua

-- You don't need to add your own feeding capacity amount, it adds directly from `AddHungerCapacityOnHaybaleDeliver` config option where config_animals is.
--- @param ranchId - requires an existing ranch id.
--- @param amount - a non required parameter, it is used to add your own amount of capacity, if not used, it will use the mentioned option (max value is 1000 = 100% )
TriggerEvent("tp_ranch:server:shared:add_feeding_capacity", ranchId, amount) -- THIS IS A SERVER EVENT
```

2. Add water barrel capacity

```lua
-- You don't need to add your own add_barrel_capacity capacity amount, it adds directly from `Config.WaterSystem.AddBarrelCapacityOnBucketPouring` config option where config_animals is.
--- @param ranchId - requires an existing ranch id.
--- @param amount - a non required parameter, it is used to add your own amount of capacity, if not used, it will use the mentioned option (max value is 1000 = 100% )
TriggerEvent("tp_ranch:server:shared:add_barrel_capacity", ranchId, amount) -- THIS IS A SERVER EVENT
```

3. Add feeding capacity for chickens

```lua

-- You don't need to add your own feeding capacity amount, it adds directly from `Config.AnimalPoop.AddFertilizerValueOnDrop` config option where config_animals is.
--- @param ranchId - requires an existing ranch id.
--- @param amount - a non required parameter, it is used to add your own amount of capacity, if not used, it will use the mentioned option (max value is 1000 = 100% )
TriggerEvent("tp_ranch:server:shared:add_chicken_feeding_capacity", ranchId, amount) -- THIS IS A SERVER EVENT
```

4. Add fertilizer capacity

```lua

-- You don't need to add your own fertilizer capacity amount, it adds directly from `AddProductCapacityCornOnDeliver` config option where config_animals is.
--- @param ranchId - requires an existing ranch id.
--- @param amount - a non required parameter, it is used to add your own amount of capacity, if not used, it will use the mentioned option (max value is 1000 = 100% )
TriggerEvent("tp_ranch:server:fertilizer:add", ranchId, amount) -- THIS IS A SERVER EVENT
```
