Jump to content

Zone


Recommended Posts

im trying to disable friendlyfire in a zone..  so i created a zone, so players cannot kill another players.. but when they go outside the zone.. they can kill each other.. but its not working..

local aSavePlaces = 
{
	Rectangle =
	{
		-- X, Y, Ancho, Alto --
		{  -3000, -2989, 6000, 3500 };
	};
}

local aRadarAreaPlaces = 
{
	-- x,  y ,Ancho, Alto, color: R, G, B, A. --
	{  -3000, -2989, 6000, 3500, 0, 255, 0, 180 };

}

local sResourceName      	  	= getResourceName ( resource )
local bUseGunsInSavePlace      	= get( sResourceName .. '.UseGunsInSaveZone' )
local bUseRadarArea            	= get( sResourceName .. '.UseRadarArea' )
local pColshape, pRadarArea

local bUseRunInSaveZone     	= get( sResourceName .. '.UseRunInSaveZone' )
local bUseJumpInSaveZone       	= get( sResourceName .. '.UseJumpInSaveZone' )
local bUseWeaponHudInSaveZone  	= get( sResourceName .. '.UseWeaponHudInSaveZone' )
local bUseAmmoHudInSaveZone   	= get( sResourceName .. '.UseAmmoHudInSaveZone' )

local bUseDamageInSaveZone   	= get( sResourceName .. '.UseDamageInSaveZone' )

addEventHandler ( 'onResourceStart', resourceRoot, 
	function ( )
		for s, _ in pairs( aSavePlaces ) do
			for _, a in pairs( aSavePlaces[ s ] ) do
				pColshape = _G[ 'createCol' .. s ]( unpack( a ) )
				--setElementData( pColshape, 'zombieProof', true )
				
				addEventHandler ( 'onColShapeHit', pColshape, 
                                function ( pHitElement ) 
                                    if getElementType( pHitElement ) == 'player' then 
                                        textDisplayAddObserver(display, pHitElement) 
                                        if not bUseGunsInSavePlace then 
                                        end 
                                        if not bUseDamageInSaveZone then 
                                            setElementData( pHitElement, 'damage', 'no' ) 
                                        end 
                                    elseif getElementType( pHitElement ) == 'ped' then -- check if the entered ped kill it   
                                        if getElementData(pHitElement, "zombie") then 
                                        if getElementData(pHitElement,"boss") ~= false then 
                                            killPed(pHitElement) 
                                        end 
                                    end-- 
                                end-- 
                             end-- 
                            )
							
				addEventHandler ( 'onColShapeLeave', pColshape, 
					function ( pLeaveElement )
						if getElementType( pLeaveElement ) == 'player' then
							if not bUseGunsInSavePlace then
								toggleControl ( pLeaveElement, 'fire', true )
								toggleControl ( pLeaveElement, 'aim_weapon', true )
								toggleControl ( pLeaveElement, 'vehicle_fire', true )
							end
							if not bUseRunInSaveZone then
								toggleControl ( pLeaveElement, 'sprint', true )
							end
							if not bUseJumpInSaveZone then
								toggleControl ( pLeaveElement, 'jump', true )
							end
							if not bUseWeaponHudInSaveZone then
								showPlayerHudComponent ( pLeaveElement, 'weapon', true ) 
							end
							if not bUseAmmoHudInSaveZone then
								showPlayerHudComponent ( pLeaveElement, 'ammo', true ) 
							end
							if not bUseDamageInSaveZone then
								setElementData( pLeaveElement, 'damage', 'yes' )
							end	 
						elseif getElementType( pLeaveElement ) == 'ped' then -- check if the entered ped kill it
							killPed( pLeaveElement ) -- kill ped
						end
					end
				)
			end
		end
		if bUseRadarArea then
			for _, a in ipairs( aRadarAreaPlaces ) do
				pRadarArea = createRadarArea ( unpack( a ) )
			end
		end
	end    
) 

Players can kill each other inside and outside the zone :/  i want to disable friendlyfire inside zone.. can anyone help ? :/

Edited by Shayan816
Link to comment

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...