Skip to content

OnPlayerUseMapObject

A player pressed the use key on a map object with a use prompt.

A map object’s use (CreateMapObject’s option, the editor’s “Use prompt”) shows as the game’s own use hint over it; the key on it comes here once the server checked that the player stands within reach of it. What it does is the mode’s - a lever, a sign to read, a well to drink from.

function OnPlayerUseMapObject(pid, id)
-- ...
end
Parameter Type
pid number the player
id number the map object (GetMapObject)
function OnPlayerUseMapObject(pid, id)
local o = GetMapObject(id)
if o and o.group == "wells" then
SendClientMessage(pid, COLOR_WHITE, "You drink the cold water.")
end
end

CreateMapObject · GetMapObject · the The server’s map group of the index