All resources

rsg-stables — Developer Docs#

Technical reference for rsg-stables, the horse and stables resource for the RSG Framework (rsg-core). It covers the architecture, database, configuration, every export/event/callback, the data formats, the server-side validation rules and how to extend the resource.


Overview#

Resourcersg-stables
FrameworkRSG Framework (rsg-core)
Dependenciesrsg-core, rsg-target, oxmysql, rsg-inventory
Not requiredox_lib (callbacks, notifications, locales and dialogs run on rsg-core and the resource's own NUI)
Lua5.4 (lua54 'yes')
UISingle NUI page (html/index.html) with app.js, training.js, actions.js, horsecard.js
Languagesen, de, el, es, fr, ja, nl, pl, pt-br, ro, ru

Architecture#

rsg-stables/
├── fxmanifest.lua
├── shared/config.lua          # every setting, stables, breeds, tack, races
├── shared/foal.lua            # foal growth rules (FoalAdultSeconds, GetFoalState) used by client and server
├── server/
│   ├── server.lua             # DB install, horse CRUD, sessions, needs, breeding, selling, fence, races
│   ├── training.lua           # training XP, paid sessions, ride-XP ticks
│   └── versionchecker.lua     # GitHub version check
├── client/
│   ├── dataview.lua           # DataView helper for natives that need structs
│   ├── coat.lua               # coat tint application (metaped tints)
│   ├── client.lua             # stablehand NPCs, menus, spawn/whistle/store, needs, items, horse card
│   ├── horseinfo.lua          # native animal info card (Q prompt, SHOP_BROWSING UI app) for horses
│   ├── wildhorse.lua          # listens for EVENT_HORSE_BROKEN, registers broken wild horses
│   ├── foal.lua               # foal scale growth + ride block
│   ├── training.lua           # training NUI, attribute bonus ranks, ride ticks
│   ├── fence.lua              # horse fence NPCs
│   ├── actions.lua            # Horse Actions panel + /horse<action> commands
│   ├── spook.lua              # gunfire / explosion spooking
│   ├── salvage.lua            # search the saddlebags of a dead horse in the field
│   └── races.lua              # checkpoint races, HUD, /raceroute builder
├── html/                      # NUI
├── locales/*.json
└── installation/install.sql   # optional manual schema

Server is authoritative. Hunger, thirst, bonding, shoe wear, training XP and race timing are tracked in server-side sessions; the client only reports and renders. The client-side CARE_COOLDOWN is UX only, the server enforces the real limit.

Callback style. The server registers return-style handlers through a small wrapper over RSGCore.Functions.CreateCallback:

local function registerCallback(name, fn)
    RSGCore.Functions.CreateCallback(name, function(source, cb, ...) cb(fn(source, ...)) end)
end

registerCallback('rsg-stables:server:renameHorse', function(source, horseId, newName)
    -- ...
    return true            -- or: return false, locale('some_error')
end)

Callers use the rsg-core client callback API:

RSGCore.Functions.TriggerCallback('rsg-stables:server:renameHorse', function(ok, err)
    if not ok then
        RSGCore.Functions.Notify({ description = err, type = 'error' })
    end
end, horseId, 'Dusty')

Most state-changing callbacks return success:boolean, payload_or_error_message.

Concurrency. Mutating callbacks wrap their work in withLock('citizen:<citizenid>', fn) (and withLock('stable:<name>', fn) where capacity matters) so rapid duplicate requests cannot double-spend or double-insert.


Installation & database#

  1. Ensure the dependencies start before the resource:

    ensure oxmysql
    ensure rsg-core
    ensure rsg-target
    ensure rsg-inventory
    ensure rsg-stables
  2. Database is automatic. On start the resource runs CREATE TABLE IF NOT EXISTS for every table (the SCHEMA list in server/server.lua) and adds any missing columns to rsg_stables_horses (ALTER TABLE ... ADD COLUMN, wrapped in pcall, so it is safe to restart repeatedly and upgrades older installs).

  3. Manual install is optional. Import installation/install.sql yourself if you prefer — it is the same schema.

  4. Add the items below to your RSG shared items, e.g. horse_apple, horse_carrot, horse_brush, horse_stimulant, horse_medicine, horse_reviver, horse_lantern, fullbucket.

  5. Set the language in server.cfg:

    setr rsg:locale "en"

Tables#

rsg_stables_horses — one row per owned horse

ColumnTypeNotes
idINT PKHorse id used by every callback
citizenidVARCHAR(50)Owner (indexed)
stableVARCHAR(50)Config.Stables[].name where it is kept (indexed)
modelVARCHAR(100)Model hash as stored from Config.Breeds[].model
breed_labelVARCHAR(100)Display label
genderVARCHAR(6)male / female
breed_cooldownBIGINTms epoch; parent cannot breed again before this
died_of_ageTINYINT1 when the horse reached lifespanDays
nameVARCHAR(50)Default Unnamed Horse
outfitINTIndex into the breed's outfits
tackTEXTJSON { category = hash } — see Tack
shoe_wearFLOATSeconds of riding worn off the current shoes
coatTEXTJSON coat tints — see Coat
health stamina hunger thirst bondingFLOATCores / needs, 0–100
trainingTEXTJSON XP per stat — see Training data
speed accel handling maxhealthINTBase stats (default 50)
alive insured activeTINYINTactive = 1 means the horse is currently out
bornTINYINT1 for horses born through breeding (these grow up as foals, see Foal growth); added automatically to older databases
pos_x pos_y pos_z pos_hFLOATLast saved position while out (persisted across relog)
created_atTIMESTAMPAge is DATEDIFF(NOW(), created_at) (age_days) and TIMESTAMPDIFF(SECOND, ...) (age_seconds, used for smooth foal growth)

rsg_stables_breeding — id, citizenid, stable, parent_a, parent_b, ready_at (ms epoch), collected, created_at.

rsg_stables_races — personal bests, PK (citizenid, race): rider, horse, best_ms, updated_at; index on (race, best_ms) for leaderboards.


Configuration reference#

All settings live in shared/config.lua. The tables below list the keys; defaults shown are the shipped values.

General#

KeyDefaultDescription
Config.MaxOwnedHorses8Horses one player can own in total
Config.MaxHorsesPerStable20Horses one player can keep at a single stable
Config.RenameCost / InsuranceCost / ReviveCost15 / 25 / 40Service prices
Config.StoreDistance8.0Max distance from the stable to store a horse
Config.PaymentAccount'cash''cash' or 'bank' for every payment and payout
Config.WhistleAnim'WHISTLEHORSESHORT'Whistle sound/animation, false to disable
Config.WhistleStopDistance / WhistleSpawnDistance / WhistleTeleportDistance1.0 / 12.0 / 60.0Where a whistled horse stops, is placed, or teleports from
Config.AllowTwoPlayersRidefalseAllow a second rider

Active horse persistence — Config.ActiveHorse#

saveInterval, minMoveToSave, recallMaxDistance, respawnDistance, minSpawnDistance, notifyOnLogin. While a horse is out its position is saved to pos_*; after a relog or resource restart the horse stays "out" and a whistle recalls it.

Needs, feeding and care#

Config.HorseFeedItems  = { { item = 'horse_apple',  label = 'Horse Apple',  health = 10, stamina = 10, hunger = 15 } }
Config.HorseDrinkItems = { { item = 'fullbucket', label = 'Water Bucket', thirst = 50, stamina = 10 } }

Config.HorseNeeds = {
    enabled = true, decayInterval = 60000,
    hungerDecayPerTick = 1, thirstDecayPerTick = 1,
    criticalThreshold = 15, healthDrainPerTick = 1,   -- starving/dehydrated -> damage
    wellFedThreshold = 50,  healthRegenPerTick = 1,   -- fed and watered -> slow heal
}
BlockPurpose
Config.HorseStimulantStamina/speed boost item (duration, speedMultiplier, staminaFloor, allowReuse)
Config.HorseMedicineHeals healPercent of max health, cooldown seconds between doses
Config.HorseReviverField revive within window seconds, revivedHealth, bondingLoss
Config.HorseLanternToggle a saddle lantern (item, hash, category)
Config.HorseBrushItem, HorseBrushDistance, HorseBrushMountedBrushing
Config.HorseBondingBonding gain per feed / water / brush
Config.HorseHitchHitching-post props; natural needs are skipped while hitched
Config.HorseNaturalDrinkRivers / lakes / troughs (thirstThreshold, drinkDuration, cooldown, troughModels)
Config.HorseNaturalGrazeHay near the player (hungerThreshold, searchRadius, hayModels)
Config.HorseshoesShoe wear, unshod slow-down and stamina drain, warnAt thresholds
Config.HorseInventorySaddlebag stash (maxweight grams, slots, requireSaddlebags, native cargo prompt, openAnim / openAnimDelay for the opening animation)
Config.HorseFleefleeDelay, storeOnFlee
Config.HorseSpookGunfire/explosion spooking (baseChance, minChance, throwChance, bolt)
Config.HorseSalvageDead uninsured horse stays duration seconds so its saddlebags can be searched

Horse actions — Config.HorseActions#

Config.HorseActions = {
    enabled = true,
    command = 'horseaction',      -- opens the panel
    actionCommands = true,        -- /horserest /horsesleep /horsegraze ...
    stopCommand = 'horsestop',
    maxDistance = 6.0,
    rearKey = { enabled = true, control = `INPUT_SPECIAL_ABILITY_ACTION`, cooldown = 3000 },
    actions = {
        { id = 'rest', glyph = '\u{2726}', regen = true, anim = { dict = '...', base = 'base', enterDict = '...', enter = 'enter', exitDict = '...', exit = 'exit' } },
        { id = 'rear', glyph = '\u{2191}', horseAction = 5 },
        { id = 'follow', glyph = '\u{27A4}', follow = { offset = vector3(0.8, -2.5, 0.0), speed = 3.0 } },
    },
}

Each entry in actions produces a /horse<id> command and a panel button. Behaviour flags: anim (play enter/base/exit clips), horseAction (TASK_HORSE_ACTION id), stay, lead, follow, regen (refill stamina/health via restRegen).

Ownership, breeding and life cycle#

BlockKey settings
Config.WildHorseclaimFee, claimWindow (s), horseDistance
Config.Breedingcost, time (ms), sameStableOnly, requireOppositeGender, lockParents, parentCooldown, statVariance, betterParentChance
Config.HorseAgingyoungUntilDays 7, oldFromDays 60, lifespanDays 90, warnDays, oldMinStamina, checkInterval
Config.HorseGivedistance, fee, timeout, maxPrice
Config.HorseSellpercent, perTrainedLevel, minPrice, appraisal (condition, bonding, stage multipliers, shod bonus)
Config.HorseFenceaccount (bloodmoney), percent, cooldown, sellDistance, locations

Foal growth — Config.FoalGrowth#

Config.FoalGrowth = {
    enabled          = true,
    startScale       = 0.5,   -- size of a newborn foal (1.0 = full size)
    adultScale       = 1.0,   -- size once grown
    adultAfterDays   = nil,   -- real-life days until adult; nil = Config.HorseAging.youngUntilDays
    scaleByDay       = { [0] = 0.50, [1] = 0.58, [2] = 0.66, [3] = 0.74, [4] = 0.82, [5] = 0.90, [6] = 0.95 }, -- nil = smooth linear growth
    updateInterval   = 30000, -- ms between growth updates while the foal is out
    blockRiding      = true,  -- foals can't be ridden
    applyToPurchased = false, -- true = bought horses also start as foals (age counts from purchase)
    notifyGrown      = true,  -- notify the owner when the foal has grown up
}

See Foal growth under Gameplay systems for how it works.

Stables#

Config.Stables = {
    {
        name          = 'mystable',                 -- unique id, stored in the DB
        label         = 'My Stable',
        pedModel      = `u_m_m_bwmstablehand_01`,
        pedCoords     = vector4(x, y, z, heading),  -- stablehand NPC
        storeCoords   = vector4(x, y, z, heading),  -- where stored/retrieved horses appear
        previewCoords = vector4(x, y, z, heading),  -- buy-menu preview spot
        blip = { sprite = 'blip_shop_horse', color = 'BLIP_MODIFIER_MP_COLOR_6', scale = 0.2 },
    },
}

Shipped stables: valentine, blackwater, rhodes, saintdenis, strawberry. Never rename the name of a stable that already has horses: the name is the foreign key in rsg_stables_horses.stable.

Breeds#

Config.BreedStatMax = 10
Config.BuyPriceBands = { { label = 'Under $150', min = 0, max = 149 }, { label = '$1000+', min = 1000 } }

Config.Breeds = {
    {
        model        = `a_c_horse_arabian_white`,
        label        = 'Arabian (White)',
        class        = 'Race Horse',     -- used by the Buy menu class filter
        breed        = 'arabian',        -- used by the breed filter
        price        = 1200,
        handling     = 'Elite',
        health = 4, stamina = 4, speed = 5, acceleration = 5, -- 1..Config.BreedStatMax
        description  = 'Shown in the buy menu.',
        -- outfits = n                    -- optional: number of coat variants (default 1)
    },
}

Only models listed here can be bought, bred or claimed as wild horses; the server rejects anything else (invalid_breed).

Tack and coat#

Config.Tack = { enabled = true }
Config.Coat = { enabled = true, price = 100, presets = { { label = 'Black', tint0 = 9 } } }
Config.TackCategories = { { key = 'saddle', label = 'Saddle' }, { key = 'horseshoe', label = 'Horseshoes' } --[[ ... ]] }
Config.TackItems = {
    saddle = {
        { label = 'Saddle Style 5', hash = 0x7092A211, price = 40, verified = true, bonus = { stamina = 2, speed = 1 } },
    },
}
Config.TackBonuses = {
    enabled = true,
    categoryDefaults = { saddle = { stamina = 1 }, stirrups = { accel = 1 }, horseshoe = { speed = 1 }, blanket = { health = 1 } },
}

A per-item bonus overrides the category default. Bonuses stack with training.

Training — Config.Training#

Config.Training = {
    enabled = true,
    stats = { health = { attribute = 0 }, stamina = { attribute = 1 }, speed = { attribute = 5 }, accel = { attribute = 6 }, courage = { attribute = 3 } },
    statOrder = { 'health', 'stamina', 'speed', 'accel', 'courage' },
    courageFromBonding = 25,                       -- +1 courage rank per 25 bonding
    levelXp = { 100, 250, 450, 700, 1000 },        -- total XP for level 1..n (n = max level)
    bonusPerLevel = 1,
    riding  = { enabled = true, interval = 60, metersPerXp = 100.0, maxXpPerTick = 12, maxSpeed = 22.0, split = { stamina = 0.6, speed = 0.4 } },
    session = { enabled = true, price = { health = 10, stamina = 10, speed = 15, accel = 15, courage = 10 },
                rounds = 5, roundMs = 2000, baseXp = 20, xpPerHit = 12, cooldown = 900, stableDistance = 25.0, horseDistance = 6.0 },
}

Levels are applied as SET_ATTRIBUTE_BONUS_RANK bonus ranks, so a breed's own base stats are never overwritten.

Races — Config.HorseRaces#

Config.HorseRaces = {
    enabled = true, routeCommand = 'raceroute', radius = 8.0, maxSpeed = 25.0,
    dismountTimeout = 10, leaderboardSize = 5,
    races = {
        {
            id = 'valentine_sprint', stable = 'valentine', label = 'Valentine Sprint',
            entryFee = 5, prize = 25, goalTime = 90, timeLimit = 240, cooldown = 600,
            checkpoints = { vector3(-300.0, 790.0, 118.0), vector3(-250.0, 820.0, 120.0) },
        },
    },
}

Races only appear at the stable named in stable and only if checkpoints is non-empty. See Races for the route builder.

Horse card#

Config.HorseCard = { command = 'horseinfo', maxDistance = 15.0 } — set command = false to remove the command.


Admin panel#

/horseadmin (Config.Admin.command) opens an NUI panel for staff. It needs the rsg-core permission in Config.Admin.permission (default admin); the command, every callback below and every NUI action re-check RSGCore.Functions.HasPermission(source, permission) on the server, so closing the UI in the client proves nothing.

Config.Admin = { enabled = true, command = 'horseadmin', permission = 'admin' }

Flow: search a player (online by name / citizen ID / server ID, or any offline character by name / citizen ID) → their horses → one horse (edit form, actions, transfer, delete) or Give horse.

Server callbackArgumentsReturns
rsg-stables:server:admin:searchquerytrue, { { citizenid, name, online, horses } }
rsg-stables:server:admin:getOptions—true, { stables, breeds, statMax, lifespanDays }
rsg-stables:server:admin:getHorsescitizenidtrue, { player, horses } (each horse: id, name, breed, gender, stable, alive, active, insured, born, health, stamina, hunger, thirst, bonding, speed, accel, handling, maxhealth, ageDays, stage)
rsg-stables:server:admin:updateHorsehorseId, changestrue, message or false, err
rsg-stables:server:admin:actionhorseId, actiontrue, message or false, err
rsg-stables:server:admin:giveHorsecitizenid, model, name, gender, stable, ageDays, foaltrue, message or false, err
rsg-stables:server:admin:transferHorsehorseId, targetCitizenidtrue, message or false, err

changes may contain name, gender, stable, insured, born, ageDays, health, stamina, hunger, thirst, bonding, handling (0–100), speed, accel, maxhealth (1–Config.BreedStatMax). Every value is validated and clamped; unknown keys are ignored.

action is one of forceStore, revive, resetShoes, resetCoat, resetTack, resetTraining, clearCooldown, openSaddlebags, delete.

Rules enforced on the server:

  • Editing, resetting, reviving and transferring require the horse to be in its stable. A horse that is out must be force-stored first (forceStore, which also removes it from the world on the owner's client with rsg-stables:client:adminStoreHorse). forceStore, openSaddlebags and delete work on a horse that is out.
  • Work on a player's horses holds the same citizen:<id> lock as the normal gameplay callbacks (transfers lock both owners in a fixed order), so an admin action cannot race a purchase or a store.
  • Setting an age at or above Config.HorseAging.lifespanDays on a living horse is refused. Reviving a horse that died of old age resets its age to oldFromDays so the next lifespan check does not kill it again.
  • Deleting or transferring a horse cancels its uncollected breeding jobs, and a delete also removes the saddlebag stash.
  • Every change is printed to the server console and sent to rsg-log (rsgstables, title Horse Admin) with the admin, the horse id and the owner. Online owners get a notification.
  • The panel keeps push-to-talk working while it is open (Config.AllowPushToTalkWhileOpen, Config.PushToTalkControls).

server/server.lua exposes the helpers it shares with server/admin.lua in a global StablesAPI table (server only, not an export).


Client exports#

GetActiveHorseNeeds#

local needs = exports['rsg-stables']:GetActiveHorseNeeds()
-- needs = { entity = <ped handle>, hunger = 0-100, thirst = 0-100 }  or nil

Returns the live hunger/thirst of the player's currently active (spawned) horse, as tracked client-side and synced from the server session (Config.HorseNeeds). Returns nil when no horse is out. Compare needs.entity with GetMount(PlayerPedId()) to check you're riding that horse — rsg-hud does this so borrowed or wild horses show nothing.

-- Show needs only while riding your own horse
CreateThread(function()
    while true do
        Wait(1000)
        local needs = exports['rsg-stables']:GetActiveHorseNeeds()
        if needs and GetMount(PlayerPedId()) == needs.entity then
            print(('Horse hunger %d / thirst %d'):format(needs.hunger, needs.thirst))
        end
    end
end)

GetHorseBonusInfo#

local info = exports['rsg-stables']:GetHorseBonusInfo()
-- info = { tack = { health=, stamina=, speed=, accel=, courage= }, training = <summary> }  or nil

Returns nil when no horse is out. tack holds the bonus ranks from fitted tack (plus the bonding-derived courage), training is the latest server summary (see Training data).

local info = exports['rsg-stables']:GetHorseBonusInfo()
if info and info.training then
    local speed = info.training.stats.speed
    print(('Speed level %d (%d xp)'):format(speed.level, speed.xp))
end

Events#

Client events you can listen to (local, AddEventHandler)#

EventArgumentsWhen
rsg-stables:client:horseSpawnedentity, horseRowAn owned horse entity has been created and configured (client/foal.lua and client/training.lua hook it)
rsg-stables:client:tackChangedtackTack changed while the horse is out (e.g. a thrown shoe)
rsg-stables:client:openTraining—Opens the training panel (checks the horse is dismounted and near a stable)
AddEventHandler('rsg-stables:client:horseSpawned', function(entity, horseRow)
    print(('Horse %d (%s) spawned as entity %d'):format(horseRow.id, horseRow.name, entity))
    -- Owned horses carry a state bag flag:
    print(Entity(entity).state.rsgStablesOwned) --> true
end)

The spawned entity is flagged with the replicated state bag rsgStablesOwned = true. Foals also publish their current size on the rsgFoalScale state bag (see Foal growth). The server uses it to refuse to fence owned horses and wildhorse.lua uses it to ignore them when detecting a broken wild horse. Use it in your own scripts to tell owned horses from wild ones.

Net events received by the client (server → client)#

EventPayloadPurpose
rsg-stables:client:useFeeditemNameFeed item used from inventory
rsg-stables:client:useBrush—Brush item used
rsg-stables:client:useLantern—Lantern item used
rsg-stables:client:useStimulant—Stimulant used
rsg-stables:client:useMedicine—Medicine used
rsg-stables:client:useReviver—Reviver used
rsg-stables:client:horseDiedOfAgehorseId, horseNameHorse reached its lifespan
rsg-stables:client:fieldCorpse{ horseId, model, outfit, name, coords, heading, duration }A dead uninsured horse can be searched in the field
rsg-stables:client:trainingUpdatehorseId, summaryNew training XP/levels
rsg-stables:client:raceRouteactionAdmin route builder (add, print, clear)

These are server-driven: do not trigger them from other client scripts.

Net events received by the server (client → server)#

All of these revalidate everything server-side (ownership, distance, cooldowns); never trust their arguments.

EventArgumentsNotes
rsg-stables:server:saveHorsePositionhorseId, x, y, z, h, healthThrottled by Config.ActiveHorse
rsg-stables:server:wildHorseBrokennetIdRegisters a broken wild horse for claiming (Config.WildHorse.claimWindow)
rsg-stables:server:openHorseInventoryhorseId, horseNetIdRequires saddlebags if requireSaddlebags and proximity to the horse. The client plays Interaction_LootSaddleBags (via TaskAnimalInteraction) for openAnimDelay ms before sending it
rsg-stables:server:openFieldSaddlebagshorseIdDead horse in the field, within Config.HorseSalvage
rsg-stables:server:openDeadHorseInventoryhorseIdAt the stable only
rsg-stables:server:trainingRideTickhorseNetIdRide XP; measured on the horse entity, rate limited

rsg-core events used#

RSGCore:Client:OnPlayerLoaded, RSGCore:Client:OnPlayerUnload (client) and RSGCore:Server:OnPlayerUnload (server-only event, not a net event) end sessions and clean up.


Server callbacks#

Register-name → arguments → return. ok, x means true, payload on success or false, errorMessage on failure.

Horse lifecycle#

CallbackArgumentsReturns
rsg-stables:server:getStableHorsesstableNametable[] — rows of horses stabled there (with age_days, stage)
rsg-stables:server:buyHorsestableName, model, horseName, outfit, genderok, newHorseId
rsg-stables:server:claimWildHorsestableName, netId, horseNameok, ...
rsg-stables:server:retrieveHorsehorseIdok, horseRow (marks active = 1, starts a session)
rsg-stables:server:storeHorsehorseId, health, staminaok (saves needs, clears pos_*)
rsg-stables:server:fleeStoreHorsehorseId, health, staminaok (store without requiring a stable)
rsg-stables:server:restoreActiveHorse—Row of a horse left out before relog, or nil
rsg-stables:server:renameHorsehorseId, newNameok
rsg-stables:server:insureHorsehorseIdok
rsg-stables:server:reviveHorsehorseIdok (insured dead horse, Config.ReviveCost)
rsg-stables:server:releaseHorsehorseIdok (horse must be dead, at its stable, not a parent of an uncollected foal, saddlebags empty; the row is deleted)
rsg-stables:server:transferHorsehorseId, newStableok (move a stabled horse to another stable; you must be at its current stable and the destination must have room)
rsg-stables:server:getNearbyPlayers—Players within Config.HorseGive.distance
rsg-stables:server:giveHorsehorseId, targetId, priceok (target must accept within timeout)
rsg-stables:server:getSellPricehorseIdprice, info (info = base, training, condition, bonding, stageMult, stage, shod, price) or nil
rsg-stables:server:sellHorsehorseIdok, price
rsg-stables:server:fenceHorsefenceIndex, netIdok, ... (unowned horses only)
rsg-stables:server:horseDownnetIdtrue, secondsLeft — starts the field-revive window (applies bondingLoss once)
rsg-stables:server:reviveDownedHorsenetIdok — revive a downed horse in the field (consumes the reviver item)
rsg-stables:server:horseDiedhorseId, netIdMarks the horse dead; insured horses return to the stable, uninsured ones leave a field corpse (fieldCorpse event). Returns true, 'dead'
-- Buy a horse at Valentine (client)
RSGCore.Functions.TriggerCallback('rsg-stables:server:buyHorse', function(ok, result)
    if ok then
        print('Bought horse id', result)
    else
        RSGCore.Functions.Notify({ description = result, type = 'error' })
    end
end, 'valentine', `a_c_horse_americanpaint_overo`, 'Biscuit', 0, 'female')

Care and consumables#

CallbackArguments
rsg-stables:server:feedHorsepreferredItem, horseNetId
rsg-stables:server:waterHorsehorseNetId
rsg-stables:server:brushHorsehorseNetId
rsg-stables:server:naturalDrink / naturalGrazehorseNetId
rsg-stables:server:useStimulanthorseNetId
rsg-stables:server:useMedicinehorseNetId
rsg-stables:server:toggleLantern—
rsg-stables:server:getHorseshoeCondition—
rsg-stables:server:wearHorseshoehorseNetId, seconds

Feeding, watering and brushing share a 60 s per-player cooldown enforced on the server.

Customisation and breeding#

-- selections = { categoryKey = hash | false }, charged per changed category (Config.TackItems prices)
RSGCore.Functions.TriggerCallback('rsg-stables:server:applyHorseTack', function(ok, res)
end, horseId, { saddle = 0x7092A211, blanket = false })

-- coat = { tint0, tint1, tint2, mane, tail } or the string 'reset'
RSGCore.Functions.TriggerCallback('rsg-stables:server:applyHorseCoat', function(ok, res)
end, horseId, { tint0 = 9, tint1 = 255, tint2 = 255, mane = 9, tail = 9 })
CallbackArgumentsReturns
rsg-stables:server:applyHorseTackhorseId, selectionsok, newTack
rsg-stables:server:applyHorseCoathorseId, coat | 'reset'ok
rsg-stables:server:startBreedingstableName, idA, idBok, readyAtMs
rsg-stables:server:getBreedingJobsstableNameJobs with ms_left and ready (server clock)
rsg-stables:server:collectFoalbreedingIdok, ...

Training and races#

CallbackArgumentsReturns
rsg-stables:server:getTraining—Summary + horseId, name, prices, cooldownLeft
rsg-stables:server:startTrainingstat, horseNetIdtrue, { token, rounds, roundMs } or false, err
rsg-stables:server:finishTrainingtoken, hitstrue, { gain, stat, hits, training }
rsg-stables:server:getRacesstableNameRace list with best, cooldownLeft, leaderboard
rsg-stables:server:startRaceraceId, horseNetIdtrue, { checkpoints, timeLimit, goalTime, radius }
rsg-stables:server:raceCheckpointidxtrue, { finished=false, next } or true, { finished=true, ms, won, prize, newBest }
rsg-stables:server:abortRace—true

NUI callbacks#

Registered with RegisterNUICallback in the client scripts and called from the html/*.js files.

CallbackFilePurpose
select, close, inputSubmit, inputCancel, alertClose, statsCloseclient.luaMenu navigation, name input, alert and stats dialogs
rotateCam, zoomCamclient.luaPreview camera
tackCycle, tackCategoryNav, coatUpdate, coatActionclient.luaTack and coat editors
horseCardAction, horseCardCloseclient.luaHorse card (/horseinfo)
actionsSelect, actionsCloseactions.luaHorse Actions panel
trainingStart, trainingFinish, trainingClosetraining.luaTraining minigame

Menu options can carry an optional iconTone (young, adult, old, dead) next to icon; NuiRender forwards it and html/app.js adds a tone-<name> class to the round icon (colours in html/style.css). The stable ledger uses icon = 'mars' | 'venus' for the sex and iconTone for the age stage.

NUI messages sent from Lua use SendNUIMessage({ action = '...', ... }) — for example trainingOpen carries data, order and strings (localised labels built from the training_* locale keys).

The NUI keeps keyboard focus on SetNuiFocus(true, true). Keep the push-to-talk keep-alive pattern used across RSG scripts if you add new panels.


Commands#

CommandPermissionDescription
/storehorseeveryoneStore the active horse at the nearest stable
/horseinfo (Config.HorseCard.command)everyoneOpen the horse card
/horseaction (Config.HorseActions.command)everyoneOpen the actions panel
/horse<id> for each Config.HorseActions.actions[].ideveryonee.g. /horserest /horsesleep /horsegraze /horsewallow /horserear /horsestay /horsefollow /horselead
/horsestop (stopCommand)everyoneEnd the current action / release the reins
/horseadmin (Config.Admin.command)Config.Admin.permission (admin)Open the horse admin panel
/raceroute add | print | clear (routeCommand)adminBuild a race route (server command registered with RSGCore.Commands.Add)

Keys: whistle (INPUT_WHISTLE, H), Horse Cargo prompt (B) beside the horse, INPUT_SPECIAL_ABILITY_ACTION (Q) to rear while riding.


Usable items#

Created with RSGCore.Functions.CreateUseableItem from the Config item names.

Config keyDefault itemBehaviour
Config.HorseFeedItems[].itemhorse_apple, horse_carrotFeed (needs the horse within HorseBrushDistance)
Config.HorseDrinkItems[].itemfullbucketWater the horse (via Water Horse)
Config.HorseBrushItemhorse_brushBrush (not consumed)
Config.HorseStimulant.itemhorse_stimulantBoost, consumed
Config.HorseMedicine.itemhorse_medicineHeal, consumed
Config.HorseReviver.itemhorse_reviverRevive a downed horse, consumed
Config.HorseLantern.itemhorse_lanternToggle lantern, not consumed, saved in tack

Example shared-items entry:

horse_brush = { name = 'horse_brush', label = 'Horse Brush', weight = 200, type = 'item', image = 'horse_brush.png', unique = false, useable = true, shouldClose = true, description = 'Keeps your horse clean and bonded' },

Data formats#

Tack#

rsg_stables_horses.tack — JSON map of category key to the shop-item hash:

{ "saddle": 1904169813, "horseshoe": 2147483647, "blanket": 123456 }

Hashes come from Config.TackItems[category][].hash. New purchased horses start with the first horseshoe item when Config.Horseshoes.newHorsesShod is true, otherwise {}.

Coat#

rsg_stables_horses.coat — JSON, every key required and range checked on the server:

KeyRange
tint0 (main)0–254
tint1 (markings)0–255 (255 = none)
tint2 (nose)0–255 (255 = default)
mane, tail0–254
{ "tint0": 9, "tint1": 255, "tint2": 255, "mane": 9, "tail": 9 }

Anything out of range is rejected (invalid_coat). Sending the string 'reset' restores the natural coat for free.

Training data#

rsg_stables_horses.training — JSON:

{ "stats": { "health": 0, "stamina": 142.5, "speed": 60, "accel": 0, "courage": 0 }, "lastSession": 1731660000 }

The summary sent to clients (getTraining, trainingUpdate, GetHorseBonusInfo().training):

{
    stats = { stamina = { xp = 142, level = 1, prevXp = 100, nextXp = 250 }, --[[ ... ]] },
    maxLevel = 5,
    lastSession = 1731660000,
}

Foal state#

GetFoalState(row) (shared, shared/foal.lua) takes a horse row that has born and age_seconds and returns isFoal, scale, secondsLeft:

local isFoal, scale, secondsLeft = GetFoalState({ born = 1, age_seconds = 3.5 * 86400 })
-- isFoal = true, scale = 0.74, secondsLeft = 302400   (default scaleByDay, 7 day Young stage: day 3 -> 0.74)

With scaleByDay set (the default, modelled on rsg-ranch's growth table) the size is the entry for the foal's current day of age; with scaleByDay = nil it is startScale + (adultScale - startScale) * (age / adultSeconds), i.e. linear. The result is clamped to 0.1–2.0 like rsg-ranch. It returns false, adultScale, 0 for adults, when Config.FoalGrowth.enabled is false, and for horses that weren't born at a stable unless applyToPurchased is true. The server's AGE_SQL adds age_days and age_seconds to every horse row it selects with SELECT *, ' .. AGE_SQL.

Age stages#

young (< youngUntilDays), adult, old (≥ oldFromDays); the horse dies at lifespanDays. Only adults can breed. Age is DATEDIFF(NOW(), created_at).

Sell price#

base      = floor(breedPrice * Config.HorseSell.percent)
condition = (health + hunger + thirst) / 3                       -- 0..100
price     = base * (1 - conditionWeight * (1 - condition / 100))
                 * (1 + bondingBonus * bonding / 100)
                 * stage[youngOrAdultOrOld]                     -- Config.HorseSell.appraisal.stage
price     = max(minPrice, floor(price + perTrainedLevel * trainedLevels + shodBonus))  -- shodBonus only if shoes fitted

With appraisal.enabled = false only base + training is used. getSellPrice returns the price and the breakdown shown before the sale.


Gameplay systems#

Horse sessions and needs#

retrieveHorse starts a server session (activeSessions[citizenid]) holding hunger, thirst, bonding and model. Decay is applied lazily from elapsed time (Config.HorseNeeds) and persisted on store, drop or restart. GetActiveHorseNeeds mirrors it for HUDs.

Persistence and recall#

While out, the horse position is saved to pos_x/y/z/h. After a relog the horse is restored as pending; a whistle spawns it at the saved position (if within recallMaxDistance) or behind the player.

Opening the saddlebags#

Both entry points (the Open Saddlebags target option and the native Horse Cargo prompt, B) call the same client function in client/client.lua. It plays the game's saddlebag interaction on the horse, waits Config.HorseInventory.openAnimDelay ms, checks the horse is still the active one, then triggers rsg-stables:server:openHorseInventory; the server still validates ownership, distance and saddlebags. Set openAnim = false to open the stash instantly. The dead-horse salvage uses the same interaction.

Death, insurance and salvage#

horseDown opens a Config.HorseReviver.window for a field revive. If it dies: an insured horse returns to its stable for reviveHorse; an uninsured horse's body stays for Config.HorseSalvage.duration seconds so its saddlebags can be searched, and the stash can still be emptied at the stable afterwards.

Breeding#

The breed menu only lists horses that are living, stabled at that stable and adults (not Young, not Old). If you have two or more living horses but fewer than two adults, it explains why instead of breed_need_two: breed_wait_to_grow (with the days until enough young horses are adult) when waiting will fix it, otherwise breed_not_enough_breeders (old horses can't breed). startBreeding validates ownership, stage (adult only), both alive and stabled, same stable, opposite genders, no pending job, parent cooldowns, then charges cost. The foal is collected with collectFoal once ready_at passes; its stats are the parents' average ± statVariance, with betterParentChance% per stat to take the better parent's value.

Foal growth#

Horses created by collectFoal are stored with born = 1. While such a horse is younger than the adult age (Config.FoalGrowth.adultAfterDays, default the end of the Young stage) it is a foal:

  • Size. client/foal.lua listens for rsg-stables:client:horseSpawned, sets the entity size with SetPedScale (_SET_PED_SCALE, 0x25ACFC650B65C538, the same native rsg-ranch uses) and re-applies a slightly larger size every updateInterval ms while the foal is out. The owner also publishes the value on the entity state bag rsgFoalScale; every client has an AddStateBagChangeHandler for it, so other players see the same size. When the foal reaches adult age it is set to adultScale and the owner is notified.
  • No riding. With blockRiding the foal gets ped config flag 136 (CannotBeMounted), and if a player ends up on it anyway they are dismounted with TaskDismountAnimal and notified. The flag is cleared when it grows up.
  • Server enforcement. rsg-stables:server:startRace refuses a foal (foal_cannot_ride) and trainingRideTick gives no ride XP for one, using the same GetFoalState rules from the database age.
-- Another script: is this horse entity still a foal? (the bag is only set on horses that started as foals)
local scale = Entity(horseEntity).state.rsgFoalScale   -- nil, or the current size (reaches adultScale, 1.0 by default, when grown)
local isFoal = scale ~= nil and scale < 1.0

To make every bought horse start small as well, set Config.FoalGrowth.applyToPurchased = true (age then counts from the purchase date).

Training#

  • Ride XP: the client sends trainingRideTick every riding.interval seconds; the server measures distance travelled by the horse entity (ignores teleports above maxSpeed, walking, trains and wagons).
  • Paid sessions: startTraining charges the price, stamps the cooldown immediately and returns a one-time token; finishTraining(token, hits) grants baseXp + hits × xpPerHit. Finishing faster than 90 % of rounds × roundMs counts as tampering and gives 0 hits.
  • Levels become bonus ranks via SET_ATTRIBUTE_BONUS_RANK.

Races#

Races are timed and validated on the server. Build a route in-game as an admin:

/raceroute add     -- at every checkpoint, in order
/raceroute print   -- prints `checkpoints = { vector3(x, y, z), ... },` to the F8 console
/raceroute clear

Paste the printed block into Config.HorseRaces.races, set id, stable, label, fees, goalTime and timeLimit. Each checkpoint must arrive in order, within radius, on the same horse, and not faster than maxSpeed allows (otherwise the run is cancelled). Personal bests are stored in rsg_stables_races.


Security model#

  • Every server callback re-reads the player and the horse row and checks citizenid ownership; ids are sanitised with toId().
  • Distance checks (isNearStable, nearStableByName, activeHorseNear) are done with server-side coordinates.
  • Net-event arguments are untrusted. Client-reported entity ids are verified (entity exists, model matches the owned horse, close to the player).
  • Money moves through chargePlayer(Player, amount) using Config.PaymentAccount; failed inserts refund.
  • Names are sanitised and truncated; coat and tack payloads are validated against COAT_LIMITS and Config.TackItems.
  • The admin panel re-checks Config.Admin.permission in every callback, validates every field, takes the owner's lock and logs each change (see Admin panel).
  • Riding restrictions for foals are enforced on the server where the server can know about them (startRace, ride XP); the mount block itself is client-side (ped config flag plus dismount), as RedM has no server mount control.
  • RSGCore:Server:OnPlayerUnload is a server-only event, intentionally not registered as a net event.

Extending the resource#

Add a stable#

Append a block to Config.Stables (see Stables), restart the resource. Blips and the stablehand NPC are created from the config; race and training distance checks use the same entries.

Add a breed#

Append to Config.Breeds (see Breeds). Prices appear in the Buy menu price bands automatically.

Add a horse action#

-- Config.HorseActions.actions
{ id = 'bow', glyph = '\u{2193}', anim = {
    dict = 'my_dict@base', base = 'base',
    enterDict = 'my_dict@enter', enter = 'enter',
    exitDict = 'my_dict@exit', exit = 'exit',
} },

This creates /horsebow and a panel button. Add the label key to every locales/*.json.

Add a feed item#

Config.HorseFeedItems[#Config.HorseFeedItems + 1] =
    { item = 'horse_sugar', label = 'Sugar Cube', health = 5, stamina = 15, hunger = 10 }

Add the item to your shared items; the usable-item hook is created for every entry at start.

Add a tack item#

Config.TackItems.saddle[#Config.TackItems.saddle + 1] =
    { label = 'My Saddle', hash = 0x12345678, price = 60, verified = true, bonus = { speed = 1 } }

Use the resource from another script#

-- Is this ped an owned (stables) horse?
local function isOwnedHorse(ped) return Entity(ped).state.rsgStablesOwned == true end

-- Boost an NPC-less feature when the player rides a well-trained horse
local info = exports['rsg-stables']:GetHorseBonusInfo()
local fast = info and info.training and info.training.stats.speed.level >= 3

Locales#

Locale JSON files live in locales/ and load through rsg-core (@rsg-core/shared/locale.lua):

locale('horse_enjoyed', 'Apple')   -- "Your horse enjoyed the Apple"

Foal keys: foal_cannot_ride, foal_grown_up (%s = horse name). When adding a key, add it to all ten files (en, de, el, es, fr, ja, nl, pl, pt-br, ro, ru). Placeholders use %s / %d. Server functions return the localised string as the error value, so it reaches the player unchanged.


Troubleshooting#

SymptomCheck
Tables missingLook for [rsg-stables] SQL errors in the console; confirm oxmysql starts first or import installation/install.sql
"Not close to the stable"Server uses pedCoords / storeCoords of Config.Stables; check coordinates and Config.StoreDistance
Horse will not feed/water/brushSet Config.DebugHorseChecks = true to print the failing server check
Training disappears at restartTraining XP is saved in rsg_stables_horses.training; check the horse row is not deleted
Race not listedstable must match a Config.Stables[].name and checkpoints must not be empty
Race run cancelledA leg was completed faster than maxSpeed allows (teleport/lag) or you left your horse for dismountTimeout seconds
Foal is full size / won't growOnly horses collected from breeding after the update have born = 1; check Config.FoalGrowth.enabled, or set applyToPurchased = true
Other players see a foal full sizeThe owner's client publishes rsgFoalScale on the entity state bag; make sure the horse entity is networked and the other client has client/foal.lua running
Fence refuses a horseOwned horses (state bag rsgStablesOwned) are never accepted; add locations to Config.HorseFence.locations

rsg-skills integration#

Config.Skills = { Enabled, Skill, TrainingXP }. At the end of rsg-stables:server:finishTraining, after the horse's training XP is saved, the server calls AddXP(src, 'horsemanship', TrainingXP, 'horse training'). The amount comes from config. The horsemanship speed_bonus perk is not applied by rsg-stables. Skipped when rsg-skills is not started.

<!-- BEGIN AUTO-REFERENCE (generated from the code; re-run the generator instead of editing by hand) -->

Technical reference#

Generated from the source of rsg-stables 3.6.0. Names, arguments and defaults below are read straight from the code.

Dependencies#

rsg-core, rsg-target, oxmysql, rsg-inventory

Database#

Tables: rsg_stables_horses, rsg_stables_breeding, rsg_stables_races.

Tables are created automatically on start while Config.AutoDatabase = true (default). Nothing is ever dropped or overwritten. For a manual install set Config.AutoDatabase = false and import installation/install.sql once.

-- shared/config.lua
Config.AutoDatabase = true -- false = import the SQL file yourself

Configuration#

OptionDefaultNotes
Config.AutoDatabasetruebuild the database tables automatically on start (set false and import the SQL file for a manual install)
Config.MaxOwnedHorses8max horses a single player can own across all stables
Config.MaxHorsesPerStable20max horses a single player can keep at one stable location
Config.RenameCost15$ cost to rename an owned horse
Config.InsuranceCost25$ cost to insure a horse
Config.ReviveCost40$ cost to revive/replace a dead insured horse
Config.StoreDistance8.0max distance player's mount can be from stable to store it
Config.PaymentAccount'cash''cash' or 'bank'
Config.WhistleStopDistance1.0whistled horse stops this many meters in front of the player (measured to the horse's nose)
Config.WhistleAnim'WHISTLEHORSESHORT'whistle sound + animation played on H ('WHISTLEHORSESHORT', 'WHISTLEHORSELONG', 'WHISTLEHORSEDOUBLE'), false t
Config.WhistleSpawnDistance12.0when moved closer, the horse is placed on open ground about this far away (preferring behind you) with a clear
Config.WhistleTeleportDistance60.0if the active horse is farther than this when whistled, it's moved near the player instead of walking/running
Config.AllowTwoPlayersRidefalse
Config.ActiveHorsetablebrings it back toward the player instead of it being returned to the stable.
Config.HorseFeedItemstable===================== FEEDING / NEEDS =====================
Config.HorseDrinkItemstable
Config.HorseStimulanttable===================== HORSE STIMULANT =====================
Config.HorseNeedstable
Config.HorseHitchtablewhile hitched so the horse doesn't pull itself off the post and wander.
Config.HorseNaturalDrinktable===================== NATURAL DRINKING (rivers / lakes / troughs) =====================
Config.HorseNaturalGrazetable===================== NATURAL GRAZING (hay near the player) =====================
Config.HolsterStoresLongarmstrueWhen false, the game default applies (any owned horse stores long guns).
Config.Horseshoestableworn they come off and the horse stays degraded until new shoes are fitted at a stable (tack menu -> Horseshoe
Config.HorseLanterntable
Config.HorseBrushItem'horse_brush'item required (not consumed) to Brush Horse; using it from the inventory brushes your horse
Config.HorseBrushDistance4.0how close you must be to your horse to use the brush or a feed item from the inventory (measured to the horse'
Config.DebugHorseChecksfalseprints why a feed/water/brush server check failed to the server console
Config.HorseBrushMountedtrueallow brushing from the saddle (Interaction_Brush, rdr3_discoveries tasks/TASK_ANIMAL_INTERACTION)
Config.HorseBondingtable===================== BONDING =====================
Config.HideNativeBrushFeedtruehide the game's own Brush / Feed horse prompts (rsg-target options are used instead)
Config.HorseInventorytable===================== HORSE INVENTORY =====================
Config.HorseFleetable===================== FLEE =====================
Config.HorseActionstableHorse action ids from rdr3_discoveries tasks/TASK_HORSE_ACTION
Config.WildHorsetable"Claim Wild Horse" at the stable hand. Only breeds listed in Config.Breeds can be claimed.
Config.Breedingtable===================== BREEDING =====================
Config.HorseAgingtableAge is counted in real-life days since the horse was bought (or born as a foal).
Config.FoalGrowthtablewith other players through the rsgFoalScale entity state bag.
Config.Admintabletransfer to another player or delete. Every action is checked and logged on the server (rsg-log channel `rsgst
Config.AllowPushToTalkWhileOpentrueWhile a stables NUI that supports it is open, block game controls but still allow push-to-talk.
Config.PushToTalkControlstable
Config.HorseGivetable===================== GIVE HORSE TO ANOTHER PLAYER =====================
Config.Stablestable===================== STABLES =====================
Config.BreedStatMax10===================== BREEDS =====================
Config.BuyPriceBandstablePrice ranges shown in the Buy menu "Price" filter (max = nil means no upper limit)
Config.Breedstable
Config.TacktableLets players fit their horse with separate saddle, blanket, saddlebags, horn, stirrups,
Config.Coattablemane / tail = 0-254. Applied with SetMetaPedTag on the metaped_tint_horse palette.
Config.TackSoundstablefrontend sound played when cycling tack styles in the customisation menu
Config.TackCategoriestable
Config.TackItemstable
Config.HorseCardtableLive horse information panel (target "Horse Stats" on your horse, or the command below)
Config.HorseMedicinetableHealth counterpart to the stimulant (SP: CONSUMABLE_HORSE_CARE_PACKAGE / horse medicine)
Config.HorseRevivertablein the field with the item before it counts as dead (insurance / death rules then apply as normal).
Config.TackBonusestableA per-item bonus = { speed = 1 } on any Config.TackItems entry overrides its category default.
Config.HorseSelltableSell a stabled horse back to the stablehand (Sell Horse in the horse menu)
Config.HorseFencetablebrain data, so add your own locations below (vector4 x, y, z, heading for the fence NPC).
Config.TrainingtableAttribute IDs: rsg-redm-brain data/rdr3-native-enums/PedAttribute__AttributeType.md
Config.HorseSpooktablefrom rdr3_discoveries tasks/TASK_ANIMAL_INTERACTION) or the timer runs out.
Config.HorseSalvagetableThe saddlebags can still be emptied at its stable afterwards.
Config.HorseRacestableBuild routes in-game: /raceroute add (at each checkpoint), /raceroute print (prints the config to F8), /racero
Config.Skillstablersg-skills integration (optional). Needs the rsg-skills resource; does nothing when it is not started.
Config.Enabledtrue
Config.Skill'horsemanship'
Config.TrainingXP15

Exports#

Client

ExportArgumentsFile
GetActiveHorseNeeds``client/client.lua
GetHorseBonusInfo``client/training.lua
-- example
local result = exports['rsg-stables']:GetActiveHorseNeeds()

Callbacks#

CallbackSideArgumentsFile
rsg-stables:client:confirmHorseGiftclientcb, giverName, horseName, breedLabel, priceclient/client.lua
rsg-stables:client:isHorseDeadclientcb, netIdclient/client.lua
rsg-stables:server:admin:searchserversource, queryserver/admin.lua
rsg-stables:server:admin:getOptionsserversourceserver/admin.lua
rsg-stables:server:admin:getHorsesserversource, citizenidserver/admin.lua
rsg-stables:server:admin:updateHorseserversource, horseId, changesserver/admin.lua
rsg-stables:server:admin:actionserversource, horseId, actionserver/admin.lua
rsg-stables:server:admin:giveHorseserversource, citizenid, model, name, gender, stable, ageDays, foalserver/admin.lua
rsg-stables:server:admin:transferHorseserversource, horseId, targetCitizenidserver/admin.lua
rsg-stables:server:getStableHorsesserversource, stableNameserver/server.lua
rsg-stables:server:restoreActiveHorseserversourceserver/server.lua
rsg-stables:server:toggleLanternserversourceserver/server.lua
rsg-stables:server:useStimulantserversource, horseNetIdserver/server.lua
rsg-stables:server:feedHorseserversource, preferredItem, horseNetIdserver/server.lua
rsg-stables:server:waterHorseserversource, horseNetIdserver/server.lua
rsg-stables:server:naturalDrinkserversource, horseNetIdserver/server.lua
rsg-stables:server:naturalGrazeserversource, horseNetIdserver/server.lua
rsg-stables:server:brushHorseserversource, horseNetIdserver/server.lua
rsg-stables:server:buyHorseserversource, stableName, model, horseName, outfit, genderserver/server.lua
rsg-stables:server:claimWildHorseserversource, stableName, netId, horseNameserver/server.lua
rsg-stables:server:retrieveHorseserversource, horseIdserver/server.lua
rsg-stables:server:storeHorseserversource, horseId, health, staminaserver/server.lua
rsg-stables:server:fleeStoreHorseserversource, horseId, health, staminaserver/server.lua
rsg-stables:server:horseDiedserversource, horseId, netIdserver/server.lua
rsg-stables:server:horseDownserversource, netIdserver/server.lua
rsg-stables:server:reviveDownedHorseserversource, netIdserver/server.lua
rsg-stables:server:useMedicineserversource, horseNetIdserver/server.lua
rsg-stables:server:renameHorseserversource, horseId, newNameserver/server.lua
rsg-stables:server:insureHorseserversource, horseIdserver/server.lua
rsg-stables:server:reviveHorseserversource, horseIdserver/server.lua
rsg-stables:server:releaseHorseserversource, horseIdserver/server.lua
rsg-stables:server:transferHorseserversource, horseId, newStableserver/server.lua
rsg-stables:server:getNearbyPlayersserversourceserver/server.lua
rsg-stables:server:giveHorseserversource, horseId, targetId, priceserver/server.lua
rsg-stables:server:getHorseshoeConditionserversourceserver/server.lua
rsg-stables:server:wearHorseshoeserversource, horseNetId, secondsserver/server.lua
rsg-stables:server:applyHorseTackserversource, horseId, selectionsserver/server.lua
rsg-stables:server:applyHorseCoatserversource, horseId, rawCoatserver/server.lua
rsg-stables:server:startBreedingserversource, stableName, idA, idBserver/server.lua
rsg-stables:server:getBreedingJobsserversource, stableNameserver/server.lua
rsg-stables:server:collectFoalserversource, breedingIdserver/server.lua
rsg-stables:server:getSellPriceserversource, horseIdserver/server.lua
rsg-stables:server:sellHorseserversource, horseIdserver/server.lua
rsg-stables:server:fenceHorseserversource, fenceIndex, netIdserver/server.lua
rsg-stables:server:getRacesserversource, stableNameserver/server.lua
rsg-stables:server:startRaceserversource, raceId, horseNetIdserver/server.lua
rsg-stables:server:raceCheckpointserversource, idxserver/server.lua
rsg-stables:server:abortRaceserversourceserver/server.lua
rsg-stables:server:getTrainingserversourceserver/training.lua
rsg-stables:server:startTrainingserversource, stat, horseNetIdserver/training.lua
rsg-stables:server:finishTrainingserversource, token, hitsserver/training.lua
-- client side
RSGCore.Functions.TriggerCallback('rsg-stables:client:confirmHorseGift', function(result)
    -- use result
end)

Events#

Server events can be fired by any client, so every handler re-validates the player, the arguments and any permission, distance or cooldown on the server. Never add a reward to a handler without those checks.

EventSideArgumentsFile
rsg-stables:client:openAdminclient``client/admin.lua
rsg-stables:client:adminStoreHorseclient``client/admin.lua
rsg-stables:client:useStimulantclient``client/client.lua
rsg-stables:client:useFeedclientitemclient/client.lua
rsg-stables:client:useBrushclient``client/client.lua
rsg-stables:client:useLanternclient``client/client.lua
rsg-stables:client:horseDiedOfAgeclienthorseId, horseNameclient/client.lua
rsg-stables:client:useReviverclient``client/client.lua
rsg-stables:client:useMedicineclient``client/client.lua
RSGCore:Client:OnPlayerLoadedclient``client/client.lua
RSGCore:Client:OnPlayerUnloadclient``client/client.lua
rsg-stables:client:raceRouteclientactionclient/races.lua
rsg-stables:client:fieldCorpseclientdataclient/salvage.lua
rsg-stables:client:trainingUpdateclienthorseId, dataclient/training.lua
rsg-stables:server:saveHorsePositionserverhorseId, x, y, z, h, healthserver/server.lua
rsg-stables:server:wildHorseBrokenservernetIdserver/server.lua
rsg-stables:server:openHorseInventoryserverhorseId, horseNetIdserver/server.lua
rsg-stables:server:openFieldSaddlebagsserverhorseIdserver/server.lua
rsg-stables:server:openDeadHorseInventoryserverhorseIdserver/server.lua
rsg-stables:server:trainingRideTickserverhorseNetIdserver/training.lua
-- from a client script
TriggerServerEvent('rsg-stables:server:saveHorsePosition', horseId, x, y, z, h, health)
-- from a server script
TriggerClientEvent('rsg-stables:client:openAdmin', source)

Commands#

CommandNotesFile
/storehorseclient/client.lua

Locales#

Language files in locales/: de, el, en, es, fr, ja, nl, pl, pt-br, ro, ru. Set the language with setr rsg:locale "en".

<!-- END AUTO-REFERENCE -->