Jump to content

Ajuda bloqueia as armas na area verde, mais quando sai quantinua bloqueado


Recommended Posts

local elementBlocked = 'paradiseAreaVerde' -- Element-Data que será bloqueado.

local elementDesblok = 'paradiseAreaVerde'


addEventHandler ('onClientPlayerWeaponSwitch', root, function ()

    setPedWeaponSlot (source, 0)
    if getElementData (source, elementBlocked) then
    cancelEvent ()
	
    toggleControl ("fire", false)
    toggleControl ("next_weapon", false)
    toggleControl ("previous_weapon", false)
    toggleControl ("sprint", false)
    toggleControl ("aim_weapon", false)
    toggleControl ("vehicle_fire", false)
	return
  end
 end)
 
 
 
 addEventHandler ("onColShapeLeave", getRootElement(), 
function(leaveElement, matchingDimension)
  if (getElementType (leaveElement) == "player") and (getElementID (source) == "greenzoneColshape") then
  
    toggleControl ("fire", true)
    toggleControl ("next_weapon", true)
    toggleControl ("previous_weapon", true)
    toggleControl ("sprint", true)
    toggleControl ("aim_weapon", true)
    toggleControl ("vehicle_fire", true)

    showPlayerHudComponent (leaveElement, "ammo", true)
    showPlayerHudComponent (leaveElement, "weapon", true)
    triggerClientEvent (leaveElement, "disableGodMode", leaveElement)
  end
end)
 
addEventHandler("onClientPlayerDamage", getLocalPlayer(),
function()
	if getElementData(source,"paradiseAreaVerde") then
	cancelEvent()
	end
end)

addEventHandler("onClientPlayerStealthKill", getLocalPlayer(),
function(targetPlayer)
	if getElementData(targetPlayer,"paradiseAreaVerde") then
	cancelEvent()
	end
end)

addEventHandler("onClientVehicleDamage", root,
function()
	local occupants = getVehicleController(source)
	if (occupants) then
	godmode = getElementData(occupants,"paradiseAreaVerde")
	if (godmode) then
	cancelEvent()
	end
	end
end)

addEventHandler("onClientElementDataChange", root,
	function (dataName)
	if (dataName == "paradiseAreaVerde") then
	if (source:getData("paradiseAreaVerde")) then
	if (source:getType() == "player") then
	for k, v in ipairs (Element.getAllByType("player")) do
	source:setCollidableWith(v, false);
	end
	for k, v in ipairs (Element.getAllByType("vehicle")) do
	source:setCollidableWith(v, false);
	end
	elseif (source:getType() == "vehicle") then
	for k, v in ipairs (Element.getAllByType("vehicle")) do
	source:setCollidableWith(v, false);
	end
	for k, v in ipairs (Element.getAllByType("player")) do
	source:setCollidableWith(v, false);
	end
	end
	else
	if (source:getType() == "player") then
	for k, v in ipairs (Element.getAllByType("player")) do
	source:setCollidableWith(v, true);
	end
	for k, v in ipairs (Element.getAllByType("vehicle")) do
	source:setCollidableWith(v, true);
	end
	elseif (source:getType() == "vehicle") then
	for k, v in ipairs (Element.getAllByType("vehicle")) do
	source:setCollidableWith(v, true);
	end
	for k, v in ipairs (Element.getAllByType("player")) do
	source:setCollidableWith(v, true);
	end
	end
	end
	end
	end
)

 

Edited by Nakka Lindo
Link to comment
  • Nakka Lindo changed the title to Ajuda bloqueia as armas na area verde, mais quando sai quantinua bloqueado

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...