Compatibility

Stable adapters

How the Stables app reads horses and wagons from gum_stables, vorp_stables or rsg-horses, what each one supports and how to connect another stable script.

The Stables app (Ahirlar) shows the character's horses and wagons, and with some stable scripts it can choose the active horse or call it. It reaches the stable script through an adapter in framework/frameworks.lua (FXStables).

#Supported stable scripts

Mode Script Horses Wagons Choose active horse Call horse
gum gum_stables (VORP) yes yes off by default no
vorp vorp_stables-lua (VORP) yes yes yes no
rsg rsg-horses 2.x (RSG) yes with rsg-wagons yes yes
internal none no no no no
custom yours what you fill in
  • gum_stables is read from its tables horses and wagons. Its client code is protected, so the notebook cannot call a horse. Choosing the active horse changes the selected column; it is off by default because gum_stables may keep its own copy in memory. Stable names come from Gum.StableNames, or else from gum_stables/cfg/configCoords.lua.
  • vorp_stables is read from its table stables (type = 'horse' and type = 'cart'). After the active horse changes, the notebook asks vorp_stables to reload its list (event stables:loadRuntime).
  • rsg-horses is read from player_horses. Choosing a horse runs the same SQL as rsg-horses' own server event and sends rsg-horses:client:horseActivated. Calling sends rsg-horses:client:FleeHorse and rsg-horses:client:SpawnHorse. Wagons come from player_wagons while rsg-wagons is started.
  • internal means no stable script is connected. The app says so and lists nothing.

#How the mode is chosen

apps/stables/config.lua:

luaMode = 'auto', -- auto | vorp | rsg | gum | internal | custom

'auto' picks:

  1. rsg when the framework is RSG and rsg-horses is started,
  2. gum when the framework is VORP and gum_stables is started,
  3. vorp when the framework is VORP and vorp_stables is started,
  4. internal otherwise.

#Settings

Key Default What it does
Mode 'auto' See above
Wagons true Show the wagons tab (list only)
ModelLabels {} Names for horse models, { A_C_Horse_Arabian_White = 'Arap Beyaz' }. Without one the name is made from the model.
WagonLabels {} Names for wagon models, { cart04 = 'Ciftlik arabasi' }
Gum.AllowSetActive false Let the notebook choose the active horse in gum_stables. Test it in game before you turn it on.
Gum.StableNames nil { [1] = 'Valentine', ... }; empty: read from gum_stables' config
Vorp.AllowSetActive true Let the notebook change vorp_stables' default horse
Rsg.AllowCall true Let the notebook call the horse with rsg-horses
Rsg.StableNames {} { valentine = 'Valentine Ahiri' }

#The adapter contract

Every adapter is a table in FXStables.Adapters:

Function Returns Required
Available() true, or false, reason yes
List(src, char) { { id, name, model, label, gender, stable, active, health, dead }, ... } yes
Call(src, char, id) true, or false, reason no; leave it out when the script cannot call a horse
SetActive(src, char, id) true, or false, reason no
AllowCall(), AllowSetActive() boolean no; a config switch for the two above
Wagons(src, char) { { id, name, model, label, stable, active, condition }, ... } no; list only, condition 0 to 100 when the script keeps one
  • Horse and wagon ids are the stable script's own numeric ids.
  • char.id is 'vorp:...' or 'rsg:...'. FXFramework.CharacterKey(char, 'vorp') returns the part after the colon.
  • Check in Call and SetActive that the horse belongs to char. The shipped adapters do it by looking the id up in List.

#Writing a custom adapter

Set Mode = 'custom' and fill in the custom adapter in framework/frameworks.lua. The file ships with this template:

lualocal customStables = {}
FXStables.Adapters.custom = customStables
function customStables.Available()
    -- return GetResourceState('my_stables') == 'started'
    return false, 'Ozel ahir baglantisi yapilmamis.'
end
function customStables.List(src, char)
    -- local rows = MySQL.query.await('SELECT id,name,model,active FROM my_horses WHERE owner=?', { char.id })
    -- return { { id = 1, name = 'Duman', model = 'A_C_Horse_Arabian_White', label = 'Arabian White', active = true } }
    return {}
end
-- The wagons the character owns (read only):
-- function customStables.Wagons(src, char)
--     return { { id = 1, name = 'Yuk arabasi', model = 'cart04', active = true, condition = 90 } }
-- end
-- Remove the comment marks to enable calling / choosing from the book:
-- function customStables.Call(src, char, horseId)
--     TriggerClientEvent('my_stables:client:callHorse', src, horseId)
--     return true
-- end
-- function customStables.SetActive(src, char, horseId)
--     return exports.my_stables:SetActiveHorse(char.id, horseId) == true
-- end

my_stables, its table and its events stand for your own script.