OnPlayerSeatChange
A player sat down on a bench, a chair or a bed of the level, stood up, lay down or got up.
The game’s own “Sit” and “Lie down” on the level’s seats. kind is what they sit or lie on, state where they are in
it; both are nil once they are off it again. A sit goes "sitting_down", "sitting", "standing_up", then nil; a
lie "lying_down", "lying", "getting_up", then nil. It is called once per change, and the sit-down is told once
the game names the seat (under a second into it). GetPlayerSeat reads it at any time.
A cart’s seat is not one of these: it is the stance STANCE_SEATED (OnPlayerStanceChange).
Syntax
Section titled “Syntax”function OnPlayerSeatChange(pid, kind, state, previousKind, previousState) -- ...end| Parameter | Type | |
|---|---|---|
pid |
number | the player |
kind |
string|nil | "table" (a table’s bench or a chair at it), "bench" (a bench or a chair away from a table, or lying on a bench), "bed" (a low straw bed on the floor too), "ground" (sitting or resting on the ground), "on_table", "shelter", "tent", "bath" or "other"; nil = off the seat |
state |
string|nil | "sitting_down", "sitting", "standing_up", "lying_down", "lying" or "getting_up"; nil = off the seat |
previousKind |
string|nil | the kind before (nil = they were on no seat) |
previousState |
string|nil | the state before |
Example
Section titled “Example”-- a word when a player takes a seat and when they get upfunction OnPlayerSeatChange(pid, kind, state, previousKind, previousState) if state == "sitting" and (kind == "bench" or kind == "table") then SendClientMessage(pid, COLOR_GOLD, "You take a rest.") elseif state == nil and previousKind ~= nil then SendClientMessage(pid, COLOR_GOLD, "You get back on your feet.") endendSee also
Section titled “See also”GetPlayerSeat · OnPlayerStanceChange · GetPlayerPos · the Players group of the index
