-- ====================================================================================== -- System: Block fire when player is dead -- Autor: marlondev -- Descrição: -- Bloqueia o uso de armas quando o jogador está morto. -- ====================================================================================== local blockfirewhendied_ = { ignoredZones = { {-2053.624, -995.734, -2104.595, -995.735, -2104.595, -965.901, -2053.625, -965.898}; } } local ignoredZones = {} for i, v in ipairs(blockfirewhendied_.ignoredZones) do local zone = createColPolygon(v[1], v[2], unpack(v)) ignoredZones[zone] = i end local AREAS_BLOCKED_FIRE = {} local function FUck_onEnterColShape(el) if el ~= localPlayer then return end setPedWeaponSlot(el, 0) toggleControl("fire", false) toggleControl("aim_weapon", false) toggleControl("next_weapon", false) toggleControl("previous_weapon", false) toggleControl("action", false) exports['infobox']:dxDrawNotification('Você desmaiou aqui recentemente e não pode realizar algumas ações no momento.', 'error') end local function FUck_onLeaveColShape(el) if el ~= localPlayer then return end toggleControl("fire", true) toggleControl("aim_weapon", true) toggleControl("next_weapon", true) toggleControl("previous_weapon", true) toggleControl("action", true) end addEventHandler('onClientElementDataChange', localPlayer, function(key, old, new) if key ~= 'fall' then return end local InService = getElementData(localPlayer, 'player:inService') if InService and InService == 'Hospital' then return; end if new then local x, y, z = getElementPosition(localPlayer); for i, v in next, ignoredZones do if isElement(i) and isElementWithinColShape(localPlayer, i) then return end end for i, v in next, AREAS_BLOCKED_FIRE do if isElement(i) and isElementWithinColShape(localPlayer, i) then return end end local COLSHAPE = createColCircle(x, y, 100) if isElement(COLSHAPE) then AREAS_BLOCKED_FIRE[COLSHAPE] = {CreatedAt = os.time()} addEventHandler('onClientColShapeHit', COLSHAPE, FUck_onEnterColShape) addEventHandler('onClientColShapeLeave', COLSHAPE, FUck_onLeaveColShape) setPedWeaponSlot(localPlayer, 0) end end end) addEventHandler('onClientPlayerWasted', localPlayer, function(killer, weaponID, bodyPart) local InService = getElementData(localPlayer, 'player:inService') if InService and InService == 'Hospital' then return; end for i, v in next, ignoredZones do if isElement(i) and isElementWithinColShape(localPlayer, i) then return end end for i, v in next, AREAS_BLOCKED_FIRE do if isElement(i) and isElementWithinColShape(localPlayer, i) then return end end local COLSHAPE = createColCircle(x, y, 100) if isElement(COLSHAPE) then AREAS_BLOCKED_FIRE[COLSHAPE] = {CreatedAt = os.time()} addEventHandler('onClientColShapeHit', COLSHAPE, FUck_onEnterColShape) addEventHandler('onClientColShapeLeave', COLSHAPE, FUck_onLeaveColShape) setPedWeaponSlot(localPlayer, 0) end end) addEventHandler('onClientPlayerWeaponSwitch', localPlayer, function(prevSlot, currSlot) local InService = getElementData(localPlayer, 'player:inService') if InService and InService == 'Hospital' then return; end if getPedWeapon(localPlayer, currSlot) ~= 0 then for i, v in next, AREAS_BLOCKED_FIRE do if isElement(i) and isElementWithinColShape(localPlayer, i) then cancelEvent(true, 'You cannot use this weapon here.') exports['infobox']:dxDrawNotification('Você desmaiou aqui recentemente e não pode realizar algumas ações no momento.', 'error') return end end end end, true, 'high+999') CreateThread(function() while true do local NOW = os.time(); for i, v in next, AREAS_BLOCKED_FIRE do if isElement(i) then if (NOW - v.CreatedAt) >= (10 * 60) then removeEventHandler('onClientColShapeHit', i, FUck_onEnterColShape) removeEventHandler('onClientColShapeLeave', i, FUck_onLeaveColShape) destroyElement(i) AREAS_BLOCKED_FIRE[i] = nil FUck_onLeaveColShape(localPlayer) end else AREAS_BLOCKED_FIRE[i] = nil end end Wait(2000) end end) RegisterNetEvent('onClearAreas', root, function() for i, v in next, AREAS_BLOCKED_FIRE do if isElement(i) then removeEventHandler('onClientColShapeHit', i, FUck_onEnterColShape) removeEventHandler('onClientColShapeLeave', i, FUck_onLeaveColShape) destroyElement(i) AREAS_BLOCKED_FIRE[i] = nil end end end)