Jump to content

onColShapeHit


TorNix~|nR

Recommended Posts

Hello guys, I have this little problem, it makes me crazy xD

I already set when a zombie enter to the safe zone, he will disappear (destroyElement)

I want to make when the player enter to the safe zone, any zombies disappear, any help please?

                                addEventHandler ( 'onColShapeHit', pColshape,
                                    function ( pHitElement, ped )		
                                        if getElementType( pHitElement ) == 'player' then
											if getElementData(pHitElement,"boss") ~= true then
                                            textDisplayAddObserver(display, pHitElement)
                                            if not bUseGunsInSavePlace then
                                            end
                                            if not bUseDamageInSaveZone then
                                                setElementData( pHitElement, 'damage', 'no' )
                                            end
										end
                                        elseif getElementType( pHitElement ) == 'ped' then -- check if the entered ped kill it  
										local aa = getElementData(pHitElement, "zombie")
                                            if getElementData(pHitElement, "zombie") then
                                            if getElementData(pHitElement,"boss") ~= true then
			                          destroyElement(pHitElement, aa) -- THIS ONE DISAPPEAR THE ZOMBIE WHEN JOIN THE SAFE ZONE
                                            end													
                                        end--
                                    end--
                                 end--
                                )  

 

Link to comment

yes, when a player enter to the safe zone, kill all the zombies (like the zombies who are coming to him)

when I am in safe zone, the zombies come, they annoy, but they get killed if they join the safe zone

so the point is, I will if a player enter the safe zone, kill the zombies

Link to comment
addEventHandler('onColShapeHit', pColshape, function(pHitElement, ped)		
	if getElementType(pHitElement) == 'player' then
		if getElementData(pHitElement,"boss") ~= true then
			textDisplayAddObserver(display, pHitElement)
			if not bUseGunsInSavePlace then
			end
			if not bUseDamageInSaveZone then
				setElementData(pHitElement, 'damage', 'no')
			end
			for i, k in pairs(getElementsByType("ped")) do
				if getElementData(k, "zombie") then
					if getElementData(k, "target") == pHitElement then -- You may have to change this.
						destroyElement(k)
					end
				end
			end
		end
	elseif getElementType(pHitElement) == 'ped' then -- check if the entered ped kill it  
		local aa = getElementData(pHitElement, "zombie")
		if getElementData(pHitElement, "zombie") then
			if getElementData(pHitElement,"boss") ~= true then
				destroyElement(pHitElement, aa) -- THIS ONE DISAPPEAR THE ZOMBIE WHEN JOIN THE SAFE ZONE
			end													
		end
	end
end) 

Try this.

Edited by NeXuS™
  • Confused 1
Link to comment
local timerTable = {}

addEventHandler('onColShapeHit', pColshape, function(pHitElement, ped)		
	if getElementType(pHitElement) == 'player' then
		if getElementData(pHitElement,"boss") ~= true then
			textDisplayAddObserver(display, pHitElement)
			if not bUseGunsInSavePlace then
			end
			if not bUseDamageInSaveZone then
				setElementData(pHitElement, 'damage', 'no')
			end
			timerTable[pHitElement] = setTimer(function()
				for i, k in pairs(getElementsByType("ped")) do
					if getElementData(k, "zombie") then
						if getElementData(k, "target") == pHitElement then -- You may have to change this.
							destroyElement(k)
						end
					end
				end
			end, 500, 0)
		end
	elseif getElementType(pHitElement) == 'ped' then -- check if the entered ped kill it  
		local aa = getElementData(pHitElement, "zombie")
		if getElementData(pHitElement, "zombie") then
			if getElementData(pHitElement,"boss") ~= true then
				destroyElement(pHitElement, aa) -- THIS ONE DISAPPEAR THE ZOMBIE WHEN JOIN THE SAFE ZONE
			end													
		end
	end
end)

addEventHandler("onColShapeLeave", pColshape, function(hitElement)
	if isTimer(timerTable[hitElement]) then
		killTimer(timeTable[hitElement])
		timerTable[hitElement] = nil
	end
end)

What about this?

Edited by NeXuS™
  • Sad 1
Link to comment

I'm using slothbot only for boss script, but the zombies are without slothbot

Before this post, I sent you a wrong script, here it is the working one, if you want try it, you will see a green map on F11, sorry for taking your time.

                local aSavePlaces =
                {
                    Circle =
                    {
                        -- x, y, radius
                    },
                    Cuboid =
                    {
                        -- x, y, z, Width, Depth, Height
                    },
                    Rectangle =
                    {
                        -- X, Y, Width, Height
                    { 1155.28, -1350.23, 65, 58, 0, 255, 0, 0 },									
                    },
                    Sphere =
                    {
                        -- X, Y, Z, Radius
                    },
                    Tube =
                    {
                        -- X, Y, Z, Radius, Height
                    },
                    Polygon =
                    {
                        -- X, Y, X1, Y1, X2, Y2, X3, Y3, ...
                        -- You can add like X4, Y4 ..
                    }
                }
                 
                local aRadarAreaPlaces =
                {

                    { 1155.28, -1350.23, 65, 58, 0, 255, 0, 70 },					
									
                }
                 
                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 ( )
                        local display = textCreateDisplay ()
                        local text = textCreateTextItem("", 0.15, 0.53, "high", 150, 0, 0, 255, 2, "right", "bottom")
                        textDisplayAddText(display, text)
                        for s, _ in pairs( aSavePlaces ) do
                            for _, a in pairs( aSavePlaces[ s ] ) do
                                pColshape = _G[ 'createCol' .. s ]( unpack( a ) )
                                setElementData( pColshape, 'zombieProof', false )
                               
                                addEventHandler ( 'onColShapeHit', pColshape,
                                    function ( pHitElement, ped )
		            triggerClientEvent (pHitElement, "welcome88", pHitElement)
		            triggerClientEvent (pHitElement, "yes1", pHitElement)				
                                        if getElementType( pHitElement ) == 'player' then
											if getElementData(pHitElement,"boss") ~= true then
                                            textDisplayAddObserver(display, pHitElement)
                                            if not bUseGunsInSavePlace then
                                            end
                                            if not bUseDamageInSaveZone then
                                                setElementData( pHitElement, 'damage', 'no' )
                                            end
										end
                                        elseif getElementType( pHitElement ) == 'ped' then -- check if the entered ped kill it  
										local aa = getElementData(pHitElement, "zombie")
                                            if getElementData(pHitElement, "zombie") then
                                            if getElementData(pHitElement,"boss") ~= true then
												destroyElement(pHitElement, aa)
                                            end													
                                        end--
                                    end--
                                 end--
                                )  
     
                                addEventHandler ( 'onColShapeLeave', pColshape,
                                    function ( pLeaveElement )
		            triggerClientEvent (pLeaveElement, "fail88", pLeaveElement)		
		            triggerClientEvent (pLeaveElement, "no1", pLeaveElement)						
                                        if getElementType( pLeaveElement ) == 'player' then
                                            textDisplayRemoveObserver(display, pLeaveElement)
                                            if not bUseGunsInSavePlace then
                                            end
                                            if not bUseDamageInSaveZone then
                                                setElementData( pLeaveElement, 'damage', 'yes' )
                                            end
                                        elseif getElementType( pLeaveElement ) == 'ped' then -- check if the entered ped kill it
                                        end
                                    end
                                )
                            end
                        end
                        if bUseRadarArea then
                            for _, a in ipairs( aRadarAreaPlaces ) do
                                pRadarArea = createRadarArea ( unpack( a ) )
                                setElementData( pRadarArea, 'zombieProof', true )
                            end
                        end
                    end    
                )
				

 

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