Skip to content

CreateHorse

Puts a horse in the world.

controllerPid is the player whose client simulates it (usually the one it is for); with nil nobody does and it stands still until the server hands it to the nearest player within 30 m. world is the virtual world (nil = the controller’s; 0 without one). soul is the breed - a Horse-archetype soul by name (Horse2, Pebbles), id or GUID from the horse souls; nil = the server’s [spawn] horse_soul; a key that is not a horse makes no horse. coat is its colour with mane and tail, one of GetHorseCoats, on from the first moment; nil = a pick from the ten coats that changes with the horse’s id (two horses can share one; the soul does not decide it), and a coat that is no coat makes no horse. coat may be a look of its own too - SetHorseLook’s table or its one-line form, the table’s coat the coat under it: {coat = "black", mane = "horse_braided_hair_01_black"}; a part that is none makes no horse. nil when the world is full ([world] max_entities).

CreateHorse(x, y, z, yaw [, controllerPid, world, soul, coat])
Parameter Type
x number metres
y number metres
z number metres
yaw number degrees (0 without)
controllerPid number the player whose client simulates it; nil = nobody yet (optional)
world number the virtual world; nil = the controller’s (optional)
soul string | number the breed - a horse soul’s name, id or GUID; nil = the server default (optional)
coat string | table the coat, one of GetHorseCoats ("chestnut"), or a look (SetHorseLook); nil = the pick that goes with the horse’s id (optional)

number - the horse’s entity id; nil when it could not be made

-- /steed: a horse in front of the player, mounted at once
local x, y, z = GetPlayerPos(pid)
local r = math.rad(GetPlayerYaw(pid))
local horse = CreateHorse(x - math.sin(r) * 3, y + math.cos(r) * 3, z, GetPlayerYaw(pid), pid, nil, "Pebbles")
if horse then MountPlayer(pid, horse) end

MountPlayer · GetPlayerHorse · GetHorseSoul · SetHorseCoat · DestroyEntity · the Horses group of the index