Sign in to follow this  
Lergen

Damage player in water

Recommended Posts

Hello. I've had a bit of trouble trying to figure out how to do something. I'm trying to make it so when a player enters water (swimming) it drains his health until he exits it. What's the best way to go about doing this? I've looked around but haven't been able to find any reference points for this. I'd greatly appreciate any help!

Share this post


Link to post
function checkwater()
	if(isPedDoingTask(localPlayer, "TASK_COMPLEX_IN_WATER")) then
		setElementHealth(localPlayer, getElementHealth(localPlayer)-0.5)
	end
end
addEventHandler("onClientPreRender", root, checkwater)

in client

  • Thanks 1

Share this post


Link to post
2 hours ago, alexaxel705 said:

function checkwater()
	if(isPedDoingTask(localPlayer, "TASK_COMPLEX_IN_WATER")) then
		setElementHealth(localPlayer, getElementHealth(localPlayer)-0.5)
	end
end
addEventHandler("onClientPreRender", root, checkwater)

in client

That was exactly what I needed. Thank you.

Share this post


Link to post

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
Sign in to follow this  

  • Recently Browsing   0 members

    No registered users viewing this page.