Events and time
Listening#
on("playerJoin", function(player)
log(player.name, "joined")
end)
The full list is in Events.
Talking to the client#
From the server to the client with player:emit; from the client to the server with nov_emit:
on("client:ring", function(player, text)
-- Always check: the message comes from a player's PC
if not bellZone:contains(player:position()) then
return
end
for _, other in players.all() do
other:emit("ring", player.name)
end
end)
Important
A modified client can send anything, at any time. Check distance, role and bounds before acting.
| Limit | Value |
|---|---|
| client to server | 20 events per second, 4096 bytes each |
| server to client | 60,000 characters, of which the client library reads 511 bytes |
| name | 64 characters |
Waiting and repeating#
| Function | Effect |
|---|---|
wait |
suspends the current function |
after |
once, later |
every |
at regular intervals |
cancel |
cancels a timer |
thread |
runs a function that can wait |
now |
server time, in seconds |
Precision is that of the tick: 50 ms at 20 ticks per second.