OnServerEvent
The game mode sent an event to this player’s game.
Every event the mode’s SendClientEvent or SendClientEventToAll addressed to this player arrives here, with its name
and the string it carried. An error inside is logged ([KcdMp] OnServerEvent: ...), never fatal.
Syntax
Section titled “Syntax”function OnServerEvent(name, payload) -- ...end| Parameter | Type | |
|---|---|---|
name |
string | the event’s name, as the mode sends it |
payload |
string | the string the mode sent ("" when it sent none) |
Returns
Section titled “Returns”nothing
Example
Section titled “Example”function OnServerEvent(name, payload) if name == "marker" then local x, y, z = payload:match("^([^,]+),([^,]+),(.+)$") marker = {x = tonumber(x), y = tonumber(y), z = tonumber(z)} print("marker at " .. payload) endendSee also
Section titled “See also”SendServerEvent · the Script events group of the index
