Skip to content

HitchHorse

Puts a player’s horse in front of a cart, in place of its own horse or an empty slot.

The horse (an ENTITY_HORSE, a player’s or the mode’s) leaves everyone’s view as itself and the cart draws it in the slot with its coat; it keeps its owner, stats and saddlebags, and its strength counts in what the team pulls (GetCartPull). slot 1 is horse1, 2 horse2 (a wagon’s right), 0 the first slot without a player’s horse - an empty slot ("none", SetCartPart) first. Nobody rides a hitched horse, and a dead one is unhitched; moving it with SetEntityPos (a “call my horse” command) takes it out of the cart first. A cart made with no horses at all (CreateCart with {horse1 = "none", horse2 = "none"}) cannot move until one is hitched: its bench offers a seat, never the reins. Whether a player may hitch, and which horses suit a cart, is the mode’s - a stable, a command, a price (SetHorseType).

HitchHorse(id, horse [, slot])
Parameter Type
id number the cart
horse number the horse
slot number 1, 2, or 0 / nil = the first free (optional)

boolean - false when it is not a cart or a horse, the slot is not the kind’s or a player’s horse is there, or the horse is ridden, dead or down, in front of another cart or in another virtual world

-- /hitch: the player's own horse in front of the cart they stand by
local horse = GetPlayerHorse(pid)
if horse and HitchHorse(cart, horse) then SendClientMessage(pid, COLOR_WHITE, "Your horse is hitched.") end

UnhitchHorse · GetCartHorse · GetHorseCart · GetCartPull · the Carts group of the index