### Define and Filter Horse Catalog in Lua Source: https://context7.com/rexshack-redm/rsg-horses/llms.txt Defines a dataset of HorseSettings with coordinates, models, prices, and stable IDs. Includes a usage example that filters horses by the 'valentine' stable to produce a subset for display or processing. ```Lua -- shared/horse_settings.lua local HorseSettings = { { horsecoords = vector4(-357.77, 771.73, 116.52, 5.00), horsemodel = 'a_c_horse_dutchwarmblood_chocolateroan', horseprice = 250, horsename = 'Chocolate Dutch Warmblood', stableid = 'valentine' }, { horsecoords = vector4(-362.45, 771.06, 116.53, 5.00), horsemodel = 'a_c_horse_dutchwarmblood_sootybuckskin', horseprice = 250, horsename = 'Sooty Dutch Warmblood', stableid = 'valentine' }, { horsecoords = vector4(-368.03, 770.17, 116.53, 5.00), horsemodel = 'a_c_horse_kentuckysaddle_silverbay', horseprice = 50, horsename = 'Silver Bay Kentucky Saddler', stableid = 'valentine' }, { horsecoords = vector4(-377.73, 769.48, 116.3, 5.00), horsemodel = 'a_c_horse_morgan_bay', horseprice = 55, horsename = 'Morgan Bay', stableid = 'valentine' } } return HorseSettings -- Usage: Filter horses by stable local valentineHorses = {} for k, v in pairs(HorseSettings) do if v.stableid == 'valentine' then table.insert(valentineHorses, v) end end ``` -------------------------------- ### Export horse status functions for other resources Source: https://context7.com/rexshack-redm/rsg-horses/llms.txt Provides exported callbacks that other resources can call to retrieve the horse's level, bonding level, and active entity. Includes a usage example demonstrating how to call the exports and react to the returned data. No external dependencies beyond the RSG export system. ```Lua exports('CheckHorseLevel', function() return horseLevel end) exports('CheckHorseBondingLevel', function() return bondingLevel end) exports('CheckActiveHorse', function() if DoesEntityExist(horsePed) then return horsePed end return nil end) -- Usage example local horseLevel = exports['rsg-horses']:CheckHorseLevel() local bondingLevel = exports['rsg-horses']:CheckHorseBondingLevel() local horsePed = exports['rsg-horses']:CheckActiveHorse() if horsePed and horseLevel >= 5 then print('Player has a high-level horse!') end ``` -------------------------------- ### Configure stable shop inventory and register shop event Source: https://context7.com/rexshack-redm/rsg-horses/llms.txt Sets up a list of purchasable stable items and registers a server event that builds the shop payload for the rsg-inventory system. Handles player retrieval, item formatting, and opens the shop UI. Requires the RSGCore player object and the inventory export. ```Lua Config.horsesShopItems = { { name = 'horse_brush', amount = 50, price = 5 }, { name = 'horse_lantern', amount = 50, price = 10 }, { name = 'sugarcube', amount = 50, price = 1 }, } Config.PersistStock = false RegisterServerEvent('rsg-horses:server:openShop', function(stableid) local src = source local Player = RSGCore.Functions.GetPlayer(src) local shopItems = {} for k, v in pairs(Config.horsesShopItems) do shopItems[#shopItems + 1] = { name = v.name, price = v.price, amount = v.amount, info = {}, type = 'item', slot = k } end exports['rsg-inventory']:OpenShop(src, shopItems) end) ``` -------------------------------- ### Spawn Horse with Components in Lua Source: https://context7.com/rexshack-redm/rsg-horses/llms.txt Loads the active horse from the server, applies saved components and gender, then spawns the horse in the world. It sets up the horse's stats, blip, ownership, and optional auto-mount, using server data and various game natives. Inputs: server-provided horse data; Outputs: a spawned and configured horse entity with prompts. ```Lua function SpawnHorse()\n RSGCore.Functions.TriggerCallback('rsg-horses:server:GetActiveHorse', function(result)\n if not result then\n lib.notify({title = 'No active horse', type = 'error', duration = 5000})\n return\n end\n\n local horseModel = result.horse\n local horseName = result.name\n local components = json.decode(result.components or '{}')\n horsexp = result.horsexp or 0\n horsegender = result.gender\n\n -- Load horse model\n local modelHash = GetHashKey(horseModel)\n RequestModel(modelHash)\n while not HasModelLoaded(modelHash) do\n Wait(100)\n end\n\n -- Calculate spawn position\n local playerCoords = GetEntityCoords(cache.ped)\n local spawnCoords = GetOffsetFromEntityInWorldCoords(cache.ped, 0.0, 3.0, 0.0)\n\n if Config.SpawnOnRoadOnly then\n local roadFound, roadCoords = GetClosestVehicleNodeWithHeading(\n spawnCoords.x, spawnCoords.y, spawnCoords.z,\n 1, 3.0, 0\n )\n if roadFound then\n spawnCoords = roadCoords\n end\n end\n\n -- Spawn horse entity\n horsePed = CreatePed(modelHash, spawnCoords.x, spawnCoords.y, spawnCoords.z, 0.0, true, true, true, true)\n\n -- Wait for entity to be networked\n while not DoesEntityExist(horsePed) do\n Wait(10)\n end\n\n SetEntityAsMissionEntity(horsePed, true, true)\n SetModelAsNoLongerNeeded(modelHash)\n\n -- Apply gender\n if horsegender == 'male' then\n Citizen.InvokeNative(0x5653AB26C82938CF, horsePed, 41611, 1.0) -- Male\n else\n Citizen.InvokeNative(0x5653AB26C82938CF, horsePed, 41612, 1.0) -- Female\n end\n\n -- Apply saved components\n for category, hash in pairs(components) do\n if hash ~= 0 then\n local categoryHash = Config.ComponentHash[category]\n if categoryHash then\n Citizen.InvokeNative(0xD3A7B003ED343FD9, horsePed, hash, categoryHash, true, true)\n end\n end\n end\n\n -- Set horse stats based on level\n horseLevel = CalculateHorseLevel(horsexp)\n SetHorseStats(horsePed, horseLevel)\n\n -- Set bonding level\n bondingLevel = CalculateBondingLevel(horsexp)\n Citizen.InvokeNative(0x09A59688C26D88DF, horsePed, 7, bondingLevel)\n\n -- Create blip\n horseBlip = Citizen.InvokeNative(0x23f74c2fda6e7c61, -1749618580, horsePed)\n SetBlipSprite(horseBlip, GetHashKey(Config.Blip.blipSprite), true)\n\n -- Set ownership\n Citizen.InvokeNative(0x931B241409216C1F, horsePed, cache.ped, true)\n\n horseSpawned = true\n\n -- Auto-mount if configured\n if Config.Automount then\n TaskMountAnimal(cache.ped, horsePed, -1, -1, 2.0, 1, 0, 0)\n end\n\n -- Setup prompts\n SetupHorsePrompts()\n end)\nend ``` -------------------------------- ### General horse system configuration settings Source: https://context7.com/rexshack-redm/rsg-horses/llms.txt Defines feature toggles, timing parameters, inventory defaults, keybinds, and bonding requirements for the horse system. These values drive core behavior such as auto‑mount, death grace periods, and trick XP thresholds. Adjust as needed to fit server preferences. ```Lua Config.EnableTarget = true Config.Automount = false Config.SpawnOnRoadOnly = false Config.AllowTwoPlayersRide = false Config.StoreFleedHorse = false Config.ObjectAction = true Config.DeathGracePeriod = 60000 Config.CheckCycle = 60 Config.StarterHorseDieAge = 7 Config.HorseDieAge = 90 Config.HorseInvWeight = 15000 Config.HorseInvSlots = 20 Config.HorseInvKey = 0x760A9C6F Config.KeyBind = 'J' Config.TrickXp = { Lay = 1000, Play = 2000 } Config.MaxBondingLevel = 5000 ``` -------------------------------- ### Define Component Hashes, Pricing, and Apply Components in Lua Source: https://context7.com/rexshack-redm/rsg-horses/llms.txt Declares component category hashes and their pricing, provides an ApplyComponent function to attach a component to a horse, and demonstrates usage with a saddle component. Relies on game engine natives for applying components. ```Lua -- Component category hashes (used by game engine) Config.ComponentHash = { Blankets = 0x17CEB41A, Saddles = 0xBAA7E618, Horns = 0x05447332, Saddlebags = 0x80451C25, Stirrups = 0xDA6DADCA, Bedrolls = 0xEFB31921, Tails = 0xA63CAE10, Manes = 0xAA0217AB, Masks = 0xD3500E5D, Mustaches = 0x30DEFDDF, } -- Component pricing Config.PriceComponent = { Blankets = 5, Saddles = 2, Horns = 10, Saddlebags = 3, Stirrups = 4, Bedrolls = 5, Tails = 4, Manes = 3, Masks = 3, Mustaches = 2, } -- Apply component to horse function ApplyComponent(horsePed, componentHash, categoryHash) Citizen.InvokeNative( 0xD3A7B003ED343FD9, -- Native: Apply component to ped horsePed, componentHash, categoryHash, true, -- p3 true -- p4 ) end -- Example usage: local saddleHash = 0x12345678 -- From horse_comp.lua local saddleCategoryHash = Config.ComponentHash.Saddles ApplyComponent(horsePed, saddleHash, saddleCategoryHash) ``` -------------------------------- ### Handle horse purchase in server (Lua) Source: https://context7.com/rexshack-redm/rsg-horses/llms.txt Purchases a horse from a stable by validating funds, generating a unique horse ID, and inserting a record into the player_horses table. Inputs include model, stable, horsename, and gender; outputs include deducting money and notifying the client. Dependencies include RSG-Core, ox_lib, and MySQL. ```lua RegisterServerEvent('rsg-horses:server:BuyHorse', function(model, stable, horsename, gender) local src = source local Player = RSGCore.Functions.GetPlayer(src) if not Player then return end -- Find horse info from catalog local horseInfo = nil for k,v in pairs(HorseSettings) do if v.horsemodel == model then horseInfo = v break end end if not horseInfo then warn(('Unexpected horse model %s'):format(model)) return end -- Validate player has sufficient cash local price = horseInfo.horseprice if (Player.PlayerData.money.cash < price) then TriggerClientEvent('ox_lib:notify', src, { title = 'Insufficient funds', type = 'error', duration = 5000 }) return end -- Generate unique horse ID and insert into database local horseid = GenerateHorseid() MySQL.insert('INSERT INTO player_horses(stable, citizenid, horseid, name, horse, gender, active, born) VALUES(@stable, @citizenid, @horseid, @name, @horse, @gender, @active, @born)', { ['@stable'] = stable, ['@citizenid'] = Player.PlayerData.citizenid, ['@horseid'] = horseid, ['@name'] = horsename, ['@horse'] = model, ['@gender'] = gender, ['@active'] = false, ['@born'] = os.time() }) -- Deduct payment Player.Functions.RemoveMoney('cash', price) TriggerClientEvent('ox_lib:notify', src, { title = 'You now own this horse', type = 'success', duration = 5000 }) end) ``` -------------------------------- ### Define Stable Locations in Lua Source: https://context7.com/rexshack-redm/rsg-horses/llms.txt Defines multiple stable entries with coordinates, NPC models, and customization zones. Demonstrates how to access stable settings in code. Dependencies: vector3, vector4, vec4 helpers. Inputs/Outputs: a list of stable configurations used by the horse system. ```Lua Config.StableSettings = {\n {\n stableid = 'valentine',\n coords = vector3(-365.2, 791.94, 116.18),\n npcmodel = `u_m_m_bwmstablehand_01`,\n npccoords = vector4(-365.2, 791.94, 116.18, 180.9),\n horsecustom = vec4(-388.5212, 784.0562, 115.8154, 150.4135),\n showblip = true\n },\n {\n stableid = 'blackwater',\n coords = vector3(-876.85, -1365.55, 43.53),\n npcmodel = `u_m_m_bwmstablehand_01`,\n npccoords = vector4(-876.85, -1365.55, 43.53, 275.38),\n horsecustom = vec4(-865.1928, -1366.3270, 43.5440, 86.8795),\n showblip = true\n },\n {\n stableid = 'strawberry',\n coords = vector3(-1817.1, -568.64, 155.98),\n npcmodel = `u_m_m_bwmstablehand_01`,\n npccoords = vector4(-1817.1, -568.64, 155.98, 254.85),\n horsecustom = vec4(-1827.2969, -577.0493, 155.9565, 215.5404),\n showblip = true\n }\n}\n\n-- Access in code:\nfor k, v in pairs(Config.StableSettings) do\n local stableId = v.stableid -- 'valentine', 'blackwater', etc.\n local coords = v.coords -- Stable entrance position\n local npcCoords = v.npccoords -- NPC spawn position and heading\n local customZone = v.horsecustom -- Customization camera position\nend ``` -------------------------------- ### Configure XP Thresholds, Level System, and Stats in Lua Source: https://context7.com/rexshack-redm/rsg-horses/llms.txt Sets level-based inventory capacities and horse stats, provides a function to determine a horse's level from XP, and applies level-based stat values. Dependencies include in-game SetAttribute functions and Citizen.InvokeNative for max level empowerment. ```Lua -- Level-based inventory capacity Config.Level1InvWeight = 2000 Config.Level1InvSlots = 2 Config.Level5InvWeight = 9000 Config.Level5InvSlots = 10 Config.Level10InvWeight = 15000 Config.Level10InvSlots = 20 -- Level-based horse stats (health, stamina, speed, acceleration) Config.Level1 = 100 Config.Level2 = 200 Config.Level3 = 300 Config.Level4 = 400 Config.Level5 = 500 Config.Level6 = 900 Config.Level7 = 1000 Config.Level8 = 1500 Config.Level9 = 1750 Config.Level10 = 2000 -- Calculate level from XP function CalculateHorseLevel(xp) if xp >= Config.Level10 then return 10 elseif xp >= Config.Level9 then return 9 elseif xp >= Config.Level8 then return 8 elseif xp >= Config.Level7 then return 7 elseif xp >= Config.Level6 then return 6 elseif xp >= Config.Level5 then return 5 elseif xp >= Config.Level4 then return 4 elseif xp >= Config.Level3 then return 3 elseif xp >= Config.Level2 then return 2 else return 1 end end -- Set stats on horse entity function SetHorseStats(horsePed, level) local statValue = Config['Level' .. level] -- Health SetAttributeBaseRank(horsePed, 0, statValue) SetAttributeCoreValue(horsePed, 0, 100) -- Stamina SetAttributeBaseRank(horsePed, 1, statValue) SetAttributeCoreValue(horsePed, 1, 100) -- Speed SetAttributeBaseRank(horsePed, 4, statValue) -- Acceleration SetAttributeBaseRank(horsePed, 5, statValue) -- Overpower at max level if level == 10 then Citizen.InvokeNative(0xF6A7B003ED343FD9, horsePed, 0, 5000.0) end end ``` -------------------------------- ### Horse Shop and Stable Configuration (Lua) Source: https://github.com/rexshack-redm/rsg-horses/blob/main/README.md This configuration defines items available in the stable shop, including their names, prices, and experience values. It also specifies the locations and blip settings for various stables within the game world. ```lua -- shared/config.lua Config.horsesShopItems = { { name = "horse_morgan_flaxchestnut", label = "Morgan Flax Chestnut", price = 50, xp = 0 }, { name = "horse_turkoman_gold", label = "Turkoman Gold", price = 300, xp = 10 }, } Config.Stables = { { name = "valentine", coords = vector3(-366.48, 786.45, 116.15), showblip = true, blipsprite = "blip_shop_stable", blipscale = 0.25, }, } ``` -------------------------------- ### Create player_horses table using SQL Source: https://context7.com/rexshack-redm/rsg-horses/llms.txt Creates the persistent player_horses table used to store horse ownership, attributes, and components. Depends on MySQL and utf8mb4 charset. Inputs are none; outputs are a new table schema in the database. Limitations include default values and data types chosen for RSG-Horses integration. ```sql CREATE TABLE IF NOT EXISTS `player_horses` ( `id` int(11) NOT NULL AUTO_INCREMENT, `stable` varchar(50) NOT NULL, `citizenid` varchar(50) NOT NULL, `horseid` varchar(11) NOT NULL, `name` varchar(255) NOT NULL, `horse` varchar(50) DEFAULT NULL, `dirt` int(11) DEFAULT 0, `horsexp` int(11) DEFAULT 0, `components` LONGTEXT NOT NULL DEFAULT '{}', `gender` varchar(11) NOT NULL, `wild` varchar(11) DEFAULT NULL, `active` tinyint(4) DEFAULT 0, `born` int(11) NOT NULL DEFAULT 0, PRIMARY KEY (`id`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4; ``` -------------------------------- ### Server: Horse Death System (Lua) Source: https://context7.com/rexshack-redm/rsg-horses/llms.txt Implements an automated system that periodically checks horses in the 'player_horses' table for lifespans and removes them if they have exceeded their age limit. It distinguishes between starter horses (7-day lifespan) and regular horses (90-day lifespan) and sends in-game notifications upon death. ```lua -- Runs every Config.CheckCycle minutes (default: 60) CreateThread(function() while true do Wait(Config.CheckCycle * 60000) local result = MySQL.query.await('SELECT * FROM player_horses', {}) if result[1] then for i = 1, #result do local horseData = result[i] local currentTime = os.time() local bornTime = horseData.born local daysPassed = (currentTime - bornTime) / 86400 -- Check starter horses (7 day lifespan) if horseData.horsexp == 0 and daysPassed >= Config.StarterHorseDieAge then MySQL.query.await('DELETE FROM player_horses WHERE id = ?', {horseData.id}) -- Send in-game telegram notification exports['rsg-telegram']:CreateTelegram({ name = horseData.name, text = 'Your horse has died of old age', citizenid = horseData.citizenid }) end -- Check regular horses (90 day lifespan) if horseData.horsexp > 0 and daysPassed >= Config.HorseDieAge then MySQL.query.await('DELETE FROM player_horses WHERE id = ?', {horseData.id}) exports['rsg-telegram']:CreateTelegram({ name = horseData.name, text = 'Your horse has died of old age', citizenid = horseData.citizenid }) end end end end end) ``` -------------------------------- ### Save Horse Customization Components Source: https://context7.com/rexshack-redm/rsg-horses/llms.txt Handles server-side saving of horse customization components to database with payment processing. Validates player funds before applying customizations and charges the player accordingly. Uses JSON encoding for component data and MySQL for database updates. ```lua RegisterServerEvent('rsg-horses:server:SaveComponents', function(price, components, id) local src = source local Player = RSGCore.Functions.GetPlayer(src) if Player.PlayerData.money.cash < price then TriggerClientEvent('ox_lib:notify', src, { title = 'Insufficient funds for customization', type = 'error', duration = 5000 }) return end -- Encode components as JSON local componentsJson = json.encode(components) -- Update database MySQL.update('UPDATE player_horses SET components = ? WHERE id = ? AND citizenid = ?', { componentsJson, id, Player.PlayerData.citizenid } ) -- Charge player Player.Functions.RemoveMoney('cash', price) TriggerClientEvent('ox_lib:notify', src, { title = string.format('Customization applied for $%d', price), type = 'success', duration = 5000 }) end) ``` -------------------------------- ### Configure and apply horse feed effects Source: https://context7.com/rexshack-redm/rsg-horses/llms.txt Defines the feed item table with health and stamina values and implements the FeedHorse function that updates horse attributes and optionally applies a medicine native. Requires the Config and native functions from the RSG framework. Handles missing data and ensures attribute caps. ```Lua Config.HorseFeed = { ['carrot'] = { health = 10, stamina = 10, ismedicine = false }, ['apple'] = { health = 15, stamina = 15, ismedicine = false }, ['sugarcube'] = { health = 25, stamina = 25, ismedicine = false }, ['horse_stimulant'] = { health = 100, stamina = 100, ismedicine = true, medicineHash = 'consumable_horse_stimulant' }, } function FeedHorse(horsePed, itemName) local feedData = Config.HorseFeed[itemName] if not feedData or not DoesEntityExist(horsePed) then return end local currentHealth = GetAttributeCoreValue(horsePed, 0) local currentStamina = GetAttributeCoreValue(horsePed, 1) SetAttributeCoreValue(horsePed, 0, math.min(100, currentHealth + feedData.health)) SetAttributeCoreValue(horsePed, 1, math.min(100, currentStamina + feedData.stamina)) if feedData.ismedicine then local hash = GetHashKey(feedData.medicineHash) Citizen.InvokeNative(0x06DB26EC0DF5F1F1, horsePed, hash, true) end TaskAnimalInteraction(cache.ped, horsePed, GetHashKey('INTERACTION_FEED'), 0, 0) end ``` -------------------------------- ### Server: Activate Horse (Lua) Source: https://context7.com/rexshack-redm/rsg-horses/llms.txt Sets a specified horse as active (spawnable) for a player and deactivates any other currently active horses owned by that player. It requires player identification and interacts with the MySQL database to update the 'active' status of horses. ```lua RegisterServerEvent('rsg-horses:server:SetHoresActive', function(id) local src = source local Player = RSGCore.Functions.GetPlayer(src) -- Find currently active horse local activehorse = MySQL.scalar.await( 'SELECT id FROM player_horses WHERE citizenid = ? AND active = ?', {Player.PlayerData.citizenid, true} ) -- Deactivate current active horse MySQL.update('UPDATE player_horses SET active = ? WHERE id = ? AND citizenid = ?', { false, activehorse, Player.PlayerData.citizenid } ) -- Activate selected horse MySQL.update('UPDATE player_horses SET active = ? WHERE id = ? AND citizenid = ?', { true, id, Player.PlayerData.citizenid } ) end) -- Client trigger example: TriggerServerEvent('rsg-horses:server:SetHoresActive', horseDbId) ``` -------------------------------- ### Register Horse Reviver Item Source: https://context7.com/rexshack-redm/rsg-horses/llms.txt Registers a usable horse reviver item that checks for an active horse and triggers client-side revival. Queries player's active horse from database and notifies player if no horse is found. Requires MySQL database and ox_lib for notifications. ```lua RSGCore.Functions.CreateUseableItem('horse_reviver', function(source, item) local src = source local Player = RSGCore.Functions.GetPlayer(src) if not Player then return end local cid = Player.PlayerData.citizenid local result = MySQL.query.await( 'SELECT * FROM player_horses WHERE citizenid=@citizenid AND active=@active', { ['@citizenid'] = cid, ['@active'] = 1 } ) if not result[1] then TriggerClientEvent('ox_lib:notify', src, { title = 'No active horse found', type = 'error', duration = 5000 }) return end TriggerClientEvent('rsg-horses:client:revivehorse', src, item, result[1]) end) ``` -------------------------------- ### Retrieve all horses for a player (Lua) Source: https://context7.com/rexshack-redm/rsg-horses/llms.txt Fetches all horses owned by a player from the database and passes them to the callback. Inputs include the player's citizenid; outputs are the horses array or nil. Dependencies include RSG-Core and MySQL. ```lua RSGCore.Functions.CreateCallback('rsg-horses:server:GetAllHorses', function(source, cb) local src = source local Player = RSGCore.Functions.GetPlayer(src) local horses = MySQL.query.await('SELECT * FROM player_horses WHERE citizenid=@citizenid', { ['@citizenid'] = Player.PlayerData.citizenid }) if horses[1] ~= nil then cb(horses) else cb(nil) end end) -- Client usage example: RSGCore.Functions.TriggerCallback('rsg-horses:server:GetAllHorses', function(horses) if horses then for i = 1, #horses do local horse = horses[i] print(string.format("Horse: %s (ID: %s) at %s", horse.name, horse.horseid, horse.stable )) end end end) ``` -------------------------------- ### Apply Horse Feed Effects Source: https://context7.com/rexshack-redm/rsg-horses/llms.txt Handles client-side application of feed effects on horses, including health/stamina boosts and medicine application. Uses native functions to modify horse attributes and applies medicine effects when configured. Requires active horse entity and valid feed configuration data. ```lua -- Client receives and applies effects: RegisterNetEvent('rsg-horses:client:playerfeedhorse', function(itemName) local feedConfig = Config.HorseFeed[itemName] if feedConfig and DoesEntityExist(horsePed) then -- Apply health/stamina boost local currentHealth = GetAttributeCoreValue(horsePed, 0) local currentStamina = GetAttributeCoreValue(horsePed, 1) SetAttributeCoreValue(horsePed, 0, currentHealth + feedConfig.health) SetAttributeCoreValue(horsePed, 1, currentStamina + feedConfig.stamina) if feedConfig.ismedicine then -- Apply medicine native local medicineHash = GetHashKey(feedConfig.medicineHash or 'consumable_horse_stimulant') Citizen.InvokeNative(0x06DB26EC0DF5F1F, horsePed, medicineHash) end end end) ``` -------------------------------- ### Register Horse Feed Items Source: https://context7.com/rexshack-redm/rsg-horses/llms.txt Registers usable items that restore horse health and stamina. Items include carrot, sugar cube, and horse stimulant. Each item triggers a client event to apply the feed effect. Requires RSGCore framework and configured feed data in Config.HorseFeed. ```lua -- Carrot item RSGCore.Functions.CreateUseableItem('carrot', function(source, item) local Player = RSGCore.Functions.GetPlayer(source) if Player.Functions.RemoveItem(item.name, 1, item.slot) then TriggerClientEvent('rsg-horses:client:playerfeedhorse', source, item.name) end end) -- Sugar cube item RSGCore.Functions.CreateUseableItem('sugarcube', function(source, item) local Player = RSGCore.Functions.GetPlayer(source) if Player.Functions.RemoveItem(item.name, 1, item.slot) then TriggerClientEvent('rsg-horses:client:playerfeedhorse', source, item.name) end end) -- Horse stimulant (medicine) RSGCore.Functions.CreateUseableItem('horse_stimulant', function(source, item) local Player = RSGCore.Functions.GetPlayer(source) if Player.Functions.RemoveItem(item.name, 1, item.slot) then TriggerClientEvent('rsg-horses:client:playerfeedhorse', source, item.name) end end) ``` -------------------------------- ### Handle Horse Revival Source: https://context7.com/rexshack-redm/rsg-horses/llms.txt Handles client-side horse revival process, including native revival calls and health restoration. Checks for existing dead horse entity before attempting revival. Notifies player upon successful revival and triggers server event to handle item consumption. ```lua -- Client revive handler: RegisterNetEvent('rsg-horses:client:revivehorse', function(item, horseData) if DoesEntityExist(horsePed) and IsEntityDead(horsePed) then -- Revive the horse Citizen.InvokeNative(0xD3A8E0C46A78FACC, horsePed) -- ReviveInjuredPed SetEntityHealth(horsePed, 600) IsBeingRevived = true TriggerServerEvent('rsg-horses:server:revivehorse', item) lib.notify({ title = 'Horse revived successfully', type = 'success', duration = 5000 }) end end) ``` -------------------------------- ### Server: Rename Horse (Lua) Source: https://context7.com/rexshack-redm/rsg-horses/llms.txt Allows a player to rename their currently active horse. This involves updating the 'name' field in the 'player_horses' table in the MySQL database and providing feedback to the player via notifications. ```lua RegisterServerEvent('rsg-horses:renameHorse', function(name) local src = source local Player = RSGCore.Functions.GetPlayer(src) local newName = MySQL.query.await( 'UPDATE player_horses SET name = ? WHERE citizenid = ? AND active = ?', {name, Player.PlayerData.citizenid, 1} ) if newName == nil then TriggerClientEvent('ox_lib:notify', src, { title = 'Name change failed', type = 'error', duration = 5000 }) return end TriggerClientEvent('ox_lib:notify', src, { title = 'Horse renamed successfully', type = 'success', duration = 5000 }) end) -- Client command usage: RSGCore.Commands.Add('sethorsename', 'Rename your active horse', {}, false, function(source) -- Show input dialog, then trigger event with new name TriggerServerEvent('rsg-horses:renameHorse', newHorseName) end) ``` -------------------------------- ### Server: Store Horse at Stable (Lua) Source: https://context7.com/rexshack-redm/rsg-horses/llms.txt Deactivates a horse and assigns it to a specific stable location. This function updates the horse's 'active' status to false and sets its 'stable' identifier in the MySQL database. ```lua RegisterServerEvent('rsg-horses:server:SetHoresUnActive', function(id, stableid) local src = source local Player = RSGCore.Functions.GetPlayer(src) local activehorse = MySQL.scalar.await( 'SELECT id FROM player_horses WHERE citizenid = ? AND active = ?', {Player.PlayerData.citizenid, false} ) -- Deactivate horse MySQL.update('UPDATE player_horses SET active = ? WHERE id = ? AND citizenid = ?', { false, activehorse, Player.PlayerData.citizenid } ) MySQL.update('UPDATE player_horses SET active = ? WHERE id = ? AND citizenid = ?', { false, id, Player.PlayerData.citizenid } ) -- Update stable location MySQL.update('UPDATE player_horses SET stable = ? WHERE id = ? AND citizenid = ?', { stableid, id, Player.PlayerData.citizenid } ) end) ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.