Hi Citizen thanks for taking the time to make that script.
There are syntax errors. With respect to the operation of the code, I could not make it work
local forbiddenAreas = {
--x, y, width, height
{1801, -1897, 250, 250}, --example1 (needs a ',' because it's not the last)
{-500, -1613, 50, 50} --example2 (no need a ',' because it's the last)
}
addEventHandler('onResourceStart', resourceRoot, function()
for k, i in ipairs(forbiddenAreas) do
local col = createColRectangle(i[1], i[2], i[3], i[4])
addEventHandler('onColShapeHit', root, function ( hitElement )
if getElementType(hitElement) ~= 'player' then return end
setElementData(hitElement, 'isInForbiddenArea', true)
end)
addEventHandler('onColShapeLeave', root, function( leaveElement )
if getElementType(leaveElement) ~= 'player' then return end
setElementData(leaveElement, 'isInForbiddenArea', false)
end)
end
end)
addEventHandler('onPlayerJoin', root, function()
bindKey(source, 'f1', 'down', openF1)
end)
function openF1( player, preventLoop )
if preventLoop == false and getElementData(player, 'isInForbiddenArea') then
executeCommandHandler('fr', player, true)
end
end
addCommandHandler('fr', openF1)