Skip to content

Implements AcceptInputProxy #1

@TIMONz1535

Description

@TIMONz1535
  1. Implements AcceptInputProxy in the Entity meta, that hooks inputs through GM:AcceptInput.

A serious performance check is required.

Usage:

security_button:AcceptInputProxy("Use", function(ent, input, activator, caller, value)
	if IsValid(activator) and activator:IsPlayer() and not activator:IsAdmin() then
		return true -- suppress use for non-admin players
	end
end)

local proxies = {}
local function AcceptInputProxy(target, input, callback)
for _, v in ipairs(target) do
local idx = v:EntIndex()
proxies[idx] = proxies[idx] or {}
proxies[idx][input] = callback
end
end
hook.Add(
"AcceptInput",
"MapLogicProxy",
function(ent, input, activator, caller, value)
local callbacks = proxies[ent:EntIndex()]
if callbacks then
local callback = callbacks[input]
if callback then
return callback(ent, input, activator, caller, value)
end
end
end
)

  1. Implements SuppressOutputs that must suppress default map inputs through GM:AcceptInput.
    > Unfortunately, there is no way to remove an already added output from the entity #1984. Alternatively, you can mute them all via GM:AcceptInput.

Most likely it will be irrelevant if ClearOutputs(string)/ClearAllOutputs appears
Facepunch/garrysmod-requests#1984 (comment)

Metadata

Metadata

Assignees

Labels

documentationImprovements or additions to documentationenhancementNew feature or requestquestionFurther information is requested

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions