Skip to content

OnMapEdit

A player’s edit in the in-game map editor, before it is made - return false to refuse it.

Runs for every edit from the in-game editor (SetPlayerEditor, an admin’s /editor) after the editor’s own scope allowed it, never for the mode’s own functions. edit says what it would do: label (what the editor calls it - "move", "place" …), the counts placed, changed, deleted, removed (parts of the level taken out), restored, the meshes it places, the layers it switches, the places ({x, y, z}) of every object it places or moves, the areas (names) it draws, changes or deletes and navLinks (how many nav links it draws or deletes). Refused, the player’s editor says so and nothing changes. An undo or redo of an edit already made is not asked again.

function OnMapEdit(pid, edit)
-- ...
end
Parameter Type
pid number the player
edit table {label, placed, changed, deleted, removed, restored, meshes, layers, places, areas, navLinks}

boolean - false refuses the edit; anything else lets it through

-- builders keep to the town square
function OnMapEdit(pid, edit)
for _, p in ipairs(edit.places) do
if (p.x - 1290) ^ 2 + (p.y - 1095) ^ 2 > 60 ^ 2 then
SendClientMessage(pid, COLOR_RED, "Build on the square only.")
return false
end
end
end

SetPlayerEditor · the The server’s map group of the index