Crook4Money Posted December 21, 2017 Share Posted December 21, 2017 Can anyone show me a simple script for making a player lose health if he's in a marker or something. I can't seem to get the player to lose health that way. Basically trying to go for a zone method like PUBG where you lose health over time in a circle. Link to comment
quindo Posted December 22, 2017 Share Posted December 22, 2017 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. 1 Link to comment
Crook4Money Posted December 22, 2017 Author Share Posted December 22, 2017 Ah, I thought I'd have to use a ColShape which is what I was trying before. This was a lot more complex than I originally thought. lol Nice. It works just as I wanted it to. Thanks. Link to comment
Crook4Money Posted December 22, 2017 Author Share Posted December 22, 2017 How would you go about showing the radius on the map? Link to comment
quindo Posted December 22, 2017 Share Posted December 22, 2017 Depends on what map do you use, it could be as easy as using https://wiki.multitheftauto.com/wiki/DxDrawCircle to draw the circle on screen. Link to comment
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now