Jump to content

Recommended Posts

Something like this should work:
 

local healthlossTime = 1000
local lastHealthLossTick = 0

function isPlayerInCircle(player, cx,cy,radius)
	local px,py = getElementPosition( player )
	return (getDistanceBetweenPoints2D( px, py, cx, cy ) <= radius)
end

local cx,cy,radius = 0,0,100

function checkPlayerCircleStatus()
	local currentTick = getTickCount()
	if (currentTick - lastHealthLossTick) > healthlossTime then
		if isPlayerInCircle(localPlayer, cx, cy, radius) then
			local health = getElementHealth( localPlayer )
			if health > 0 then
				setElementHealth( localPlayer, health-10 )
			end
			lastHealthLossTick = currentTick
		end
	end
end
addEventHandler( "onClientRender", root, checkPlayerCircleStatus )

For some explanation, this way doesn't use any markers, it uses "onClientRender" event to take 10 health from player every second when he's inside of circle that has center in point "cx,cy", and has radius of "radius". I haven't tested it, but it should work.

  • Thanks 1
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...