Skip to content

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.

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

nothing

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
end
end

OnPlayerWebSurfaceReady · OnClientEvent · JsonDecode · the Web surfaces group of the index