Skip to content

SetEntityState

Sets a key of an entity’s bag, read by every client that sees the entity.

The bag travels with the entity’s spawn to whoever comes into range and is dropped when it leaves their view - KcdMp.state.entity[id][key] while the entity is in view. Gone with the entity. An NPC actor’s pose rides in its bag under the key anim (SetActorAnim).

SetEntityState(id, key, value)
Parameter Type
id number the entity
key string 1-48 characters
value string | number | boolean | nil kept as a string; nil removes the key

boolean - false when there is no such entity or out of bounds

local horse = CreateHorse(x, y, z, yaw, pid)
SetEntityState(horse, "owner", GetPlayerName(pid)) -- the client scripts can label it

GetEntityState · GetEntityStates · SetEntityData · the State bags group of the index