OnPlayerWebSurfaceEvent
A player’s copy of a surface’s page sent the mode an event.
The page called KcdMp.emitServer(name, value). name is one its surface allows in ui.toml (events_out, the surface’s
own <name>.* unless it lists others); payload is the value as text - a text as it was sent, anything else as JSON
(JsonDecode reads it back). Events share the player’s budget with the client scripts’ and the frames’ (30 a second):
a page that sends more loses the rest.
This is the player’s game talking: check it like any other input from a player.
Syntax
Section titled “Syntax”function OnPlayerWebSurfaceEvent(pid, id, name, payload) -- ...end| Parameter | Type | |
|---|---|---|
pid |
number | the player |
id |
number | the surface’s entity id |
name |
string | the event’s name |
payload |
string | the value as text |
Returns
Section titled “Returns”nothing
Example
Section titled “Example”function OnPlayerWebSurfaceEvent(pid, id, name, payload) if name == "board.read" then local notice = notices[tonumber(payload) or 0] if notice then SendClientMessage(pid, COLOR_SERVER, "You read: " .. notice.title) end endendSee also
Section titled “See also”OnPlayerWebSurfaceReady · OnClientEvent · JsonDecode · the Web surfaces group of the index
