Jump to content

Dead on water


maarten123

Recommended Posts

Hello everyone,

I have a server with the TDMA gamemode and to my surprise do not you die if you jump into the water.

So now I want a script that when you go swimming then you die

I thought of as the swimming animation is played then you die

but I can not really scripting in LUA, so would anyone here would like to help me.

Regards Maarten123 :D

Sorry for my bad english, I'm dutch :P

Link to comment

(As far as I know:) there is no event for as a player gets in/out water, so the only option would be a timer to check every player, and see if they're in water or not. Such as below;

function makeTimer()
setTimer(checkPlayers,5000,0)
end
addEventHandler("onResourceStart",getResourceRootElement(),makeTimer)
 
function checkPlayers()
for k, v in ipairs(getElementsByType("player")) do
if (isElementInWater(v)) then
killPed(v)
end
end
end

Link to comment

Why server-side? Try client-side. When you die, it gets sync, so there should be no problem.

addEventHandler("onClientRender", getRootElement(), function ()
   if(isElementInWater(getLocalPlayer())) then
       setElementHealth(getLocalPlayer(), 0)
   end
end
)

This is a snippet, but all you have to copy and paste this code somewhere in your code.

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