# Feeding Horse + Syringe

### 🟦 Client Side

* **Enable or disable** the command and events in the config.
* **Edit** command/event names as you wish.

**Trigger feeding via event:**

```lua
TriggerEvent("Botiv:giveFoodToHorse", [ID])
-- or
TriggerEvent("Botiv:giveFoodToHorse", [ITEM])
```

**Trigger feeding via command:**

```
/feedhorse [ID]      -- Feed with item by numeric ID
/feedhorse [ITEM]    -- Feed with item name
```

***

### 🟧 Server Side

You can use ready-to-go lines from `config_server.lua` for VORP/REDEM.\
Or, integrate like this:

#### VORP Example

```lua
local vorpInventory = exports.vorp_inventory:vorp_inventoryApi()

vorpInventory.RegisterUsableItem("syringe", function(data)
   TriggerClientEvent("Botiv:giveFoodToHorse", data.source, "syringe")
end)

RegisterServerEvent("botiv-FeedHorse:itemUsed")
AddEventHandler("botiv-FeedHorse:itemUsed", function(item, used)
   if used then
      vorpInventory.subItem(source, item, 1)
   end
end)
```

#### RedEM Example

```lua
RegisterServerEvent("RegisterUsableItem:syringe")
AddEventHandler("RegisterUsableItem:syringe", function(source)
   TriggerClientEvent("Botiv:giveFoodToHorse", source, "syringe")
end)

local data = {}
TriggerEvent("redemrp_inventory:getData",function(call)
   data = call
end)

RegisterServerEvent("botiv-FeedHorse:itemUsed")
AddEventHandler("botiv-FeedHorse:itemUsed", function(item, used)
   if used then
      local ItemData = data.getItem(source, item)
      ItemData.RemoveItem(1)
   end
end)
```

***

### ⚙️ Configuration Example (`config.lua`)

```lua
Config = {
    enable_command      = true,
    botiv_feed_cmd      = "feedhorse",          -- Command name (/feedhorse)
    enable_client_side  = true,                 -- Enable client call function
    bt_c_function       = 'Botiv:giveFoodToHorse', -- Event name (editable)
    need_ride_horse     = "You must be on or near a horse to use this item.",
    no_aliment          = "This food does not exist",
    item_used           = "You gave %s to the horse.",
    HorseFood = {
        -- ... (many foods possible)
        [42] = {
            name = "Horse Poison",
            object = "s_inv_bulrush01cx",
            Heal = -200, Stamina = -200,
            healOverpower = 0, staminaOverpower = 0,
            timeEffect = 30,
            item = "horsepoison"
        },
    }
}
```

* `timeEffect`: Duration of effect (progressive)
* `Heal`/`Stamina`: Positive or negative values allowed
* `healOverpower`/`staminaOverpower`: Overpower when horse stats are maxed
* `object`: For syringe animation, use `"p_cs_syringe01x"`
* **Item objects**: see [Mooshe RDR2 Models](https://rdr2.mooshe.tv/)

***

### 📌 Notes

* You can freely modify command/event names to fit your server.
* Feeding logic supports both item names and numeric IDs.
* System handles progressive healing/stamina and can apply negative effects (poison).
* Add or remove foods in the `HorseFood` table.
