COLLISIONS_AREAS = {} COLLISIONS_AREAS.__index = COLLISIONS_AREAS COLLISIONS_AREAS.ZONES = { {Vector2(583.875, -1487.796, 16.242), Vector2(583.748, -1429.064, 16.242), Vector2(606.043, -1429.275, 14.988), Vector2(606.222, -1487.174, 14.988)}, -- configurar essa merda! {Vector2(1229.114, -1466.808, 14.761), Vector2(1228.875, -1463.507, 14.761), Vector2(1233.465, -1463.775, 14.761), Vector2(1233.392, -1466.506, 14.761)}, -- configurar essa merda! {Vector2(1743.781, -1097.819, 24.289), Vector2(1780.653, -1097.936, 24.234), Vector2(1780.630, -1141.073, 24.234), Vector2(1743.557, -1141.007, 24.234)}, -- configurar essa merda! {Vector2(678.034, 2001.895, 5.539), Vector2(730.621, 2002.085, 5.525), Vector2(730.822, 1952.576, 5.539), Vector2(678.095, 1952.443, 5.539)}, -- configurar essa merda! {Vector2(-70.244, 2044.636, 12.589), Vector2(-48.244, 1932.823, 12.589), Vector2(-161.905, 1917.093, 12.589), Vector2(-166.282, 2057.867, 12.589)}, -- configurar essa merda! {Vector2(2222.185, 1368.035, 10.770), Vector2(2222.279, 1198.038, 10.767), Vector2(2077.546, 1197.589, 10.680), Vector2(2077.637, 1368.543, 10.660)}, -- configurar essa merda! {Vector2(2222.185, 1368.035, 10.770), Vector2(2222.279, 1198.038, 10.767), Vector2(2077.546, 1197.589, 10.680), Vector2(2077.637, 1368.543, 10.660)}, -- nome do local {Vector2(-2568.124, 313.900, 5.697), Vector2(-2568.335, 306.174, 5.180), Vector2(-2578.354, 306.182, 5.180), Vector2(-2578.486, 313.187, 5.180)}, -- Barbearia SF {Vector2(-2491.007, -42.616, 26.637), Vector2(-2474.870, -43.149, 26.637), Vector2(-2475.062, -34.270, 26.637), Vector2(-2491.578, -34.360, 25.766)}, -- Tattoo SF {Vector2(471.064, -1477.056, 30.270), Vector2(474.649, -1504.964, 30.270), Vector2(463.518, -1506.767, 32.234), Vector2(459.609, -1479.096, 31.062)}, -- Roupas LS 1 {Vector2(843.848, -1592.462, 13.712), Vector2(828.001, -1579.002, 13.712), Vector2(822.364, -1585.904, 14.662), Vector2(837.960, -1598.251, 14.639)}, -- Tattoo LS {Vector2(2724.521, -2030.322, 13.555), Vector2(2734.176, -2029.809, 13.555), Vector2(2733.941, -2021.521, 13.555), Vector2(2724.567, -2021.591, 13.555)}, -- Barbearia LS {Vector2(1003.619, -1592.663, 13.249), Vector2(1003.767, -1606.464, 13.249), Vector2(1025.213, -1606.252, 13.249), Vector2(1026.680, -1591.979, 13.249)}, -- Roupas LS 2 {Vector2(2587.482, 1179.561, 10.299), Vector2(2572.778, 1182.796, 10.299), Vector2(2572.806, 1149.713, 10.299), Vector2(2585.374, 1148.828, 10.299)}, -- Roupas LV {Vector2(2104.983, 2135.588, 10.149), Vector2(2086.106, 2135.735, 10.149), Vector2(2086.564, 2123.505, 10.149), Vector2(2104.520, 2123.467, 10.149)}, -- Tattoo LV {Vector2(2090.944, 2262.784, 10.149), Vector2(2090.525, 2252.928, 10.149), Vector2(2101.192, 2252.873, 10.149), Vector2(2101.343, 2262.122, 10.149)}, -- Barbeiro LV {Vector2(-2463.578, 336.172, 35.643), Vector2(-2441.290, 372.818, 35.643), Vector2(-2417.052, 352.575, 35.643), Vector2(-2438.281, 316.321, 35.643)}, -- Barbeiro LV {Vector2(878.022, 1202.303, -98.186), Vector2(884.557, 1201.543, -98.186), Vector2(884.418, 1197.178, -98.186), Vector2(877.970, 1197.131, -98.186)}, -- Barbeiro LV } COLLISIONS_AREAS.AREAS = {} COLLISIONS_AREAS.INDEX = {} local function onEnterBlockZone(element) local zone = COLLISIONS_AREAS.INDEX[source]; if not isElement(element) or getElementType(element) ~= "player" then return end if not isElement(source) then return end if not getElementData(element, 'element:collisions') then setElementData(element, 'element:collisions', source, false) end end local function onLeaveBlockZone(element) local zone = COLLISIONS_AREAS.INDEX[source]; if not isElement(element) or getElementType(element) ~= "player" then return end if getElementData(element, 'element:collisions') then setElementData(element, 'element:collisions', nil, false) end end addEventHandler("onClientResourceStart", resourceRoot, function() for _, zone in ipairs(COLLISIONS_AREAS.ZONES) do local blockZone = createColPolygon(zone[1].x, zone[1].y, unpack(zone)) if isElement(blockZone) then COLLISIONS_AREAS.AREAS[blockZone] = true COLLISIONS_AREAS.INDEX[blockZone] = zone addEventHandler("onClientColShapeHit", blockZone, onEnterBlockZone) addEventHandler("onClientColShapeLeave", blockZone, onLeaveBlockZone) end end outputDebugString('['..resource.name..'] '..#COLLISIONS_AREAS.ZONES..' Colisions zones loaded') end) addEventHandler('onClientElementDataChange', root, function(Name, Old, New) if Name ~= 'element:collisions' then return end if not isElement(source) or getElementType(source) ~= 'player' then return end if New then if isElement(New) then local players = getElementsWithinColShape(New, 'player') for i = #players, 1, -1 do local v = players[i]; if isElement(v) then if isElementCollidableWith(source, v) then setElementCollidableWith(v, source, false) setElementCollidableWith(source, v, false) end end end end else if isElement(Old) then local players = getElementsWithinColShape(Old, 'player') for i = #players, 1, -1 do local v = players[i]; if isElement(v) then if not isElementCollidableWith(source, v) then setElementCollidableWith(v, source, true) setElementCollidableWith(source, v, true) end end end end end end) setTimer(function() for blockZone in pairs(COLLISIONS_AREAS.AREAS) do if isElementWithinColShape(localPlayer, blockZone) then local players = getElementsWithinColShape(blockZone, 'player'); for i = #players, 1, -1 do local v = players[i]; if isElement(v) then if not getElementData(v, 'element:collisions') then setElementData(v, 'element:collisions', blockZone, false) end end end end end end, 600, 0) RegisterNetEvent('collisions:requestBlockZones', root, function(x, y, z, radius) local blockZone = createColSphere(x, y, z, radius) if not isElement(blockZone) then return end COLLISIONS_AREAS.AREAS[blockZone] = true COLLISIONS_AREAS.INDEX[blockZone] = {x, y, z, radius} addEventHandler("onClientColShapeHit", blockZone, onEnterBlockZone) addEventHandler("onClientColShapeLeave", blockZone, onLeaveBlockZone) end)