To perform action 2 players must simultaneously press 2 different buttons (

map = {}
map.b1name = "button1" -- entity name for button 1
map.b2name = "button2" -- entity name for button 2
map.trigger = "entity" -- entity name to trigger
-- because of latency and that players can't possibly press the buttons at the exact same time, a delay must be allowed between button presses
map.pressdelay = 300 -- milliseconds
map.pressdelay = map.pressdelay / 1000
map.pressedtime = 0 -- keep track of when buttons where pressed
map.firstpressed = false
map.pressid = 0
addhook("usebutton", "map.usebutton")
function map.usebutton(id, x, y)
local e = entity(x, y, "name")
local t = os.clock()
-- return if it's neither of the buttons
if e ~= map.b1name and e ~= map.b2name then
return
end
-- is it the first button pressed?
if not map.firstpressed then
map.firstpressed = e
end
-- if the first one is pressed again, reset the timer and player id
-- this is also done on the first button press
if e == map.firstpressed then
map.pressedtime = t
map.pressid = id
return
end
-- the second button was pressed. check if they where pressed quickly enough and by different players
if (t - map.pressedtime) <= map.pressdelay and map.pressid ~= id then
parse('trigger "' .. map.trigger ..'"')
end
-- reset everything
map.pressedtime = 0
map.firstpressed = false
map.pressid = 0
end